From: Brian Newman <brian.newman@ns...> - 2009-12-24 15:13:53
Sorry to be such a pest, you've been very helpful and patient, but I've still got a lot more questions.
On http://www.saxonica.com/documentation/dotnet/dotnetapi.html, the instructions are to use DocumentBuilder as part of the transform process. But on http://www.saxonica.com/documentation/dotnetdoc/index.html, it suggests that the appropriate way to do a transform is (new Processor()).NewXsltCompiler().Compile(transformfile).Load();
Is the second way required for compiling the transform and the first way for not compiling the transform?
Also, http://www.saxonica.com/documentation/extensibility/uri-resolver.html references JAXP for building a URIResolver, but what about if you're using the .NET version of Saxon? I understand it's possible to create a System.Xml.XmlResolver if I use the DocumentBuilder approach, but how do I add a URIResolver if I want to precompile the transform (which, I assume, requires the NewXsltCompiler approach)?
From: Michael Kay <mike@sa...> - 2009-12-28 00:44:50
The documentation on that page says that the XdmNode produced by a
DocumentBuilder "might also contain a stylesheet or a schema which can then
be used as input to the XsltCompiler or the SchemaManager." I'm not quite
sure how you read this as instructing you to do it this way: there are cases
when it's useful, but it's not normally necessary. If the source is in a
file then the simplest way to supply the stylesheet is by calling the
Compile method supplying the file directly. The DocumentBuilder is usually
used only for source documents (i.e. the transformation input).
> Is the second way required for compiling the transform and
> the first way for not compiling the transform?
No, the XsltTransform object that is produced is the same either way.
er.html references JAXP for building a URIResolver, but what > about if
you're using the .NET version of Saxon? I
> understand it's possible to create a System.Xml.XmlResolver
> if I use the DocumentBuilder approach, but how do I add a
> URIResolver if I want to precompile the transform (which, I
> assume, requires the NewXsltCompiler approach)?
The information on the cited page is Java-specific. The XmlResolver on .NET
works in much the same way, except that the same resolver object can be used
at both the XML parsing and XSLT transformation levels.
The XsltCompiler object has an XmlResolver property. This can be used to set
an XmlResolver which will be used to resolve URI references occurring in
xsl:include and xsl:import declarations. This is used regardless of which
overload of the Compile() method you use.