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