xml-classes 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. * XML Classes Status and Tasks
  2. ** Abstract
  3. XML library is used by several areas of Mono such as ADO.NET and XML
  4. Digital Signature (xmldsig). Here I write about System.Xml.dll and
  5. related tools. This page won't include any classes which are in other
  6. assemblies such as XmlDataDocument.
  7. Note that current corlib has its own XML parser class (Mono.Xml.MiniParser).
  8. Basically System.XML.dll feature is almost finished, so I write this
  9. document mainly for bugs and improvement hints.
  10. ** Status
  11. *** System.Xml namespace
  12. **** Document Object Model (Core)
  13. DOM implementation has finished and our DOM implementation scores better
  14. than MS.NET as to the NIST DOM test results (it is ported by Mainsoft
  15. hackers and in our unit tests).
  16. **** Xml Writer
  17. Here XmlWriter almost equals to XmlTextWriter. If you want to see
  18. another implementation, check XmlNodeWriter.cs and DTMXPathDocumentWriter.cs
  19. in System.XML sources.
  20. XmlTextWriter is completed, though it looks a bit slower than MS.NET (I
  21. tried 1.1).
  22. **** XmlResolver
  23. XmlUrlResolver is implemented.
  24. XmlSecureResolver, which is introduced in MS .NET Framework 1.1 is basically
  25. implemented, but it requires CAS (code access security) feature. We need to
  26. fixup this class after ongoing CAS effort works.
  27. You might also be interested in an improved <a href="http://codeblogs.ximian.com/blogs/benm/archives/000039.html">XmlCachingResolver</a> by Ben Maurer.
  28. If even one time download is not acceptable, you can use <a href="http://primates.ximian.com/~atsushi/XmlStoredResolver.cs">this one</a>.
  29. [2.0] XmlDataSourceResolver is not implemented as yet.
  30. **** XmlNameTable
  31. NameTable is implemented, but also needs performance improvement.
  32. It affects on the whole XML processing performance so much.
  33. Optimization hackings are welcome. There is also a <a
  34. href="http://bugzilla.ximian.com/show_bug.cgi?id=59537">bugzilla entry</a>
  35. for this matter.
  36. **** XML Reader
  37. XmlTextReader, XmlNodeReader and XmlValidatingReader are almost finished.
  38. <ul>
  39. * All OASIS conformance test passes as Microsoft does. Some
  40. W3C tests fail, but it looks better.
  41. * Entity expansion and its well-formedness check is incomplete.
  42. It incorrectly allows divided content models. It incorrectly
  43. treats its Base URI, so some dtd parse fails.
  44. * I won't add any XDR support on XmlValidatingReader. (I haven't
  45. ever seen XDR used other than Microsoft's BizTalk Server 2000,
  46. and Now they have 2002 with XML Schema support). If anyone
  47. contributes an implementation, it would be still nice.
  48. </ul>
  49. XmlTextReader and XmlValidatingReader should be faster than now. Currently
  50. XmlTextReader looks nearly twice as slow as MS.NET, and XmlValidatingReader
  51. (which uses this slow XmlTextReader) looks nearly three times slower. (Note
  52. that XmlValidatingReader wouldn't be so slow as itself. It uses schema
  53. validating reader and dtd validating reader.)
  54. **** Some Advantages
  55. The design of Mono's XmlValidatingReader is radically different from
  56. that of Microsoft's implementation. Under MS.NET, DTD content validation
  57. engine is in fact simple replacement of XML Schema validation engine.
  58. Mono's DTD validation is designed fully separate and does validation
  59. as normal XML parser does. For example, Mono allows non-deterministic DTD.
  60. Another advantage of this XmlValidatingReader is support for *any* XmlReader.
  61. Microsoft supports only XmlTextReader (this bug is fixed in .NET 2.0 beta,
  62. taking shape of XmlReader.Create()).
  63. <del>I added extra support interface named "IHasXmlParserContext", which is
  64. considered in XmlValidatingReader.ResolveEntity(). </del><ins>This is now
  65. made as internal interface.</ins> Microsoft failed to design XmlReader
  66. so that XmlReader cannot be subtree-pluggable (i.e. wrapping use of other
  67. XmlReader) since XmlParserContext shoud be supplied for DTD information
  68. support (e.g. entity references cannot be expanded) and namespace manager.
  69. (In .NET 2.0, Microsoft also supported similar to IHasXmlParserContext,
  70. named IXmlNamespaceResolver, but it still does not provide DTD information.)
  71. We also have RELAX NG validating reader (described later).
  72. *** System.Xml.Schema
  73. **** Summary
  74. Basically it is completed. You can test how current schema validation engine
  75. is complete (incomplete) by using standalone test module (see
  76. mcs/class/System.XML/Test/System.Xml.Schema/standalone_tests).
  77. At least in my box, msxsdtest fails only 30 cases with bugfixed catalog -
  78. this score is better than that of Microsoft implementation. But instead,
  79. we need performance boost. There should be many points to improve
  80. schema compilation and validation.
  81. **** Schema Object Model
  82. Completed, except for some things to be fixed:
  83. <ul>
  84. * Complete facet support. Currently some of them is missing.
  85. Recently David Sheldon is doing several fixes on them.
  86. * ContentTypeParticle for pointless xs:choice is incomplete
  87. (fixing this arose another bugs in compilation.
  88. Interestingly, MS.NET also fails around here, so it might
  89. be nature of ContentTypeParticle design)
  90. * Some derivation by restriction (DBR) handling is incorrect.
  91. </ul>
  92. **** Validating Reader
  93. Basically this is implemented and actually its feature is complete,
  94. but I have only did validation feature testing. So we have to write more
  95. tests on properties, methods, and events (validation errors).
  96. *** System.Xml.Serialization
  97. Lluis rules ;-)
  98. Well, in fact XmlSerializer is almost finished and is on bugfix phase.
  99. However, we appliciate more tests. Please try
  100. <ul>
  101. * System.Web.Services to invoke SOAP services.
  102. * xsd.exe and wsdl.exe to create classes.
  103. </ul>
  104. And if any problems were found, please file it to bugzilla.
  105. Lluis also built interesting standalone test system placed under
  106. mcs/class/System.Web.Services/Test/standalone.
  107. You might also interested in "genxs", which enables you to create custom
  108. XML serializer. This is not included in Microsoft.NET.
  109. See <a
  110. href="http://primates.ximian.com/~lluis/blog/archives/000120.html">here</a>
  111. and manpages for details. Code files are in mcs/tools/genxs.
  112. Lluis also created "sgen", that based on XmlSerializer.GenerateSerializer().
  113. Code files are in mcs/tools/sgen.
  114. *** System.Xml.XPath and System.Xml.Xsl
  115. There are two XSLT implementations. One and historical implementation is
  116. based on libxslt (aka Unmanaged XSLT). Now we uses fully implemented and
  117. managed XSLT by default. To use Unmanaged XSLT, set MONO_UNMANAGED_XSLT
  118. environment value (any value is acceptable).
  119. As for Managed XSLT, we support msxsl:script.
  120. It would be nice if we can support <a href="http://www.exslt.org/">EXSLT</a>.
  121. <a href="http://msdn.microsoft.com/WebServices/default.aspx?pull=/library/en-us/dnexxml/html/xml05192003.asp">Microsoft has tried to do some of them</a>,
  122. but it is not successful because of System.Xml.Xsl design problem:
  123. <ul>
  124. * In general, .NET's "extension objects" (including
  125. msxsl:script) is not useful to return node-sets (MS XSLT
  126. implementation rejects just overriden XPathNodeIterator,
  127. but accepts only their hidden classes. And are the same
  128. in Mono though classes are different)
  129. * In .NET's extension object design, extension function name
  130. is a valid method name that cannot contain some characters
  131. such as '-'. That is, implementing EXSLT in C# is impossible.
  132. </ul>
  133. So if we support EXSLT, it has to be done inside our System.XML.dll.
  134. Microsoft developers are also aware of this problem and some of them wish
  135. to have EXSLT support in WinFX (not whidbey). If anyone is interested
  136. in it, it would be nice.
  137. Our managed XSLT implementation is slower than MS XSLT for some kind of
  138. stylesheets, and faster for some.
  139. *** RELAX NG
  140. I implemented an experimental RelaxngValidatingReader. It is still not
  141. complete, for example some simplification stuff (see RELAX NG spec
  142. chapter 4; especially 4.17-19) and some constraints (especially 7.3).
  143. See mcs/class/Commons.Xml.Relaxng/README for details.
  144. Currently we have
  145. <ul>
  146. * Custom datatype support. Right now, you can use XML schema
  147. datatypes ( http://www.w3.org/2001/XMLSchema-datatypes )
  148. as well as RELAX NG default datatypes (as used in relaxng.rng).
  149. * RELAX NG Compact Syntax support, though not yet stable.
  150. See Commons.Xml.Relaxng.Rnc.RncParser class.
  151. </ul>
  152. ** System.Xml v2.0
  153. Microsoft released the first public beta version of .NET Framework 2.0,
  154. available from <a href="http://www.microsoft.com/downloads/details.aspx?familyid=916EC067-8BDC-4737-9430-6CEC9667655C&displaylang=en">MSDN</a>.
  155. It contains several new classes.
  156. There are two assemblies related to System.Xml v2.0; System.Xml.dll and
  157. System.Data.SqlXml.dll. Most of the important part are in System.Xml.dll
  158. (you will find that the core part of XQuery is in System.Xml.dll; For
  159. example, see some classes in MS.Internal.Xml namespace), so I'll still
  160. spot only on System.Xml.dll.
  161. Note that .NET Framework is pre-release version, so they are subject
  162. to change. Actually many of the pre-released classes vanished.
  163. System.Xml 2.0 contains several features such as:
  164. <ul>
  165. * new XPathNavigator and XPathDocument
  166. * Factory method based and strongly-typed XmlReader
  167. * XML Schema design changes
  168. * XSD Inference
  169. * XQuery implementation
  170. * Well-documented and improved XmlSerializer.
  171. * XSLT IL generator (similar to Apache XSLTC) - it is
  172. internal use
  173. </ul>
  174. *** System.Xml 2.0
  175. **** XmlReader/XmlWrier Factory methods
  176. In .NET 2.0, XmlTextReader, XmlNodeReader, XmlValidatingReader are
  177. obsolete and XmlReader.Create() is recommended (there is however no
  178. alternative way to create XmlNodeReader). Similarly, there are
  179. XmlWriter.Create() overloads.
  180. Currently, Microsoft's XmlWriter.Create() is unreliable and maybe there
  181. will be changes. So basically XmlWriter.Create() is supposed to be done
  182. after the next beta version of .NET 2.0.
  183. Some of XmlReader.Create() overloads are implemented, with limited
  184. XmlReaderSettings support.
  185. **** Typed XmlReader/XmlWriter
  186. In .NET 2.0, XmlReader is supposed to support strongly-typed data reading.
  187. They are based on W3C "XML Schema Datatypes" Recommendation and "XQuery 1.0
  188. and XPath 2.0 Data Model" Working Draft.
  189. Some of XmlReader.ReadValueAsXxx() and XmlWriter.WriteValue() overloads are
  190. implemented, though incompletely. They are based on internal XQueryConvert.
  191. **** Sub-tree handling in XmlReader/XmlWriter/XPathNavigator
  192. Currently XmlReader.ReadSubtree(), XmlWriter.WriteSubtree() and
  193. XPathNavigator.ReadSubtree() are implemented, though not so stable.
  194. They are based on Mono.Xml.SubtreeXmlReader and
  195. Mono.Xml.XPath.XPathNavigatorReader classes.
  196. *** System.Xml.Schema 2.0
  197. Since .NET 1.x is not so compliant with W3C XML Schema specification,
  198. Microsoft had to redesign System.Xml.Schema classes. We also have to
  199. change many things.
  200. 1) It does not expose XmlSchemaDatatype (except for obsolete members).
  201. Primitive types are represented as XmlSchemaSimpleType instances (thus
  202. there are ElementSchemaType, AttributeSchemaType, BaseXmlSchemaType that
  203. replace some existing properties).
  204. 2) "XQuery 1.0 and XPath 2.0 Data Model" datatypes (such as
  205. xdt:dayTimeDuration) are newly supported. They are partially implemented
  206. yet.
  207. 3) schema structures are now bound in parent-child relationship. It is
  208. not yet implemented. With related to it, there seems bunch of schema
  209. compilation bugfixes.
  210. 4) XmlSchemaCollection is not used anymore to represent effective set of
  211. schemas. Instead, new XmlSchemaSet class is used. It should affect on
  212. schema compilation design. In fact, I've implemented XmlSchemaCollection
  213. as more conformant to W3C specification, but there are still many changes
  214. required.
  215. **** XSD Inference
  216. In .NET 2.0, there is an XML Schema inference implementation. Now that
  217. XmlSchemaSet is basically implemented, it can be separately done by anyone.
  218. Volunteer efforts are welcome here.
  219. *** System.Xml.XPath 2.0
  220. **** Editable XPathDocument
  221. in .NET 2.0 XPathDocument is supposed to be editable. Currently we provide
  222. fast document table model based implementation (DTMXPathNavigator), but
  223. by that design change, we (and they) cannot provide fast read only
  224. XPathNavigator from XPathDocument anymore.
  225. Currently, new XPathDocument implementation is provided. The actual
  226. implementation is Mono.Xml.XPath.XPathDocument2, that is simple dom-like
  227. tree model. XPathDocument2 implements the same interfaces as XPathDocument
  228. does. And XPathDocument delegates most of the methods to that class (for
  229. example, XPathDocument.CreateEditor() calls XPathDocument2.CreateEditor()).
  230. Currently Mono.Xml.XPath.XPathDocument2 is unstable (it does not pass
  231. the standalone XSLT tests as well as existing DTMXPathDocument does). So
  232. it did not replace existing XPathDocument implementation, but you can use
  233. new implementation by explicitly setting environment value
  234. USE_XPATH_DOCUMENT_2 = yes. Currently it supports (well, is supposed
  235. to support) basic editor feature such as AppendChild(). Other members
  236. are untested (such as RejectChanges()).
  237. **** extra stuff - XPathEditableDocument
  238. Currently we provide another IXPathEditable; XPathEditableDocument. That is
  239. based on the idea that handles XmlDocument as editor target. It is
  240. implemented as Mono.Xml.XPath.XPathEditableDocument. We might provide this
  241. class as extra set (might be different mono-specific XML assembly).
  242. **** System.Xml.XQuery and System.Xml.Xsl 2.0
  243. XQuery is a new face XML data manipulation language (well, at least new
  244. face in .NET world). It is similar to SQL, but intended to manipulate and to
  245. support XML. It is similar to XPath, but extended to support new features
  246. such as XML Schema based datatypes.
  247. XQuery implementation can be found mainly in System.Xml.Query and
  248. MS.Internal.Xml.Query namespaces. The implementation is mostly
  249. in System.Xml.dll. System.Data.SqlXml.dll just invokes the actual XQuery
  250. processor which resides in System.Xml.dll using reflection.
  251. XQuery implementation will be done in these steps:
  252. <ul>
  253. * XQuery syntax parser that parses xquery string to AST
  254. (abstract syntax tree). -> done.
  255. * XQuery AST compiler into runnable query command
  256. (static context)
  257. * XQuery (dynamic context) runtime = XQuery expression evaluator
  258. + sequence iterator.
  259. * Applied expression classes for XQuery/XPath 2.0 functions and
  260. operators.
  261. * XQuery data model and (mainly) conversion support.
  262. </ul>
  263. *** Relax NG and DSDL in Mono 1.2
  264. Currently we support only RELAX NG as one part of ISO DSDL effort. There
  265. is existing Schematron implementation (NMatrix Project: <a
  266. href="http://sourceforge.net/projects/dotnetopensrc/">
  267. http://sourceforge.net/projects/dotnetopensrc/</a>). With a few changes,
  268. it can be used with mono.
  269. We also don't have multi-language based validation, namely Namespace-based
  270. Validation Dispatch Language (NVDL). To support unwrapping, one special
  271. XmlReader implementation is required (other schema validation support will
  272. be done by ReadSubtree()). Note that we had seen RELAX Namespace, Modular
  273. Namespace (MNS) and Namespace Routing Language (NRL) - that is,
  274. standardization effort is still ongoing (though NVDL looks mostly the same
  275. as NRL).
  276. In Mono 1.2, there might be improvements on Commons.Xml.Relaxng.
  277. <ul>
  278. * Currently RelaxngPattern.Compile() provides cheap compilation
  279. error information. At least it can provide error location.
  280. Also, the type of error should be kind of
  281. RelaxngGrammarException.
  282. * Right now there is no ambiguity detection implementation that
  283. would be useful for RelaxngPattern based xml serialization (if
  284. there is need).
  285. * Because of lack of ambiguity detection, currently
  286. XmlMapping could not be provided. But If anyone is
  287. interested in such effort, integration with XmlSerializer
  288. would be interesting task.
  289. </ul>
  290. ** Tools
  291. *** xsd.exe
  292. See <a href="ado-net.html">ADO.NET page</a>.
  293. Microsoft has another inference class from XmlReader to XmlSchemaCollection
  294. (Microsoft.XsdInference). It may be useful, but it won't be so easy.
  295. ** Miscellaneous
  296. *** Mutual assembly dependency
  297. Sometimes I hear complain about System.dll and System.Xml.dll mutual
  298. dependency: System.dll references to System.Xml.dll (e.g.
  299. System.Configuration.ConfigXmlDocument extended from XmlDocument), while
  300. System.Xml.dll vice versa (e.g. XmlUrlResolver.ResolveUri takes System.Uri).
  301. Since they are in public method signatures, so at least we cannot get rid
  302. of these mutual references.
  303. Nowadays System.Xml.dll is built using incomplete System.dll (lacking
  304. System.Xml dependent classes such as ConfigXmlDocument). Full System.dll
  305. is built after System.Xml.dll is done.
  306. Note that you still need System.dll to run mcs.
  307. Atsushi Eno <[email protected]>
  308. last updated 08/03/2004