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