[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: comparing a part of the XML tree

Subject: RE: comparing a part of the XML tree
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 16 Jul 2007 09:50:44 +0100
RE:  comparing a part of the XML tree
deep-equal() is an XSLT 2.0 / XPath 2.0 function, you're trying to use it
with Xalan which only implements 1.0.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Jethro Borsje [mailto:jethro@xxxxxxxxxxxx] 
> Sent: 16 July 2007 09:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  comparing a part of the XML tree
> 
> >> 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.TransformerFactor
> yImpl.newTemplates(TransformerFactoryImpl.java:824)
> 	at
> com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactor
> yImpl.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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.