XML + Compare Nodes In XSLT Stylesheet

Here should go questions about transforming XML with XSLT and FOP.
tready29483
Posts: 1
Joined: Mon Sep 03, 2007 8:13 pm

XML + Compare Nodes In XSLT Stylesheet

Post by tready29483 »

Okay,

Very simple for some of you I'm sure. I want to compare to node values and if they don't match apply a class from my style sheet. I know how to apply the css class, but what I can't do is compare the nodes. Can anyone help me with that. Below is sample data:

In this sample I want to test and see if MentorQty = EBOMQty.

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<BOMResolutionReport>
<ComponentList>
<Component>
<Line>
<MentorFindNumber>106</MentorFindNumber>
<MentorQty>1.0</MentorQty>
<MentorComponentName>A-0000200-01</MentorComponentName>
<EBOMFindNumber>106</EBOMFindNumber>
<EBOMQty>1.0</EBOMQty>
<EBOMComponentName>A-0000200-01</EBOMComponentName>
<EBOMDescription>Test Part for Master Mapping</EBOMDescription>
<FormPer>the form per</FormPer>
<SeeView>the note</SeeView>
<SeeNote>the view</SeeNote>
<Caution>this is the caution</Caution>
<Status>Full Match</Status>
<MappingUsed>Master</MappingUsed>
</Line>

</Component>
</BOMResolutionReport>
Can anyone help me with this?? Thanks a bunch if you can.[/code]
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Something like below for instance:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="Line">
<xsl:if test="not(MentorQty=EBOMQty)">
...they don't match apply a class from my style sheet...
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Regards,
George
George Cristian Bina
Post Reply