Saxon transformation via Ant: how to pass sourceParserClass
Posted: Fri Oct 04, 2013 11:03 am
Hi,
I'm trying to set up an Ant transformation scenario in Oxygen 15.0, invoking Saxon via the XSLT Ant task. I've succesfully figured out how to pass on XML catalog files so Saxon can locate the DTD and entity files independent of the exact location of the XML source files that are being transformed. Yet, when the XSLT stylesheet loads documents via the collection() function, the process exits with errors because DTD and entity files that are referenced in the XML files which are loaded via the collection() function are not found.
From the Saxon documentation at <http://www.saxonica.com/documentation/s ... alogs.html> I've understood that specific options should be passed to Saxon in order to make doc() and collection() honour catalog files. Indeed, following direct command line call to Saxon works:
Yet, I'm struggling to pass these parameters to my Ant build file. I've looked up the corresponding Saxon configuration field names (<http://saxonica.com/documentation/confi ... tures.html>) to be passed on as <attribute> arguments in the XSLT Ant task, but it doesn't seem to work. This is how far I got:
Yet, the process exits with a notification:
...and errors about unfound entity files (note: not about the DTD files), for which Saxon clearly uses the paths inside the source documents, rather than those in the catalog.xml file. I don't know if the CatalogManager.properties error points to a classpath issue, but the required resolver.jar file is included in the list of libraries passed within Oxygen to the Ant call:
Could anyone point me in the good direction to make Saxon honour the catalog information for collection() function calls?
Any help much appreciated!
Ron
I'm trying to set up an Ant transformation scenario in Oxygen 15.0, invoking Saxon via the XSLT Ant task. I've succesfully figured out how to pass on XML catalog files so Saxon can locate the DTD and entity files independent of the exact location of the XML source files that are being transformed. Yet, when the XSLT stylesheet loads documents via the collection() function, the process exits with errors because DTD and entity files that are referenced in the XML files which are loaded via the collection() function are not found.
From the Saxon documentation at <http://www.saxonica.com/documentation/s ... alogs.html> I've understood that specific options should be passed to Saxon in order to make doc() and collection() honour catalog files. Indeed, following direct command line call to Saxon works:
Code: Select all
java -cp %SAXON_HOME%/saxon9.jar;resolver-1.2.jar \
-Dxml.catalog.files=catalog.xml net.sf.saxon.Transform \
-r org.apache.xml.resolver.tools.CatalogResolver \
-x org.apache.xml.resolver.tools.ResolvingXMLReader
-it main stylesheet.xsl
Code: Select all
<target name="convert-folder">
<xslt force="yes" style="${pd}/stylesheet.xsl" in="${pd}/input.xml" out="${outputFile}">
<xmlcatalog>
<catalogpath>
<pathelement location="${pd}/catalog.xml"/>
</catalogpath>
</xmlcatalog>
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute name="http://saxon.sf.net/feature/initialTemplate" value="main"/>
<!-- see http://saxonica.com/documentation/configuration/config-features.html -->
<attribute name="http://saxon.sf.net/feature/uriResolverClass" value="org.apache.xml.resolver.tools.CatalogResolver"/>
<attribute name="http://saxon.sf.net/feature/sourceParserClass" value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
</factory>
<classpath location="${oxygenlib}/saxon9ee.jar"/>
</xslt>
</target>
Code: Select all
[xslt] Cannot find CatalogManager.properties
Code: Select all
<field name="extensionURLs">
<String-array>
<String>${oxygenHome}/classes/</String>
<String>${oxygenHome}/lib/oxygen.jar</String>
<String>${oxygenHome}/lib/oxygenAuthor.jar</String>
<String>${oxygenHome}/lib/oxygenDeveloper.jar</String>
<String>${oxygenHome}/lib/oxygenEclipse.jar</String>
<String>${oxygenHome}/lib/oxygenAuthorEclipse.jar</String>
<String>${oxygenHome}/lib/oxygenDeveloperEclipse.jar</String>
<String>${oxygenHome}/lib/resolver.jar</String>
<String>${oxygenHome}/lib/xercesImpl.jar</String>
<String>${oxygenHome}/lib/saxon9ee.jar</String>
<String>${oxygenHome}/lib/saxon.jar</String>
<String>${oxygenHome}/lib/xml-apis-ext.jar</String>
<String>${oxygenHome}/lib/log4j.jar</String>
</String-array>
</field>
Any help much appreciated!
Ron