1

I m trying to compile an xsl using transformer factory, but it is constantly giving the exception :

XSL : `

<xsl:output method="xml" indent="yes" encoding="utf-8"
    omit-xml-declaration="no" />
<xsl:template match="@* | node()">
    <xsl:copy-of>
        <xsl:apply-templates select="@* | node()" />
    </xsl:copy-of>
</xsl:template>
<xsl:template match="value">
    <xsl:element name="value">
        <xsl:text>-1</xsl:text>
    </xsl:element>
</xsl:template>
<xsl:template match="time">
    <xsl:element name="time">
        <xsl:text>00:00:00</xsl:text>
    </xsl:element>
</xsl:template>

`

Code :

String xslPath = "C:\\Users\\Vaibhav_Ajmera\\Desktop\\vaib\\";
String findxsl = "find_replace.xsl";
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource    (xslPath + findxsl));

I am constantly getting an exception : `

ERROR:  'Syntax error in ''.'
FATAL ERROR:  'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates    (TransformerFactoryImpl.java:843)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer    (TransformerFactoryImpl.java:632)
    at com.bt.rtsm.processor.merger.MetricReset.transformXml(MetricReset.java:92)
    at com.bt.rtsm.processor.merger.MetricReset.metricReset(MetricReset.java:51)
    at com.bt.rtsm.processor.merger.MetricReset.main(MetricReset.java:194)

`

Can someone please help ? I guess something to do it xsl syntax but not able to understand what is wrong.

1 Answer 1

1

Replace

<xsl:template match="@* | node()">
    <xsl:copy-of>
        <xsl:apply-templates select="@* | node()" />
    </xsl:copy-of>
</xsl:template>

with

<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()" />
    </xsl:copy>
</xsl:template>
Sign up to request clarification or add additional context in comments.

1 Comment

THanks. Just now got it solved after reading thru couple of online articles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.