1 * XML Classes Status and Tasks
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.
10 Note that current corlib has its own XML parser class (Mono.Xml.MiniParser).
12 Basically System.XML.dll feature is almost finished, so I write this
13 document mainly for bugs and improvement hints.
17 *** System.Xml namespace
20 **** Document Object Model (Core)
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).
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.
32 XmlTextWriter is completed, though it looks a bit slower than MS.NET (I
37 XmlUrlResolver is implemented.
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.
43 You might also be interested in some improved implementations which resides
46 [2.0] XmlDataSourceResolver <del>is not implemented as yet</del><ins>vanished</ins>.
50 NameTable is implemented, but also needs performance improvement.
51 Optimization hackings are welcome. There is also a <a
52 href="http://bugzilla.ximian.com/show_bug.cgi?id=59537">bugzilla entry</a>
57 XmlTextReader, XmlNodeReader and XmlValidatingReader are almost finished.
60 * All OASIS conformance test passes as Microsoft does. Some
61 W3C tests fail, but it looks better than Microsoft.
62 * Entity expansion and its well-formedness check is incomplete.
63 It incorrectly allows divided content models. It incorrectly
64 treats its Base URI, so some dtd parse fails.
65 * I won't add any XDR support on XmlValidatingReader. (I haven't
66 ever seen XDR used other than Microsoft's BizTalk Server 2000,
67 and Now they have 2002 with XML Schema support). If anyone
68 contributes an implementation, it would be still nice.
71 XmlTextReader and XmlValidatingReader should be faster than now. Currently
72 XmlTextReader looks nearly twice as slow as MS.NET, and XmlValidatingReader
73 (which uses this slow XmlTextReader) looks nearly three times slower. (Note
74 that XmlValidatingReader wouldn't be so slow as itself. It uses schema
75 validating reader and dtd validating reader.)
80 The design of Mono's XmlValidatingReader is radically different from
81 that of Microsoft's implementation. Under MS.NET, DTD content validation
82 engine is in fact simple replacement of XML Schema validation engine.
83 Mono's DTD validation is designed fully separate and does validation
84 as normal XML parser does. For example, Mono allows non-deterministic DTD.
86 Another advantage of this XmlValidatingReader is support for *any* XmlReader.
87 Microsoft supports only XmlTextReader (this bug is fixed in .NET 2.0 beta,
88 taking shape of XmlReader.Create()).
90 <del>I added extra support interface named "IHasXmlParserContext", which is
91 considered in XmlValidatingReader.ResolveEntity(). </del><ins>This is now
92 made as internal interface.</ins> Microsoft failed to design XmlReader
93 so that XmlReader cannot be subtree-pluggable (i.e. wrapping use of other
94 XmlReader) since XmlParserContext shoud be supplied for DTD information
95 support (e.g. entity references cannot be expanded) and namespace manager.
96 (In .NET 2.0, Microsoft also supported similar to IHasXmlParserContext,
97 named IXmlNamespaceResolver, but it still does not provide DTD information.)
99 We also have RELAX NG validating reader (described later).
102 *** System.Xml.Schema
106 Basically it is completed. You can test how current schema validation engine
107 is complete (incomplete) by using standalone test module (see
108 mcs/class/System.XML/Test/System.Xml.Schema/standalone_tests).
109 At least in my box, msxsdtest fails only 30 cases with bugfixed catalog -
110 this score is better than that of Microsoft implementation. But instead,
111 we need performance boost. There should be many points to improve
112 schema compilation and validation.
114 **** Schema Object Model
116 Completed, except for some things to be fixed:
119 * Complete facet support. Currently some of them is missing.
120 Recently David Sheldon is doing several fixes on them.
121 * ContentTypeParticle for pointless xs:choice is incomplete
122 (fixing this arose another bugs in compilation.
123 Interestingly, MS.NET also fails around here, so it might
124 be nature of ContentTypeParticle design)
125 * Some derivation by restriction (DBR) handling is incorrect.
128 **** Validating Reader
130 Basically this is implemented and actually its feature is complete,
131 but I have only did validation feature testing. So we have to write more
132 tests on properties, methods, and events (validation errors).
135 *** System.Xml.Serialization
137 Lluis Sanchez is the maintainer of this namespace (as well as
138 System.Web.Services).
140 XmlSerializer is almost finished and is on bugfix phase.
142 However, we appliciate more tests. Please try
145 * System.Web.Services to invoke SOAP services.
146 * xsd.exe and wsdl.exe to create classes.
149 And if any problems were found, please file it to bugzilla.
151 Lluis also built interesting standalone test system placed under
152 mcs/class/System.Web.Services/Test/standalone.
154 You might also interested in "genxs", which enables you to create custom
155 XML serializer. See "tools" section discussed later. There is also "sgen"
156 that is introduced in .NET 2.0.
159 *** System.Xml.XPath and System.Xml.Xsl
161 There are two XSLT implementations. One and historical implementation is
162 based on libxslt (aka Unmanaged XSLT). Now we uses fully implemented and
163 managed XSLT by default. To use Unmanaged XSLT, set MONO_UNMANAGED_XSLT
164 environment value (any value is acceptable).
166 As for Managed XSLT, we support msxsl:script.
168 It would be nice if we can support <a href="http://www.exslt.org/">EXSLT</a>.
169 <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>,
170 but it is not successful because of System.Xml.Xsl design problem:
173 * In general, .NET's "extension objects" (including
174 msxsl:script) is not useful to return node-sets (MS XSLT
175 implementation rejects just overriden XPathNodeIterator,
176 but accepts only their hidden classes. And are the same
177 in Mono though classes are different)
179 * In .NET's extension object design, extension function name
180 is a valid method name that cannot contain some characters
181 such as '-'. That is, implementing EXSLT in C# is impossible.
184 So if we support EXSLT, it has to be done inside our System.XML.dll.
185 Microsoft developers are also aware of this problem and some of them wish
186 to have EXSLT support in WinFX (not whidbey). If anyone is interested
187 in it, it would be nice.
189 Our managed XSLT implementation is slower than MS XSLT for some kind of
190 stylesheets, and faster for some.
195 I implemented an experimental RelaxngValidatingReader. It is still not
196 complete, for example some simplification stuff (see RELAX NG spec
197 chapter 4; especially 4.17-19) and some constraints (especially 7.3).
198 See mcs/class/Commons.Xml.Relaxng/README for details.
203 * Custom datatype support. Right now, you can use XML schema
204 datatypes ( http://www.w3.org/2001/XMLSchema-datatypes )
205 as well as RELAX NG default datatypes (as used in relaxng.rng).
207 * RELAX NG Compact Syntax support, though not yet stable.
208 See Commons.Xml.Relaxng.Rnc.RncParser class.
214 Microsoft released the first public beta version of .NET Framework 2.0,
215 available from <a href="http://www.microsoft.com/downloads/details.aspx?familyid=916EC067-8BDC-4737-9430-6CEC9667655C&displaylang=en">MSDN</a>.
216 It contains several new classes.
218 There are two assemblies related to System.Xml v2.0; System.Xml.dll and
219 System.Data.SqlXml.dll. Now that System.Data.SqlXml.dll is little important.
220 It just contains only XQueryCommand class inside System.Xml.* namespace.
221 Most of the important part are in System.Xml.dll.
223 Note that .NET Framework is pre-release version, so they are subject
224 to change. Actually many of the pre-released classes vanished.
226 System.Xml 2.0 contains several features such as:
229 * new XPathNavigator members that supports editing XmlDocument
230 * XmlReaderSettings, XmlWriterSettings and factory methods
231 * Strongly typed XmlReader, XmlWriter and XPathNavigator.
232 * XML Schema design changes
234 * Well-documented and improved XmlSerializer.
235 * XSLT per-stylesheet assembly generator
242 <a href="http://mono.ximian.com/class-status/mono-HEAD-vs-fx-2/class-status-System.Xml.html">
243 Here</a> is the latest status of mono's System.Xml 2.0.
245 Major remaining tasks are:
248 * binary content support on XmlReader
250 * XslCompiledTransform (not available in .NET FX 2.0 as yet)
253 In general, System.Xml 2.0 bits are largely implemented.
255 I have some notes on things marked as "missing" in the above class status
259 * XmlReader, XmlTextReader and XmlValidatingReader has
260 many "missing bits", but ReadValueAsXxx() are obsoleted.
261 They were now taken its place by ReadContentAsXxx() and
262 ReadElementContentAsXxx() methods (those differences come
263 from the basis of the methods: ReadElementString() or
265 * In System.Xml.XPath - first, new features in XPathDocument
266 are said as reverted. So I just commented out those new
267 features that had been already implemented in mono.
268 Other missing classes such as XPathEditableNavigator are
269 obsolete and will vanish at the time of 2.0 RTM.
270 * There are some security attributes. They are either way
271 not applicable as yet, and actually currently corcompare
272 ignores them. (So I already added some, but are ignored.)
275 **** XmlReader/XmlWrier Factory methods
277 In .NET 2.0, XmlTextReader, XmlNodeReader, XmlValidatingReader are
278 obsolete and XmlReader.Create() is recommended (there is however no
279 alternative way to create XmlNodeReader). Similarly, there are
280 XmlWriter.Create() overloads.
282 Currently, Microsoft's XmlWriter.Create() is unstable and there will
283 be changes. So basically remaining XmlWriter.Create() is supposed to be
284 done after the next beta version of .NET 2.0.
286 Some of XmlReader.Create() overloads are implemented, with limited
287 XmlReaderSettings support.
290 **** Strongly typed XmlReader/XmlWriter
292 In .NET 2.0, XmlReader is supposed to support strongly-typed data reading.
293 They are based on W3C "XML Schema Datatypes" Recommendation and "XQuery 1.0
294 and XPath 2.0 Data Model" Working Draft.
296 Note that this W3C specification is just a Working Draft and there might
297 be incompatible changes for those strongly-typed API. For example, in the
298 latest version of the spec (as of November 2004), xs:QName is specified as
299 to have prefix, local name and namespace URI, while .NET XML classes just
300 treat it as XmlQualifiedName which does not contain prefix. So this part of
301 API might become obsolete or useless.
303 Some of XmlReader.ReadValueAsXxx() and XmlWriter.WriteValue() overloads are
304 implemented, though incompletely. They are based on internal XQueryConvert.
307 **** Sub-tree handling in XmlReader/XmlWriter/XPathNavigator
309 Currently XmlReader.ReadSubtree(), XmlWriter.WriteSubtree() and
310 XPathNavigator.ReadSubtree() are implemented, though not well-tested.
311 They are based on Mono.Xml.SubtreeXmlReader and
312 Mono.Xml.XPath.XPathNavigatorReader classes.
315 *** System.Xml.Schema 2.0
317 Since .NET 1.x is not so compliant with W3C XML Schema specification,
318 Microsoft had to redesign System.Xml.Schema classes. We also have to
322 * It does not expose XmlSchemaDatatype as a type of an
323 element or an attribute (except for obsolete members).
324 Primitive types are represented as XmlSchemaSimpleType
325 instances (thus there are ElementSchemaType,
326 AttributeSchemaType, BaseXmlSchemaType that replace some
327 existing properties). Note that XmlSchemaDatatype itself is
328 not deprecated as yet.
330 * "XQuery 1.0 and XPath 2.0 Data Model" datatypes (such as
331 xdt:dayTimeDuration) are newly supported. They are partially
334 * schema structures are now bound in parent-child
335 relationship. It is not yet implemented. With related to
336 it, there seems bunch of schema compilation bugfixes.
338 * XmlSchemaCollection is not used anymore to represent
339 effective set of schemas. Instead, new XmlSchemaSet class
340 is used. It should affect on schema compilation design.
346 In .NET 2.0, there is an XML Schema inference implementation. The API (or
347 implementation design) is not cool and Microsoft will make changes in
348 later version of beta or .NET Framework.
350 **** XmlSchemaValidator
352 It is (somewhat) exposed XML Schema validation functionality. It enables
353 developers to get expected particles and attributes. Actually it is
354 internally used to implement XmlReader.Create() with XmlSchemaSet.
357 *** System.Xml.XPath 2.0
359 **** Editable XPathNavigator
361 In System.Xml 2.0, XPathNavigator has many editing API (that used to be
362 "XPathEditableNavigator"). It enables developers to edit XmlDocument
363 (not for XPathDocument; it is read-only).
365 (In the early stage of .NET 2.0, XPathDocument is supposed to be editable.
366 Also, the new version of editable XPathNavigator had been already
367 implemented in Mono, as Mono.Xml.XPath.XPathEditableDocument.)
370 *** System.Xml.Xsl 2.0
372 There used to be System.Xml.Query.XsltCommand class, and it now disappeared
373 and it is said (by Microsoft developers) that there will be a class named
374 XslCompiledTransform - so it will be included in the next beta version.
375 It is regarded as the identical thing to XsltCommand.
377 XslCompiledtransform seems almost the same as System.Xml.Xsl.XslTransform,
378 but this class transforms documents twice to four times as fast as
379 XslTransform. Instead, stylesheet compilation is much slower, because
380 it generates compiled stylesheet assembly.
384 ** External assemblies for Mono 2.0
388 (<strong>IMPORTANT</strong>: There used to be System.Xml.Query.XQueryCommand
389 class that implemented XQuery, but now Microsoft dropped it for .NET 2.0.
390 So we moved them out to external assembly named Mono.Xml.Ext.dll, but I
391 haven't changed thing so much when I just extracted them. Thus, this
392 section is kept as is, and basically old stuff.)
394 Mono.Xml.Ext.dll contains mainly XQuery implementation, and some utility
397 XQueryCommand implements XQuery. XQuery is a new face XML document
398 manipulation language (at least new face in .NET world). It is similar
399 to XSLT, but extended to support XML Schema based datatypes (and it is
400 not XML based langauge). It is similar to XPath, but it can construct
401 XML nodes. It has no complicated template resolution, but works like
402 functional languages.
404 Under MS.NET, XQuery implementation is mainly in System.Xml.Query and
405 MS.Internal.Xml.* namespaces. The implementation is mostly
406 in System.Xml.dll. It is also true to our System.Xml.dll. Our XQueryCommand
407 in System.Data.SqlXml.dll just invokes the actual XQuery processor
408 (Mono.Xml.XPath2.XQueryCommandImpl) which resides in System.Xml.dll via
411 Currently we are not implementing MS.Internal.Xml.* classes. MS
412 implementation is based on an old version of the W3C specification, and
413 our implementation is currently based on
414 <a href="http://www.w3.org/TR/2004/WD-xquery-20040723/">23 July 2004
415 version</a> (latest as of now) of the working draft.
417 XQuery implementation tasks are:
420 * XQuery syntax parser that parses xquery string to AST
421 (abstract syntax tree). -> partly not done.
423 * XQuery AST compiler into static context -> partly not done.
425 * XQuery (dynamic context) runtime = XQuery expression evaluator
426 + sequence iterator. -> partly not done.
428 * XPathItem data model and (mainly) conversion support.
431 * Applied expression classes for XQuery/XPath 2.0 functions and
432 operators. -> partly done.
434 * Optimization, and design per-query assembly code generator (later)
437 It already handles some queries, while major part implementation is missing
438 or buggy (like FLWOR, expressions for sequence type handling, built-in
439 function support etc.).
442 *** Relax NG and DSDL in Mono 1.2
444 Currently we support only RELAX NG as one part of ISO DSDL effort. There
445 is existing Schematron implementation (NMatrix Project: <a
446 href="http://sourceforge.net/projects/dotnetopensrc/">
447 http://sourceforge.net/projects/dotnetopensrc/</a>). With a few changes,
448 it can be used with mono.
450 We don't have multi-language based validation support, namely
451 Namespace-based Validation Dispatch Language (NVDL). To support unwrapping,
452 one special XmlReader implementation is required (other schema validation
453 support can be done by ReadSubtree()). Note that we had seen RELAX
454 Namespace, Modular Namespace (MNS) and Namespace Routing Language (NRL)
455 - that is, standardization effort is still ongoing (though NVDL looks
456 mostly the same as NRL).
458 In Mono 2.0, there are some improvements:
461 * RelaxngPattern.Compile() now provides error location.
463 * RelaxngValidatingReader now supports "expected label
464 collector" API; You can get name list of expected element
465 names and attribute names by simulating validation.
467 In Mono 2.0, there might be improvements on Commons.Xml.Relaxng.
470 * The type of error should be kind of RelaxngGrammarException.
472 * Right now there is no ambiguity detection implementation that
473 would be useful for RelaxngPattern based xml serialization (if
476 * Because of lack of ambiguity detection, there is no way to
477 provide XmlMapping (XmlTypeMapping/XmlMemberMapping). But
478 If anyone is interested in such effort, integration with
479 XmlSerializer would be interesting task.
487 See <a href="ado-net.html">ADO.NET page</a>.
489 Note that xsd.exe does not support XmlSchemaInference in System.Xml 2.0.
493 genxs.exe is a custom XmlSerializer code generator. This is Mono exclusive
495 href="http://primates.ximian.com/~lluis/blog/archives/000120.html">Lluis's
496 description</a> and manpages for details. Code files are in mcs/tools/genxs.
500 sgen.exe is an alternative XmlSerializer code generator which is based on
501 XmlSerializer.GenerateSerializer() written by Lluis. Code files are in
506 It is a tiny tool that enables conversion from DTD structure to XML Schema.
507 You need an XML instance, not DTD file itself (since basic XmlTextReader has
508 no feature to read external DTD resource itself). It runs only under mono.
512 *** Mutual assembly dependency
514 Sometimes I hear complain about System.dll and System.Xml.dll mutual
515 dependency: System.dll references to System.Xml.dll (e.g.
516 System.Configuration.ConfigXmlDocument extended from XmlDocument), while
517 System.Xml.dll vice versa (e.g. XmlUrlResolver.ResolveUri takes System.Uri).
518 Since they are in public method signatures, so at least we cannot get rid
519 of these mutual references.
521 Nowadays System.Xml.dll is built using incomplete System.dll (lacking
522 System.Xml dependent classes such as ConfigXmlDocument). Full System.dll
523 is built after System.Xml.dll is done.
525 Note that you still need System.dll to run mcs.
528 Atsushi Eno <atsushi@ximian.com>
529 last updated 12/16/2004