<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html> <head> <this-is section="using-xsl" page="embedding" subpage="jaxp-transformation"/> <!-- Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Using JAXP for Transformations</title> <meta name="coverage" content="Worldwide"/> <meta name="copyright" content="Copyright Saxonica Ltd"/> <meta name="title" content="Saxonica: XSLT and XQuery Processing: Using JAXP for Transformations"/> <meta name="robots" content="noindex,nofollow"/> <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/> </head> <body class="main"> <h1>Using JAXP for Transformations</h1> <p>This API is described in the documentation provided with JDK 1.5 and later. It is available online at <a href="http://download.oracle.com/javase/6/docs/api/" class="bodylink">http://download.oracle.com/javase/6/docs/api/</a> Look for the <a href="http://download.oracle.com/javase/6/docs/api/javax/xml/transform/package-summary.html" class="bodylink">javax.xml.transform</a> package.</p> <p>More information and examples relating to the JAXP transformation API can be found in the <b>TraxExamples.java</b> example application found in the samples directory.</p> <p>The class name for the JAXP <code>TransformerFactory</code> depends on which Saxon edition you are using:</p> <ul> <li> <p><b>Saxon-HE:</b> <a class="bodylink" href="../../javadoc/net/sf/saxon/TransformerFactoryImpl.html"><code>net.sf.saxon.TransformerFactoryImpl</code></a></p> </li> <li> <p><b>Saxon-PE:</b> <a class="bodylink" href="../../javadoc/com/saxonica/config/ProfessionalTransformerFactory.html"><code>com.saxonica.config.ProfessionalTransformerFactory</code></a></p> </li> <li> <p><b>Saxon-EE:</b> <a class="bodylink" href="../../javadoc/com/saxonica/config/EnterpriseTransformerFactory.html"><code>com.saxonica.config.EnterpriseTransformerFactory</code></a></p> </li> </ul> <p>Note that as an alternative to using <code>TransformerFactory.newInstance()</code> to find Saxon dynamically on the class path, it is possible (and much faster, and more robust) to instantiate the Saxon <code>TransformerFactory</code> directly, by a call such as <code>TransformerFactory factory = new com.saxonica.config.ProfessionalTransformerFactory()</code></p> <p>The types of object that can be supplied as stylesheet parameters are not defined in the JAXP specification: they are implementation-dependent. Saxon takes the Java object supplied, and converts it to an XPath value using the same rules as it applies for the return value from a Java extension function: for these rules, see <a class="bodylink" href="../../extensibility/function-result.xml">Saxon Extensibility</a>. If the resulting value is an atomic value, it is cast to the required type of the parameter as specified in the <code>xsl:param</code> declaration, using the XPath casting rules. If the value is non-atomic (for example, if it is a node, or a sequence of integers), then no conversion is attempted, instead, the value must match the required type as stated.</p> <p>The JAXP <code>TransformerFactory</code> interface provides a configuration method <code>setAttribute()</code> for setting implementation-defined configuration parameters. The parameters supported by Saxon have names defined by constants in the class <code>net.sf.saxon.FeatureKeys</code>. The names of these properties and their meanings, are described in <a class="bodylink" href="../../configuration/config-features.xml">Configuration Features</a>.</p> <p>Where the required value of a property is a Boolean, the supplied value may be either a <code>java.lang.Boolean</code>, or a String holding the values "true" or "false" (also accepted are "on"|"off", "1"|"0", or "yes"|"no"). The returned value of the property, however, will be a <code>Boolean</code>.</p> <p>Saxon's implementation of the JAXP <code>Transformer</code> interface is the class <a class="bodylink" href="../../javadoc/net/sf/saxon/Controller.html"><code>net.sf.saxon.Controller</code></a>. This provides a number of options beyond those available in the standard JAXP interface, for example the ability to set an output URI resolver for secondary output documents, and a method to set the initial mode before the transformation starts. You can access these methods by casting the <code>Transformer</code> to a <code>Controller</code>. The methods are described in the JavaDoc documentation supplied with the product.</p> <p>When using the JAXP interface, you can set serialization properties using a <code>java.util.Properties</code> object. The names of the core XSLT 1.0 properties, such as <code>method</code>, <code>encoding</code>, and <code>indent</code>, are defined in the JAXP class <code>javax.xml.transform.OutputKeys</code>. Additional properties, including Saxon extensions and XSLT 2.0 extensions, have names defined by constants in the class <a class="bodylink" href="../../javadoc/net/sf/saxon/lib/SaxonOutputKeys.html"><code>net.sf.saxon.lib.SaxonOutputKeys</code></a>. The values of the properties are exactly as you would specify them in the <code>xsl:output</code> declaration, except that QNames are written in Clark notation (<code>{uri}local</code>).</p> <table width="100%"> <tr> <td> <p align="right"><a class="nav" href="../performanceanalysis.xml">Next</a></p> </td> </tr> </table> </body> </html>