|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] comparing two nodes
I have everything working, but it seems there is probably an easier way to
do it.
Here is my xml: <?xml version="1.0" encoding="UTF-8"?>
<REPORT>
<ENTRY>
<CHECKENTRY id = '1'>
<CHECK>
<AMOUNT>10.00</AMOUNT>
<ROUTING>
<NAME>Name</NAME>
<ADDRESS1>Address 1</ADDRESS1>
</ROUTING>
</CHECK>
</CHECKENTRY>
<CHECKENTRY id = '2'>
<CHECK>
<AMOUNT>9.00</AMOUNT>
<ROUTING>
<NAME>Changed Name</NAME>
<ADDRESS1>Address 1</ADDRESS1>
</ROUTING>
</CHECK>
</CHECKENTRY>
</ENTRY>
</REPORT>And the stylesheet: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/REPORT"> <xsl:for-each select="ENTRY"> <xsl:if test="CHECKENTRY[@id='1']/CHECK/AMT != CHECKENTRY[@id='2']/CHECK/AMOUNT"> <xsl:value-of select="CHECKENTRY[@id='1']/CHECK/AMOUNT"/> <xsl:value-of select="CHECKENTRY[@id='2']/CHECK/AMOUNT"/> </xsl:if> <xsl:if test="CHECKENTRY[@id='1']/CHECK/ROUTING/NAME != CHECKENTRY[@id='2']/CHECK/ROUTING/NAME"> <xsl:value-of select="CHECKENTRY[@id='1']/CHECK/ROUTING/NAME"/> <xsl:value-of select="CHECKENTRY[@id='2']/CHECK/ROUTING/NAME"/> </xsl:if> <xsl:if test="CHECKENTRY[@id='1']/CHECK/ROUTING/ADDRESS1 != CHECKENTRY[@id='2']/CHECK/ROUTING/ADDRESS1"> <xsl:value-of select="CHECKENTRY[@id='1']/CHECK/ROUTING/ADDRESS1"/> <xsl:value-of select="CHECKENTRY[@id='2']/CHECK/ROUTING/ADDRESS1"/> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> In the real world scenario, each <CHECK> will have many children (nested at different levels) that I need to compare values on. Right now the stylesheet compares each tag and if they are not equal outputs the value. Is there a way to not have to specify each element name and just run through all of them? I have control over both the stylesheet and xml. Thanks for the help. Danny Gallagher
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








