2004-03-01 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / web / xml-classes
1 * XML Classes
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
16 ** System.Xml namespace
17
18
19 *** Document Object Model (Core)
20
21   DOM feature has already implemented. There is still missing feature.
22
23         <ul>
24                 * ID constraint support is problematic because W3C DOM does not 
25                   specify handling of ID attributes into non-adapted element. 
26                   (MS.NET also looks incomplete in this area).
27         </ul>
28
29 *** Xml Writer
30
31   Here XmlWriter almost equals to XmlTextWriter. If you want to see
32   another implementation, check XmlNodeWriter.cs and DTMXPathDocumentWriter.cs
33   in System.XML sources.
34
35   XmlTextWriter is completed, though it looks a bit slower than MS.NET (I 
36   tried 1.1).
37
38 *** XmlResolver
39
40   Currently XmlTextReader uses specified XmlResolver. If nothing was supplied,
41   then it uses XmlUrlResolver. XmlResolver is used to parse external DTD,
42   importing XSL stylesheets and schemas etc.
43
44   However, XmlUrlResolver is still buggy (mainly because System.Uri is also
45   incomplete yet) and this results in several loading error.
46
47   XmlSecureResolver, which is introduced in MS .NET Framework 1.1 is basically
48   implemented, but it requires CAS (code access security) feature. We need to
49   fixup this class after ongoing CAS effort works.
50
51   You might also be interested in an improved <a href="http://codeblogs.ximian.com/blogs/benm/archives/000039.html">XmlCachingResolver</a> by Ben Maurer.
52
53 *** XmlNameTable
54
55   NameTable itself is implemented. However, it should be actually used in
56   several classes. Currently it makes sense if compared names are both in
57   the table, they should be simply compared using ReferenceEquals(). We
58   have done where it seems possible e.g. in XmlNamespaceManager (in .NET 
59   1.2 methods; if the build is not NET_1_2, it will be used internally).
60
61   NameTable also needs performance improvement.
62
63 *** Xml Stream Reader
64
65   When we are using ASCII document, we don't care which encoding we are using.
66   However, XmlTextReader must be aware of the specified encoding in XML
67   declaration. So we have internal XmlStreamReader class (and currently
68   XmlInputStream class. This may disappear since XmlStreamReader is enough to
69   handle this problem).
70
71   However, there seems some problems in these classes on reading network
72   stream (especially on Linux). This should be fixed soon, if we found the
73   actual reason.
74
75 *** XML Reader
76
77   XmlTextReader, XmlNodeReader and XmlValidatingReader are almost finished.
78
79         <ul>
80                 * All OASIS conformance test passes as Microsoft does. Some 
81                   W3C tests fail, but it looks better.
82                 * Entity expansion and its well-formedness check is incomplete.
83                   It incorrectly allows divided content models. It incorrectly
84                   treats its Base URI, so some dtd fails.
85                 * I won't add any XDR support on XmlValidatingReader. (I haven't
86                   ever seen XDR used other than Microsoft's BizTalk Server 2000,
87                   and Now they have 2002 with XML Schema support)
88         </ul>
89
90   XmlTextReader and XmlValidatingReader should be faster than now. Currently
91   XmlTextReader looks nearly twice as slow as MS.NET, and XmlValidatingReader
92   (which uses this slow XmlTextReader) looks nearly three times slower. (Note
93   that XmlValidatingReader won't be slow as itself. It uses schema validating
94   reader and dtd validating reader.)
95
96
97 **** Some Advantages
98
99   The design of Mono's XmlValidatingReader is radically different from
100   that of Microsoft's implementation. Under MS.NET, DTD content validation
101   engine is in fact simple replacement of XML Schema validation engine.
102   Mono's DTD validation is designed fully separate and does validation
103   as normal XML parser does. For example, Mono allows non-deterministic DTD.
104
105   Another advantage of this XmlValidatingReader is support for *any* XmlReader.
106   Microsoft supports only XmlTextReader.
107
108   I added extra support interface named "IHasXmlParserContext", which is
109   considered in XmlValidatingReader.ResolveEntity(). Microsoft failed to 
110   design XmlReader to support pluggable use of XmlReader (i.e. wrapping use
111   of other XmlReader) since XmlParserContext is required to support both
112   entity resolution and namespace manager. (In .NET 1.2, Microsoft also 
113   supported similar to IHasXmlParserContext, named IXmlNamespaceResolver,
114   but it still does not provide any DTD information.)
115
116   We also have RELAX NG validating reader. See mcs/class/Commons.Xml.Relaxng.
117
118
119 ** System.Xml.Schema
120
121 *** Summary
122
123   Basically it is completed. We can compile complex and simple types, refer to
124   external schemas, extend or restrict other types, or use substitution groups.
125   You can test how current schema validation engine is (in)complete by using
126   standalone test module 
127   (see mcs/class/System.XML/Test/System.Xml.Schema/standalone_tests).
128   At least in my box, msxsdtest fails only 30 cases with bugfixed catalog.
129
130 *** Schema Object Model
131
132   Completed, except for some things to be fixed:
133
134         <ul>
135                 * Complete facet support. Currently some of them is missing.
136                   Recently David Sheldon is doing several fixes on them.
137                 * ContentTypeParticle for pointless xs:choice is incomplete
138                   (It is because fixing this arose another bugs in 
139                   compilation. Interestingly, MS.NET also fails around here,
140                   so it might be nature of ContentTypeParticle design)
141                 * Some derivation by restriction (DBR) handling is incorrect.
142         </ul>
143
144 *** Validating Reader
145
146   XML Schema validation feature is (currently) implemented on
147   Mono.Xml.Schema.XsdValidatingReader, which is internally used in
148   XmlValidatingReader.
149
150   Basically this is implemented and actually its feature is almost complete,
151   but I have only did validation feature testing. So we have to write more 
152   tests on properties, methods, and events (validation errors).
153
154
155 ** System.Xml.Serialization
156
157   Lluis rules ;-)
158
159   Well, in fact XmlSerializer is almost finished and is on bugfix phase.
160
161   However, we appliciate more tests. Please try 
162   
163         <ul>
164                 * System.Web.Services to invoke SOAP services.
165                 * xsd.exe and wsdl.exe to create classes.
166         </ul>
167
168   And if any problems were found, please file it to bugzilla.
169
170   Lluis also built interesting standalone test system placed under
171   mcs/class/System.Web.Services/Test/standalone.
172
173   You might also interested in genxs, which enables you to create custom
174   XML serializer. This is not included in Microsoft.NET. 
175   See <a 
176   href="http://primates.ximian.com/~lluis/blog/archives/000120.html">here</a>
177   and mcs/tools/genxs for the details.
178
179
180 ** System.Xml.XPath and System.Xml.Xsl
181
182   There are two implementations for XSLT. One (and historical) implementation
183   is based on libxslt (aka Unmanaged XSLT). Now we uses fully implemented
184   managed XSLT. To use Unmanaged XSLT, set MONO_UNMANAGED_XSLT environment
185   value (any value is acceptable).
186
187   As for Managed XSLT, we support msxsl:script.
188
189   It would be nice if we can support <a href="http://www.exslt.org/">EXSLT</a>.
190   <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
191   is not good code since it depends on internal concrete derivatives of
192   XPathNodeIterator classes.
193
194   In general, .NET's "extension objects" (including msxsl:script) is not
195   usable to return node-sets, so if we support EXSLT, it has to be done
196   internally inside our System.XML.dll. Volunteers are welcome.
197
198   Our managed XSLT implementation is still inefficient. For some kind of
199   transformation, XslTransform.Load() and .Transform() looks slower than MS.
200
201
202 ** System.Xml and ADO.NET v2.0
203
204   Microsoft introduced the first beta version of .NET Framework 1.2 runtime
205   and sdk (and Visual Studio Whidbey). They are now available on MSDN
206   _subscriber_ download (i.e. it is not publicly downloadable yet). It
207   contains several new classes.
208
209   There are two assemblies related to System.Xml v2.0; System.Xml.dll and
210   System.Data.SqlXml.dll (here I treat sqlxml.dll as part of System.Xml v2.0,
211   but note that it is also one of the ADO.NET 2.0 feature). There are several 
212   namespaces such as MS.Internal.Xml and System.Xml. Note that .NET Framework
213   is pre-release version and MS.Internal.Xml namespace apparently shows that
214   it is not in stable status as yet.
215
216   System.Xml 2.0 contains several features such as:
217
218   <ul>
219                 * XPathNavigator2 and XPathDocument2
220                 * XML Query
221                 * XmlAdapter
222                 * XSLT IL generator (similar to Apache XSLTC) - it is 
223                   internal use
224   </ul>
225
226   Tim Coleman started ADO.NET 2.0 related works. Currently I have no plan to
227   implement System.Xml v2.0 classes and won't touch with them immediately, 
228   but will start in some months. If any of you wants to try this frontier,
229   we welcome your effort.
230
231 *** XPathNavigator2
232
233   System.Xml v2.0 implementation will be started from XPathDocument2 and
234   XPathNavigator2 implementations. First, its document structure and basic
235   navigation feature will be implemented. And next, XPath2 engine should
236   be implemented (XPathNavigator2 looks very different from XPathNavigator).
237
238   It is once described as to contain schema validation feature, but MS
239   guys said that they have removed that feature (It is just a beta version,
240   so anything might happen).
241
242 *** XML Query
243
244   XML Query is a new face XML data manipulation language (well, at least new
245   to .NET world). It is similar to SQL, but intended to manipulate and to
246   support XML. It is similar to XSLT, but extended to support new features
247   such as XML Schema based datatypes.
248
249   XML Query implementation can be found mainly in System.Xml.Query and 
250   MS.Internal.Xml.Query namespaces. Note that they are in 
251   System.Data.SqlXml.dll.
252
253   MSDN documentation says that there are two kind of API for XML Query: High
254   Level API and Low Level API. At the time of this beta version, the Low Level
255   API is described not released yet (though it may be MS.Internal.Xml.*
256   classes). However, to implement the High Level API, the Low Level API will 
257   be used. They looks to have interesting class structures in MS.Internal.Xml 
258   related stuff, so it would be nice (and I will) start to learn about them.
259
260   They looks to have IL generator classes, but it would be difficult to
261   start from them.
262
263 *** System.Data.Mapping
264
265   System.Data.Mapping and System.Data.Mapping.RelationalSchema are the
266   namespaces for mapping support between database and xml. This is at
267   stubbing phase (incomplete as yet).
268
269 *** XmlAdapter
270
271   XmlAdapter is used to support XML based query and update using 
272   XPathDocument2 and XPathNavigator2. This class is designed to synthesize
273   ADO.NET and System.Xml. It connects to databases, and querys data in XML
274   shape into XPathDocument2, using Mapping schema above. This must be
275   done after several classes such as XPathDocument2 and MappingSchema.
276
277
278 ** Miscellaneous Class Libraries
279
280 *** RELAX NG
281
282   I implemented an experimental RelaxngValidatingReader. It is still not
283   complete, for example some simplification stuff (see RELAX NG spec 
284   chapter 4; especially 4.17-19) and some constraints (especially 7.3).
285
286   It now supports custom datatype handling. Right now, you can use XML
287   schema datatypes ( http://www.w3.org/2001/XMLSchema-datatypes ) as well
288   as RELAX NG default datatypes (as used in relaxng.rng).
289
290   I am planning improvements (giving more kind error messages, supporting
291   compact syntax and even object mapping), but it is still my wishlist.
292
293
294 ** Tools
295
296 *** xsd.exe
297
298   See <a href="ado-net.html">ADO.NET page</a>.
299
300   Microsoft has another inference class from XmlReader to XmlSchemaCollection
301   (Microsoft.XsdInference). It may be useful, but it won't be so easy.
302
303
304 ** Miscellaneous
305
306 *** Mutual assembly dependency
307
308   Sometimes I hear complain about System.dll and System.Xml.dll mutual
309   dependency: System.dll references to System.Xml.dll (e.g. 
310   System.Configuration.ConfigXmlDocument extended from XmlDocument), while 
311   System.Xml.dll vice versa (e.g. XmlUrlResolver.ResolveUri takes System.Uri).
312   Since they are in public method signatures, so at least we cannot get rid
313   of these mutual references.
314
315   Nowadays System.Xml.dll is built using incomplete System.dll (lacking
316   System.Xml dependent classes such as ConfigXmlDocument). Full System.dll
317   is built after System.Xml.dll is done.
318
319   Also note that you still need System.dll to run mcs.
320