[xsl] node comparision for equality

Subject: [xsl] node comparision for equality
From: "uppaluri satyaprasad" <uppaluris@xxxxxxxxxxx>
Date: Tue, 13 Jun 2006 18:08:19 -0400
Hi,
I have a requirement to process xml document based following conditions
1. loop throw the document for each record.
2. process the record based on BPPLCode.
I have to produce one line of output for each BPPLCode with in Record node.
So in this example I will normally get three rows of output data (flat file output)
however i need to also test if
BusPartnerCodeValue (i.e. D06001 here) and BusPartnerCodeTypeCode (i.e. 00003) are equal in two nodes within BPPLCode.
if these two values are equal, the BPPLCode nodes are equal and i shall process only one node.
we can ignore ProductLevel/ProductLevelCode here.
i.e. here in this eaxple BPPLCode[1] and BPPLCode[2] nodes are identical as per business rules.
(neverthless to say that BPPLCode can occur 0 to many times as per schema.)


I have to produce only two rows of output data in this case
(one row for BPPLCode[1] and BPPLCode[2] as these two are treated identical) and one row for BPPLCode[3]



Environment: I am doing the processing using java and saxon8 API (and XSLT-2) I have the flexibility of using any extension if needed so.


my xml looks like this


	<message>
		   <records>
			<record>
			<BPPLCode>
				<ProductLevel>
					<ProductLevelCode>00001</ProductLevelCode>
				</ProductLevel>
				<BusPartnerCodeType>
					<BusPartnerCodeTypeCode>00003</BusPartnerCodeTypeCode>
				</BusPartnerCodeType>
				<BusPartnerCodeValue>D06001</BusPartnerCodeValue>
			</BPPLCode>
			<BPPLCode>
				<ProductLevel>
					<ProductLevelCode>00003</ProductLevelCode>
				</ProductLevel>
				<BusPartnerCodeType>
					<BusPartnerCodeTypeCode>00003</BusPartnerCodeTypeCode>
				</BusPartnerCodeType>
				<BusPartnerCodeValue>D06001</BusPartnerCodeValue>
			</BPPLCode>

<BPPLCode>
<ProductLevel>
<ProductLevelCode>00001</ProductLevelCode>
</ProductLevel>
<BusPartnerCodeType>
<BusPartnerCodeTypeCode>00002</BusPartnerCodeTypeCode>
</BusPartnerCodeType>
<BusPartnerCodeValue>001</BusPartnerCodeValue>
</BPPLCode>


			</record>
		   </records>
		</message>

My xsl looks like this
   <xsl:template match="/">
       <xsl:for-each select="BusPartnerMsg/Records/Record">

<!-- i am not sure how to test the equality here -->
<xsl:if test="(BPPLCode/BusPartnerCodeValue = BPPLCode/BusPartnerCodeValue)
and BPPLCode/BusPartnerCodeType/BusPartnerCodeTypeCode=BPPLCode/BusPartnerCodeType/BusPartnerCodeTypeCode ">
TRUE
</xsl:if>



<!-- Create one record each based on BusPartnerCodeTypeCode -->
<xsl:for-each select="BPPLCode">


<!-- writing of record goes here -->


my out put looks like this currently.


however it shall product only two rows. one of the first two rows is redundent as per the business rules

C55 D06MULTIPAC MONTAGE U. VERPACKUNG199034300MULTIPAC MONTAGE U. VERPACKUNG13 MULTIPAC MONTAGE U. VERPACKUNGMONTAGE U. VERPACKUNG GMBH ALFRED-KRUPP-STR. 8 73479 ELLWANGEN , BADEN-W\RTTEM004A92002N MDMIB 20060531173239631108773204555
C55 D06MULTIPAC MONTAGE U. VERPACKUNG399034300MULTIPAC MONTAGE U. VERPACKUNG13 MULTIPAC MONTAGE U. VERPACKUNGMONTAGE U. VERPACKUNG GMBH ALFRED-KRUPP-STR. 8 73479 ELLWANGEN , BADEN-W\RTTEM004A92002N MDMIB 20060531173239158751061651645
C55 647MINSON SPORTING GOODS LTD. 199023888MINSON SPORTING GOODS LIMITED 13 MINSON SPORTING GOODS LIMITED C/O MINSON ENTER.CO.,LTD.10F, N.145,SECTION2,MING-SHENG E.RD TAIPEI 736420802N MDMIB 20060531173239927290352273956



I am sure this may easy for you guys but i am struct up here. some sugested using keys but i amnot sure if that shall be the case.


thanks for the help Satya

Current Thread