adapter.xml: improve error messages in case of incorrect namespace declarations #191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, if the elements of an XML document are part of an unknown
namespace, this would lead to cryptic error messages such as:
Unexpected top-level list aas:assetAdministrationShells on line 3
where, the correct expected element is indeed
aas:assetAdministrationShells, leaving the user wondering about what
could possibly be wrong. The only difference is the namespace, which
isn't part of the error message, because it gets replaced by the prefix.
To improve the error messages in this case, a check that compares the
namespaces declared on the document against the ones required by the
deserialization, and errors if a required namespace isn't declared.
Furthermore, the namespace of an element would always be replaced by its
prefix if the prefix is known. However, this turned out to mask errors
in case the namespace is different from the one used by our SDK.
Thus, the function
_element_pretty_identifier()
is adjusted such thatit only replaces the namespace if it matches one of the namespaces known
to our SDK.
Fix #190