XML parsing with default xmlns and line/column data before a CDATA

I am requiring two things while futurely using the xml crate:

  • a. Use a default namespace before parsing a XML document; i.e., xmlns="jetxml" by default at the root element, so that meta-attribute doesn't need to be specified.
  • b. When reaching a <![CDATA[...]]> inside a <fx:Script> element I need the line number and the column at the < character.
    • Nothing important, but I'd like to know if the line number is one or zero based, so I don't have to play with the API.

Looking at ParserConfig2, I don't see anyway of passing the default namespace (requirement a). I don't have idea of how to do requirement b yet (looked at XmlEvent in xml::reader - Rust and there is just a string).

What would you suggest over xml if these requirements aren't possible with it?

OK, it looks like option b. is possible: listen to partial events and then use Position at the reader! But option a. I've no idea yet.

According to @kornel in Add default "xmlns" on ParserConfig2 · Issue #19 · kornelski/xml-rs · GitHub it looks like my idea of using a default namespace is not standard, so I decided to do some changes in my idea.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.