<document>
<header>
<product>resin</product>
<title>JAXP - specifying XML and XSLT implementations</title>
<description>

<p>
JAXP is a standard interface which supports pluggable XML and XSL
implementations.  JAXP selects the parser based on
system properties.  You can set the properties to select
a different parser than the default one.
</p>

</description>
</header>

<body>
<summary/>

<section name="resin" title="The Resin parsers and transformers">

<deftable title="Resin XML DOM parsers">
<tr><th>JAXP property<th>Resin class
<tr><td>javax.xml.parsers.DocumentBuilderFactory
    <td>com.caucho.xml.parsers.XmlDocumentBuilderFactory
<tr><td>javax.xml.parsers.DocumentBuilderFactory
    <td>com.caucho.xml.parsers.HtmlDocumentBuilderFactory
<tr><td>javax.xml.parsers.DocumentBuilderFactory
    <td>com.caucho.xml.parsers.LooseXmlDocumentBuilderFactory
<tr><td>javax.xml.parsers.DocumentBuilderFactory
    <td>com.caucho.xml.parsers.LooseHtmlDocumentBuilderFactory
</deftable>

<deftable title="Resin XML SAX parsers">
<tr><td>javax.xml.parsers.SAXParserFactory
    <td>com.caucho.xml.parsers.XmlSAXParserFactory
<tr><td>javax.xml.parsers.SAXParserFactory
    <td>com.caucho.xml.parsers.HtmlSAXParserFactory
<tr><td>javax.xml.parsers.SAXParserFactory
    <td>com.caucho.xml.parsers.LooseXmlSAXParserFactory
<tr><td>javax.xml.parsers.SAXParserFactory
    <td>com.caucho.xml.parsers.LooseHtmlSAXParserFactory
</deftable>

<deftable title="Resin XSLT transformer">
<tr><th>JAXP property<th>Resin class
<tr><td>javax.xml.transform.TransformerFactory
    <td>com.caucho.xsl.Xsl
</deftable>
<p>
Usually Resin will use its XML parsers and fast XSLT transformer.  Sometimes
placement of certain jars in the classpath causes problems.
<var/system-property/> can be used to explicitly set the Resin XML and XSLT
implementation classes.
</p>

<example title="system-property for using Resin XML and XSLT">
&lt;!-- xml --&gt;

&lt;system-property javax.xml.parsers.DocumentBuilderFactory=
             "com.caucho.xml.parsers.XmlDocumentBuilderFactory"/&gt;
&lt;system-property javax.xml.parsers.SAXParserFactory=
             "com.caucho.xml.parsers.XmlSAXParserFactory"/&gt;

&lt;!--  xslt --&gt;

&lt;system-property javax.xml.transform.TransformerFactory=
             "com.caucho.xsl.Xsl"/&gt;

</example>
</section>

<section title="Using alternative XML and XSLT implementations">

<section title="system-property">

<p>JAXP system properties are used to specify the XML and XSLT implementations
that are used.  Resin defaults to using it's own XML parsers and fast XSLT
transformer.  Other implementations are used with the specification of the
appropriate system properties and values.</p>

<p>Examples of using <a config-tag="system-property"/> for commonly used
alternative XML parsers and XSLT transformers are in separate sections 
below.  The system property configuration tags can be placed at the 
<a config-tag="web-app"/> or the <a config-tag="server"/> level.</p>

<example title="system-property to specify xml parser for web-app">

&lt;web-app&gt;
  &lt;!-- xml --&gt;

  &lt;system-property javax.xml.parsers.DocumentBuilderFactory=
               "..."/&gt;
  &lt;system-property javax.xml.parsers.SAXParserFactory=
               "..."/&gt;

  &lt;!--  xslt --&gt;

  &lt;system-property javax.xml.transform.TransformerFactory=
               "..."/&gt;
&lt;/web-app&gt;

</example>

<example title="system-property to specify xml parser for server">

&lt;server&gt;
  &lt;!-- xml --&gt;

  &lt;system-property javax.xml.parsers.DocumentBuilderFactory=
               "..."/&gt;
  &lt;system-property javax.xml.parsers.SAXParserFactory=
               "..."/&gt;

  &lt;!-- xslt --&gt;

  &lt;system-property javax.xml.transform.TransformerFactory=
               "..."/&gt;
&lt;/server&gt;

</example>

</section>

<section title="jar file placement">

<p>Setting system properties for alternative libraries requires that the
implementation classes, usually in a .jar file, are available in the classpath.

<p>
The implementation classes are available for a single web application when the
jar file(s) are placed in <code/WEB-INF/lib/>.  Since other web-apps do not see
these libraries,  this allows you to isolate a particular version of a
particular implementation for use by the web-app.  It is not uncommon for a new
version of these jar files to introduce problems with existing code.  </p>

<p>
If the <code/system-property/> is being set at the server level, then the jar
files containing the implementation classes need to be placed in
<code/$RESIN_HOME/lib/>.   This is also a convenient location for placement if
you want to avoid putting the libraries in <code>WEB-INF/lib</code> for every
web application.  Any jars placed in <code>$RESIN_HOME/lib</code> are
avaialable for all web applications.
</p>

</section>
</section>

<section name="xerces" title="Using Xalan and Xerces">

<example title="system-property for using Xalan and Xerces">
&lt;!-- xml --&gt;

&lt;system-property javax.xml.parsers.DocumentBuilderFactory=
             "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/&gt;
&lt;system-property javax.xml.parsers.SAXParserFactory=
             "org.apache.xerces.jaxp.SAXParserFactoryImpl"/&gt;

&lt;!--  xslt --&gt;

&lt;system-property javax.xml.transform.TransformerFactory=
             "org.apache.xalan.processor.TransformerFactoryImpl"/&gt;

</example>

<p>
Cocoon users may need the following:
</p>

<example title="system-property for cocoon users using Xalan and Xerces">
&lt;system-property org.xml.sax.driver=
             "org.apache.xerces.parsers.SAXParser"/&gt;
</example>

<p>
Put your xerces and xalan jar files in <code/WEB-INF/lib/>, or to have them
available to all of your applications put them in <code/$RESIN_HOME/lib/>.
</p>

</section>

<section name="crimson" title="Using Crimson">

<p>Crimson is the xml parser that is included with JDK 1.4 and greater.</p>

<example title="system-property for using Crimson">

&lt;!-- xml --&gt;

&lt;system-property javax.xml.parsers.DocumentBuilderFactory=
             "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"/&gt;
&lt;system-property javax.xml.parsers.SAXParserFactory=
             "org.apache.crimson.jaxp.SAXParserFactoryImpl""/&gt;

</example>
</section>

</body>
</document>
