Reputation: 765
I have an XSL as shown
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" standalone="no" indent="yes"/>
<xsl:param name="V9_XML_PATH" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="measSchedule">
<xsl:variable name="match" select="/schedule/scheduleItem[measurements/measurement=document($V9_XML_PATH)/schedule/scheduleItem/measurements/measurement]"/>
<xsl:choose>
<xsl:when test="$match">
<xsl:copy-of select="$match"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I am using this to find the common records in 2 XML files whose records are in below format:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schedule>
<scheduleItem scheduleId="1" startDate="2013-01-01" stopDate="2037-12-31">
<measurements>
<measurement>ADM010000</measurement>
</measurements>
<measPeriods>
<period day="0" duration="0" hour="0" interval="15" minutes="0"/>
</measPeriods>
</scheduleItem>
<!-- scheduleItem repeated n times -->
</schedule>
Here based on field /schedule/scheduleItem/measurements/measurement
I am taking the intersection of 2 files.
But the problem is, when I am executing this in unix as:
xsltproc --stringparam V9_XML_PATH "/root/some/path/v9.xml" xsl.xslt v10.xml
its giving correct output, but when I started using this in my Java Program, I am getting exception java.lang.VerifyError
java.lang.VerifyError: (class: GregorSamsa$0, method: test signature: (IIIILcom/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet;Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;)Z) Incompatible type for getting or setting field
at GregorSamsa.template$dot$1()
at GregorSamsa.applyTemplates()
at GregorSamsa.applyTemplates()
at GregorSamsa.transform()
at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.project.net.converter.XMLConverter.convert(XMLConverter.java:122)
Upvotes: 0
Views: 667
Reputation: 32980
Your stylesheet is obviously correct.
When you use Java to run the transformation, it uses XSLTC, the XSLT engine bundled with the JDK. XSLTC parses your stylesheet and dynamically generates Java byte code which is then loaded and run to execute the transformation.
But somehow the generated XSLTC byte code is rejected by the Java VM, as indicated by the java.lang.VerifyError.
Therefore either XSLTC has a bug (option 1: likely), or the byte code verifier of your Java version rejects valid byte code (option 2: unlikely).
You could try to run your Java program with this JVM parameter :
java -Xverify:none ...
to turn of the byte code verifier. If it succeeds then option 2 is true.
Or you could try to use a different Java XSLT engine. For instance try Saxon; you probably only need to add the saxon jar to the classpath and your calling code should work without changes since you use the java.xml.transform interfaces. If this succeeds then option 1 was true.
Upvotes: 2
Reputation: 2327
This is most likely a classpath error. Check that you do not have several JAR files or directories with class files providing several times the same classes.
Upvotes: 0