I have a XSLT which will split large xml file into multiple xml file with the use of following xslt code.
<xsl:variable name="filename" select="resolve-uri(concat('splitfilesfolder/',position(),'.xml'))" />
<xsl:result-document href="{$filename}" format="xml">
<--XML file content --->
</xsl:result-document>
then i have used that XSLT in my code to split input XML file using javax.xml.transform.Transformer.
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslSource = new StreamSource(xsltfilepath);
Transformer trans = tFactory.newTransformer(xslSource);
trans.transform(new StreamSource(xmlFile开发者_如何学CName), new StreamResult(splitfilesfolder));
Here i want to give same path for new Streamresult as it is in result document path how can i transform multiple xml file using result doucment and javax.xml.transform.Transform ??
Can anybody please give me a solution ?
Thanks in advance.
<xsl:result-document>
is in XSLT 2.0 javax.xml.transform does not support XSLT 2.0, so i'm under the impression that you're out of luck using built-in transformers.
Try using Saxon instead. Just add the jar file to your classpath and you're set.
There is also an error in your XSLT
<xsl:result-document href="{$filename}" format="xml">
Should be
<xsl:result-document href="{$filename}" method="xml">
To get the directory into your XSLT i'd use
Java
trans.setParameter("dir", "dirname");
XSL
<xsl:param name="dir"/>
Create an instance of Saxon's TransformerFactory directly, i.e. TransformerFactoryImpl factory = new TransformerFactoryImpl(); Do not use the brain-dead JAXP TransformerFactory.newInstance(); ...as you're clearly getting something other than Saxon's implmentation.
精彩评论