Git Product home page Git Product logo

Comments (3)

rgrove avatar rgrove commented on July 4, 2024

Hmm. Based on my understanding of Section 2.2 of XML 1.0 5th ed., control characters are invalid in XML documents even when represented by a character reference.

Just in case I misinterpreted the spec, I tried parsing <a>hello&#x7;</a> with libxml2. It produced a parser error:

parser error : xmlParseCharRef: invalid xmlChar value 7
<a>hello&#x7;</a>
             ^

I'd prefer not to relax this check, even via an option, since it seems like doing so would result in a parser that consumes invalid documents, and my goal with parse-xml is to conform to the spec as closely as is practical (minus the unsafe parts).

Of course, you should feel free to maintain this change yourself in a fork if it would be useful to you!

from parse-xml.

rossj avatar rossj commented on July 4, 2024

Thank you for your feedback. It seems that my files do conform to XML 1.1, as Section 2.2. of XML 1.1 does expand the char class to allow these additional control characters. My understanding is that XML 1.1 is not very common or widely implemented, so I'll just try some changes in my fork.

Thanks again.

from parse-xml.

rgrove avatar rgrove commented on July 4, 2024

Ah, interesting.

My reason for not implementing an XML 1.1 parser is basically that I came across this old excerpt from the book Effective XML, which pretty strongly recommends not bothering with XML 1.1:

Everything you need to know about XML 1.1 can be summed up in two rules:

  1. Don't use it.

  2. (For experts only) If you speak Mongolian, Yi, Cambodian, Amharic, Dhivehi, Burmese or a very few other languages and you want to write your markup (not your text but your markup) in these languages, then you can set the version attribute of the XML declaration to 1.1. Otherwise, refer to rule 1.

But I'm not completely opposed to the idea of adding XML 1.1 parsing capability as an opt-in feature via the <?xml> directive and/or a runtime option, if it's something that would actually be useful and if it could be done without adding significant complexity or code weight.

from parse-xml.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.