.NET's XmlReader is a great XML parser, but it has one big flaw in its API: XmlReader doesn't expose attribute types. XML actually defines 8 attribute types: CDATA, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS. Yes, it's DTD, which apparently Microsoft considers to be dead, but ID, IDREF, IDREFS types are really important ones. They provide support for cross-references and many XML languages rely on them, particularly XPath, XSLT, XQuery, XPointer, XInclude.
That means XmlReader cannot be used to develop third-party implementations of those languages unless one sticks to XPathDocument/XmlDocument, which know attribute types internally.
I wonder if XLinq will have this information, because if not - XSLT over XLinq won't be supporting id() function.
Btw, in Java SAX and Stax both happily expose attribute types... Makes me envy.
I though I filed it as a bug years ago, but I didn't. So although it's too late, here it is. I'm sure it will be another "thanks for suggestion, we'll consider it for the next release", but anyway. Vote please whoever cares.
Jonathan, unfortunately SchemaInfo only works for XML Schemas. It's always null for DTD.
DTD information is passed via internal DtdSchemaInfo property...
And old-fashioned XPath/XSLT rely on ID type defined in DTD only.
Another one : for my previous comment I only looked at .NET 1.1.
In 2.0 it seems even easier :
XmlReader.SchemaInfo.SchemaType.Datatype.TokenizedType
HTH,
--Jonathan
Oleg, I just had a quick look with Reflector and it looks like (totally untested)
((XmlSchemaDatatype)(XmlValidatingReader.SchemaType)).TokenizedType
should be what you want.
Yes it's on XmlValidatingReader and not XmlReader but that's to be expected since it relies on parsing the DTD.
Hope this helps,
--Jonathan