Usage of Xslt30Transformer class
The Saxon XSLT and XQuery processor, developed by Saxonica
Brought to you by:
mhkay
Hi,
I have been using saxon9he older version for valdiating my XML files.
I downloaded the latest SaxonHE 9.6.0.7. I was struggling to make my existing code use Xslt30Transformer class for transformation instead of its old counterpart XsltTransformer.
Is it possible for you to share some sample code snippet to show how to use Xslt30Transformer for validating an XML file using a XSLT file.
Appreciate your help.
Regards
Anonymous
You might find some of our test cases helpful, see attached.
In future, we're not using SourceForge for support any more. Please use http://saxonica.plan.io
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014 Saxonica Limited.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package s9apitest;
import jaxptest.ConfigTest;
import junit.framework.TestCase;
import net.sf.saxon.Configuration;
import net.sf.saxon.functions.AccessorFn;
import net.sf.saxon.lib.FeatureKeys;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.option.jdom.JDOMNodeWrapper;
import net.sf.saxon.option.jdom.JDOMObjectModel;
import net.sf.saxon.option.jdom2.JDOM2ObjectModel;
import net.sf.saxon.option.xom.XOMDocumentWrapper;
import net.sf.saxon.option.xom.XOMObjectModel;
import net.sf.saxon.s9api.*;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.type.ComplexType;
import net.sf.saxon.type.SchemaException;
import net.sf.saxon.type.SchemaType;
import net.sf.saxon.value.Cardinality;
import net.sf.saxon.value.QNameValue;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import java.io.;
import java.util.;
/
* JUnit tests for the s9api Xslt30Transformer
* @author Michael Kay
* @date March 2015
/
public class TestXslt30Transformer extends TestCase {
}
View and moderate all "support-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Support Requests"
Thanks a lot Michael. Much appreciated.
Can I ask you one more question. Is it possible to provide more than one XML files and getting it transformed with single XSL file?
If yes how to do that?
Also is XsltTransformer.Run() similar to Xslt30Transformer.applyTemplates() method.
Thanks for all your help in advance.
Regards
There are many ways you can process multiple documents in a single transformation. You can read them using the collection() function, perhaps with your own CollectionURIResolver; you can read them individually using the doc() or document() functions; you can pass them as stylesheet parameters. In XSLT 3.0 (and with the Xslt30Transformer) you can even pass a sequence of documents (as an XdmValue) to the method applyTemplates (XdmValue, Destination) - though this isn't as useful as it appears because you can then only process the documents individually and independently, you can't combine them in any way.