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