Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Prolog in aas-spec causes error on deserialization of AASX package #24

Closed
CHRiSLY78 opened this issue Nov 8, 2023 · 3 comments · Fixed by #25
Closed

XML Prolog in aas-spec causes error on deserialization of AASX package #24

CHRiSLY78 opened this issue Nov 8, 2023 · 3 comments · Fixed by #25

Comments

@CHRiSLY78
Copy link

CHRiSLY78 commented Nov 8, 2023

Trying to deserialize an AASX package containing an XML aas-spec with leading XML prolog I get the following error message:

Expected an XML element representing an instance of class Environment, but got a node of type XmlDeclaration with value version="1.0" encoding="UTF-8" at: 

(nothing after at:)

Not working example:

<?xml version="1.0" encoding="UTF-8"?>
<environment xmlns="https://admin-shell.io/aas/3/0" xmlns:IEC="http://www.admin-shell.io/IEC61360/2/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:abac="http://www.admin-shell.io/aas/abac/2/0" xsi:schemaLocation="https://admin-shell.io/aas/3/0 AAS.xsd http://www.admin-shell.io/IEC61360/2/0 IEC61360.xsd" xmlns:aas="https://admin-shell.io/aas/3/0">
	<assetAdministrationShells>
		<assetAdministrationShell>
[...]

Removing the XML prolog from aas-spec file within the package resolves the error.
Working example:

<environment xmlns="https://admin-shell.io/aas/3/0" xmlns:IEC="http://www.admin-shell.io/IEC61360/2/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:abac="http://www.admin-shell.io/aas/abac/2/0" xsi:schemaLocation="https://admin-shell.io/aas/3/0 AAS.xsd http://www.admin-shell.io/IEC61360/2/0 IEC61360.xsd" xmlns:aas="https://admin-shell.io/aas/3/0">
	<assetAdministrationShells>
		<assetAdministrationShell>
[...]

I was not able to find any restriction to XML prologs in part 5 of the specification or at https://github.com/admin-shell-io/aas-specs/tree/master/schemas/xml. And it would surprise me, if there were any in this case to be honest.

Have I overseen something or might this be wrong behavior on aas-core side?

@mristin
Copy link
Contributor

mristin commented Nov 8, 2023

@CHRiSLY78 thanks for posting the issue! Please have a look at the note regarding MoveToContent in the documentation:

https://aas-core-works.github.io/aas-core3.0-csharp/getting_started/xmlize.html#de-serialize

Please re-open if it does not solve the issue.

@mristin
Copy link
Contributor

mristin commented Nov 8, 2023

I'm leaving this open as the error message needs to improve.

mristin added a commit to aas-core-works/aas-core-codegen that referenced this issue Nov 9, 2023
When we encountered XML declarations, we threw exceptions with
uninformative messages. Namely, we expect the reader to be moved to the
content, but most users omitted to read that in the documentation.

We refine the error message for this particular situation, and hint at
`MoveToContent` method on the reader.

See [this aas-core3.0-csharp issue] for more details.

[this aas-core3.0-csharp issue]: aas-core-works/aas-core3.0-csharp#24
mristin added a commit to aas-core-works/aas-core-codegen that referenced this issue Nov 9, 2023
When we encountered XML declarations, we threw exceptions with
uninformative messages. Namely, we expect the reader to be moved to the
content, but most users omitted to read that in the documentation.

We refine the error message for this particular situation, and hint at
`MoveToContent` method on the reader.

See [this aas-core3.0-csharp issue] for more details.

[this aas-core3.0-csharp issue]: aas-core-works/aas-core3.0-csharp#24
mristin added a commit that referenced this issue Nov 9, 2023
When we encountered XML declarations, we threw exceptions with
uninformative messages. Namely, we expect the reader to be moved to the
content, but most users omitted to read that in the documentation.

We refine the error message for this particular situation, and hint at
`MoveToContent` method on the reader.

Fixes #24.

Generated with [aas-core-codegen 28fbd98].

[aas-core-codegen 28fbd98]: aas-core-works/aas-core-codegen@28fbd98
mristin added a commit that referenced this issue Nov 9, 2023
When we encountered XML declarations, we threw exceptions with
uninformative messages. Namely, we expect the reader to be moved to the
content, but most users omitted to read that in the documentation.

We refine the error message for this particular situation, and hint at
`MoveToContent` method on the reader.

Fixes #24.

Generated with [aas-core-codegen 28fbd98].

[aas-core-codegen 28fbd98]: aas-core-works/aas-core-codegen@28fbd98
@mristin
Copy link
Contributor

mristin commented Nov 9, 2023

@CHRiSLY78 a new patch version should be on nuget soon: https://github.com/aas-core-works/aas-core3.0-csharp/releases/tag/v1.0.0-rc5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants