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

Issue when deserializing XML with default namespace in ProvToolbox #215

Open
mf-16 opened this issue Feb 21, 2024 · 0 comments
Open

Issue when deserializing XML with default namespace in ProvToolbox #215

mf-16 opened this issue Feb 21, 2024 · 0 comments

Comments

@mf-16
Copy link

mf-16 commented Feb 21, 2024

I found an issue in the newest version of ProvToolbox, 2.0.4, when handling the default namespace in XML.

Let me demonstrate the issue with this XML file:

<?xml version='1.0' encoding='ASCII'?>
<prov:document xmlns:ex="https://example.org/" xmlns="https://default.org/" xmlns:prov="http://www.w3.org/ns/prov#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <prov:entity prov:id="e"/>
</prov:document>

When deserializing the identifier using the CustomQualifiedNameDeserializer#deserialize() method, it uses the DeserializerUtil#getAttributeValue() method.
On line 46 in DeserializerUtil#getAttributeValue() , when the identfier does not have a prefix, you used following:

xmlParser.getStaxReader().getNamespaceURI();

But this only gets the current element namespace which is prov, because it's in the <prov:entity> element.
Therefore, prov is registered as default namespace and the identfier of entity corresponds to IRI http://www.w3.org/ns/prov#/e.
However it should be https://default.org/e.
So, I think a better solution would be to use the following:

xmlParser.getStaxReader().getNamespaceURI("");

The statement above returns the default namespace. The correct namespace is registered as a default instead of the prov namespace being registered as default one.

@mf-16 mf-16 changed the title Issue when deserializing XML with defualt namespace in ProvToolbox Issue when deserializing XML with default namespace in ProvToolbox Feb 25, 2024
lucmoreau pushed a commit that referenced this issue Mar 22, 2024
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

No branches or pull requests

1 participant