I want to match the nodes *inside* the <selection> node against the
nodes *inside* the original node.
deep-equal(selection/node(),$original/node())
Alright, that sounds logical. I assume that in this case $original is a
variable that refers to the <original> element in the input XML file?
I constantly get an error like this when trying to use the deep-equal
function:
[error]
ERROR: 'Error checking type of the expression 'funcall(deep-equal,
[ParentLocationPath(ParentLocationPath(step("child", 14), step("child",
15)), step("child", -1)),
ParentLocationPath(ParentLocationPath(step("child", 14), step("child",
15)), step("child", -1))])'.'
FATAL ERROR: 'Could not compile stylesheet'
Error creating transformer
javax.xml.transform.TransformerConfigurationException: Could not compile
stylesheet
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:613)
at Main.getTransformer(Main.java:128)
at Main.compare(Main.java:70)
at Main.<init>(Main.java:44)
at Main.main(Main.java:53)
------------------------------------
Parsing body[<compare><selection><z color="blue"
flavor="vanilla">testje</z></selection><original><e><x color="red"
flavor="chocolate">testje 2</x><z color="blue"
flavor="vanilla">testje</z></e></original></compare>]
Exception in thread "main" java.lang.NullPointerException
at Main.compare(Main.java:79)
at Main.<init>(Main.java:44)
at Main.main(Main.java:53)
[/error]
This is my stylesheet:
[stylesheet]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="deep-equal(compare/selection/node(),
compare/selection/node())">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
[/stylesheet]
As you can see I am trying to compare the node inside the selection
element to itself, just to check if everything is working.
This is the input:
[input]
<compare>
<selection>
<z color="blue" flavor="vanilla">testje</z>
</selection>
<original>
<e>
<x color="red" flavor="chocolate">testje 2</x>
<z color="blue" flavor="vanilla">testje</z>
</e>
</original>
</compare>
[/input]
--
Best regards,
Jethro Borsje
http://www.jborsje.nl