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

The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/' #8

Open
dgil-unedbarbastro opened this issue Jun 10, 2021 · 3 comments

Comments

@dgil-unedbarbastro
Copy link
Contributor

Hi,
I'm trying to use the ONIX-Data parser with ONIX files from a provider and I'm getting this exception:

  Message: 
    System.ArgumentException : The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/'.
  Stack Trace: 
    XmlTextWriter.WriteStartAttribute(String prefix, String localName, String ns)
    XmlDOMTextWriter.WriteStartAttribute(String prefix, String localName, String ns)
    XmlAttribute.WriteTo(XmlWriter w)
    XmlElement.WriteStartElement(XmlWriter w)
    XmlElement.WriteElementTo(XmlWriter writer, XmlElement el)
    XmlElement.WriteTo(XmlWriter w)
    XmlNode.get_OuterXml()
    OnixEnumerator.MoveNext()
    MyService.ParseOnixFile(String filePath) line 42
    MyServiceTests.ParseOnixFile_ShouldReturnOK() line 34
    GenericAdapter`1.GetResult()
    AsyncToSyncAdapter.Await(Func`1 invoke)
    TestMethodCommand.RunTestMethod(TestExecutionContext context)
    TestMethodCommand.Execute(TestExecutionContext context)
    SimpleWorkItem.PerformWork()

The ONIXMessage and all Product xml nodes have the namespace attribute xmlns="http://ns.editeur.org/onix/3.0/reference":

image

If I remove all the xmlns attributes from the file then the parsing works.

I there some way to get the parse working without modifying the original ONIX files?

Thanks in advance.
Best Regards,
Dani

@jaerith
Copy link
Owner

jaerith commented Jun 11, 2021

Namespaces...the bane of anyone who deals with XML. I'll take a look at this issue when I have free time. My first recommendation would be to ask the data provider to stop sending these namespaces (since they're ridiculously pointless), but I know that it's sometimes hard to get such requests granted.

@dgil-unedbarbastro
Copy link
Contributor Author

OK thanks @jaerith, I will try to ask them if they can remove them... probably not ;(

@jaerith
Copy link
Owner

jaerith commented Jun 11, 2021

Hmmm...as I start to look over the code, I'm starting to remember how annoying namespaces can really be, especially with the .NET libraries for XML. It'll probably require a little experimentation and time to create an appropriate implementation.

I'll leave this issue open for now, but since I have less availability in my personal time these days, it may be a while before I tackle this one.

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

No branches or pull requests

2 participants