xslt document function doesn't resolve the xinclude tags in the referenced xml file

535 views Asked by At

I'm looking for a solution to resolve xincludes at documents referenced by the document() function (XSLT).

On my evalutation I tried the xsltproc (doesn't work) and now I stuck on the saxon 6.5.5 in combination with the apache xerces 2.11.0.

This is my current commandline.

java.exe  -cp lib\xercesImpl-2.7.1.jar;\lib\saxon.jar 
 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl  
 -Djavax.xml.parsers.SAXParserFactory= org.apache.xerces.jaxp.SAXParserFactoryImpl  
 -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration 
 com.icl.saxon.StyleSheet 
 -o OUTPUT.XML INPUT.XML COPY.XSLT  

Maybe I have to add some parameters or I have to use some additional libs. Thanks for your reply. BR

Markus

2

There are 2 answers

0
markus0074 On BEST ANSWER

I just added a URI Resolver at the commandline.

-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration 
 net.sf.saxon.Transform
 -x:org.apache.xml.resolver.tools.ResolvingXMLReader
 -y:org.apache.xml.resolver.tools.ResolvingXMLReader
 -r:org.apache.xml.resolver.tools.CatalogResolver   

I want to thank Mickael Kay and Dave Pawson for the help.

1
Martin Honnen On

I think Saxon 9 Java has an xi command line option which does XInclude, for instance with Saxon 9.6 HE I tried -xi -it:main -xsl:test2014112604.xsl with the stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:mf="http://example.com/mf"
    exclude-result-prefixes="xs mf"
    version="2.0">

<xsl:template name="main">
  <xsl:copy-of select="document('test2014112604.xml')"/>
</xsl:template>

</xsl:stylesheet>

and the files test2014112604.xsl as

<root>
  <include xmlns="http://www.w3.org/2001/XInclude" href="test2014112605.xml"/>
</root>

and the included as

<test>...</test>

and that way Saxon outputs

<?xml version="1.0" encoding="UTF-8"?><root>
  <test xml:base="test2014112605.xml">...</test>
</root>