XML Parsing in .NET
When you run Saxon on the .NET platform, there are two XML parsers available: the System.Xml
parser
supplied with the .NET platform, and the Xerces Apache parser, which is supplied
as part of the Saxon product.
Saxon generally uses the Xerces parser by preference. However, you can force Saxon
to use the OpenJDK parser by calling processor.SetProperty("http://saxon.sf.net/feature/preferJaxpParser", "false")
.
Or from the command line, set the option --preferJaxpParser:off
.
Note that the Microsoft parser does not notify ID or IDREF values from the DTD, or expand attributes with
fixed or default values, unless DTD validation is requested. This can be requested using the -v option on the
command line, or via the API. (See the DtdValidation
property of the DocumentBuilder
class)
Unparsed entities are not notified to Saxon by the Microsoft parser.
The XSLT functions unparsed-entity-system-id()
and unparsed-entity-public-id()
will therefore not work.
Support for OASIS catalogs is provided at the command-line level by means of the command-line option
-catalog:filename
. To enable this to work, the Apache catalog resolver is integrated in the Saxon DLL.
This works only with the JAXP (Xerces) parser.
To use catalogs when running an application using the Saxon API, the interface is not quite so convenient.
Call the static method net.sf.saxon.trans.XmlCatalogResolver.setCatalog()
(found in saxon9he.dll
)
with three arguments: the filename of the catalog file, the Saxon Configuration object,
and a boolean indicating whether tracing is required.