xml-classes 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. * XML Classes
  2. ** Abstract
  3. XML library is used by several field 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 named Mono.Xml.MiniParser.
  8. Basically System.XML.dll feature has finished, or almost finished, so
  9. I write this page mainly for bugs and improvement hints.
  10. ** System.Xml namespace
  11. *** Document Object Model (Core)
  12. DOM feature has already implemented. There is still missing feature.
  13. <ul>
  14. * ID constraint support is problematic because W3C DOM does not specify
  15. handling of ID attributes into non-adapted element. (MS.NET also
  16. looks incomplete in this area).
  17. * I think, event feature is not fully tested. There are no concrete
  18. desctiption on which events are risen, so we have to do some
  19. experiment on MS.NET.
  20. </ul>
  21. *** Xml Writer
  22. Here XmlWriter almost equals to XmlTextWriter. If you want to see
  23. another implementation, check XmlNodeWriter.cs used in monodoc.
  24. XmlTextWriter is completed. However, it looks nearly twice as slow as
  25. MS.NET (I tried 1.1)
  26. *** XmlResolver
  27. Currently XmlTextReader uses specified XmlResolver. If nothing was supplied,
  28. then it uses XmlUrlResolver. XmlResolver is used to parse external DTD,
  29. importing XSL stylesheets and schemas etc.
  30. However, XmlUrlResolver is still buggy (mainly because System.Uri is also
  31. incomplete yet) and this results in several loading error.
  32. XmlSecureResolver, which is introduced in MS .NET Framework 1.1 is basically
  33. implemented, but it requires CAS (code access security) feature. We need to
  34. fixup this class after ongoing CAS effort works.
  35. *** XmlNameTable
  36. XmlNameTable itself is implemented. However, it should be actually used in
  37. several classes. Currently it makes sense if compared names are both in
  38. the table, but if it is obvious that compared names are both in this table,
  39. it should be simply compared using ReferenceEquals() (if these names are
  40. different, the comparison is still inefficient yet).
  41. *** Xml Stream Reader
  42. When we are using ASCII document, we don't care which encoding we are using.
  43. However, XmlTextReader must be aware of the specified encoding in XML
  44. declaration. So we have internal XmlStreamReader class (and currently
  45. XmlInputStream class. This may disappear since XmlStreamReader is enough to
  46. handle this problem).
  47. However, there are some problems lies in these classes on reading network
  48. stream (especially on Linux). This should be fixed soon.
  49. *** XML Reader
  50. XmlTextReader, XmlNodeReader and XmlValidatingReader are almost finished.
  51. - Most of the OASIS conformance test passes as Microsoft does, but
  52. about W3C tests, it is not perfect.
  53. - I won't add any XDR support on XmlValidatingReader. (I haven't
  54. ever seen XDR used other than Microsoft's BizTalk Server 2000,
  55. and Now they have 2003 with XML Schema support)
  56. XmlTextReader and XmlValidatingReader should be faster than now. Currently
  57. XmlTextReader looks nearly twice as slow as MS.NET, and XmlValidatingReader
  58. (which uses this slow XmlTextReader) looks nearly three times slower. (Note
  59. that XmlValidatingReader won't be slow as itself. It uses schema validating
  60. reader and dtd validating reader.)
  61. **** Some Advantages
  62. The design of Mono's XmlValidatingReader is radically different from
  63. that of Microsoft's implementation. Under MS.NET, DTD content validation
  64. engine is in fact simple replacement of XML Schema validation engine.
  65. Mono's DTD validation is designed fully separate and does validation
  66. as normal XML parser does. For example, Mono allows non-deterministic DTD.
  67. Another advantage of this XmlValidatingReader is support for *any* XmlReader.
  68. Microsoft supports only XmlTextReader.
  69. I added extra support interface named "IHasXmlParserContext", which is
  70. considered in XmlValidatingReader.ResolveEntity(). Microsoft failed to
  71. design XmlReader to support pluggable use of XmlReader (i.e. wrapping use
  72. of other XmlReader) since XmlParserContext is required to support both
  73. entity resolution and namespace manager. (In .NET 1.2, Microsoft also
  74. supported similar to IHasXmlParserContext, named IXmlNamespaceResolver,
  75. but it still does not provide any DTD information.)
  76. We also have RELAX NG validating reader. See mcs/class/Commons.Xml.Relaxng.
  77. ** System.Xml.Schema
  78. *** Schema Object Model
  79. Basically it is implemented. Some features still needs to fix:
  80. - Complete facet support. Currently some of them is missing. Recently
  81. David Sheldon is doing several fixes on them.
  82. - Complete derivation by restriction (DBR) support. Especially
  83. substitution group won't work with it (However, I won't recommend
  84. both substitution group and DBR, regardless of this incompleteness.)
  85. Some bugs are remaining, but as far as I tried W3C XML Schema test suite
  86. with bugfixes (of test suite), only 69 out of 7581 has failed. With my test
  87. suite fix, MS.NET failed 48 cases.
  88. *** Validating Reader
  89. XML Schema validation feature is (currently) implemented on
  90. Mono.Xml.Schema.XsdValidatingReader, which is internally used in
  91. XmlValidatingReader.
  92. Basically this is implemented and actually its feature is almost complete,
  93. but I have only did validation feature testing. So we have to write more
  94. tests on properties, methods, and events (validation errors).
  95. ** System.Xml.Serialization
  96. Lluis rules ;-)
  97. Well, in fact XmlSerializer is almost finished and is on bugfix phase.
  98. However, more tests are required especially schema import and export
  99. feature. Please try xsd.exe to create classes from schema, or schema
  100. from class. And if any problems were found, please file it to bugzilla.
  101. ** System.Xml.XPath and System.Xml.Xsl
  102. There are two implementations for XSLT. One (and historical) implementation
  103. is based on libxslt. Now we uses fully implemented managed XSLT.
  104. Putting aside bug fixes, we have to support:
  105. - embedded script (such as VB, C#, JScript). So some packages like
  106. latest NAnt (for MS.NET) won't be compiled.
  107. It would be nice if we can support <a href="http://www.exslt.org/">EXSLT</a>.
  108. <a href="http://msdn.microsoft.com/WebServices/default.aspx?pull=/library/en-us/dnexxml/html/xml05192003.asp">Microsoft has already done it</a>, but it
  109. is not good code since it depends on internal concrete derivatives of
  110. XPathNodeIterator classes. In general, .NET's "extension objects" is not
  111. usable to return node-sets, so if we support EXSLT, it has to be done
  112. internally inside our System.XML.dll. Volunteers are welcome.
  113. Our managed XSLT implementation is still inefficient. XslTransform.Load()
  114. and .Transform() looks three times slower (However it depends on
  115. XmlTextReader which is also slow, so we are starting optimization from
  116. that class, not XSLT itself). These number are only for specific cases,
  117. and there might be more critical point on XSLT engine (mainly
  118. XPathNodeIterator).
  119. ** Miscellaneous Class Libraries
  120. *** RELAX NG
  121. I implemented an experimental RelaxngValidatingReader. It is far from
  122. complete, especially simplification stuff (see RELAX NG spec chapter 4),
  123. some constraints (in chapter 7), and datatype handling.
  124. I am planning improvements (starts with renaming classes, giving more
  125. kind error messages, supporting compact syntax and even object mapping),
  126. but it is still my wishlist.
  127. ** Tools
  128. *** xsd.exe
  129. xsd.exe is used to:
  130. 1) generate classes source code from schema
  131. 2) generate DataSet classes source code from schema
  132. 3) generate schema documents from assembly (classes)
  133. 4) infer schema documents from XML instance
  134. 5) convert XDR into XSD
  135. As descrived above, I won't work on 5) XDR stuff.
  136. Current xsd.exe supports 1) and 3)
  137. As for 2) and 4), Currently there is no works on them. (This inference
  138. feature is rather DataSet specific than general purpose use.)
  139. Microsoft has another inference class from XmlReader to XmlSchemaCollection.
  140. It may be useful, but it won't be so easy.
  141. any volunteers?