Reputation: 43
i checked many threads that have the same title but all of them are demo different problem than mine. so if i was wrong, can someone to point me to right thread.
i'm building my own SAX XML parser beside the test tool that will used to send XML file to the parser then the test tool will receive the fired event from SAX parser to reconstruct the XML and to be compared with transmitted one to verify the proper operation of parser.
anyway, i'm using oasis test cases, especially (o-p04pass1)
<doc>
<abcdefghijklmnopqrstuvwxyz/>
<ABCDEFGHIJKLMNOPQRSTUVWXYZ/>
<A01234567890/>
<A.-:̀·/>
</doc>
so to reconstruct <A.-:̀·/>
, i'm using the following C# code and i'm getting exception System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name. with the following line
currentXMLElement = new XElement(startString[0], "");
startString[0] will contain A.-:̀·
which will cause the exception.
my questions are:
- the : is one of accepted character in the name according to the latest standard https://www.w3.org/TR/xml/#NT-NameStartChar, so why i'm getting the exception?
- Am using the correct function to reconstruct the XML, and if not, what is best way to do it?
Thanks, Mohammed Fawzy
Upvotes: 1
Views: 169
Reputation: 163468
For most people today, "XML" means "XML plus Namespaces", that is, the combination of XML 1.0 plus XML Namespaces 1.0 (or sometimes XML 1.1 plus Namespaces 1.1, though that combination is less popular). XML 1.0 can in theory be used without namespaces, but hardly anyone does so.
So you may well have found a test suite that uses colons in a way that is permitted by XML 1.0 but disallowed by XML Namespaces 1.0, and only you can decide what you want to do with such test cases. Whether your XML parser will accept them depends on what standards it chooses to conform to, and possibly on how it is configured. In the real world (as distinct from the world of conformance testing), documents that conform to XML 1.0 but don't conform to XML Namespaces 1.0 are of little practical interest.
Upvotes: 1