Re: [xsl] Conditional processing by matching elements

Subject: Re: [xsl] Conditional processing by matching elements
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Wed, 26 Dec 2001 19:16:55 +0200
Haque, Suraiya wrote:

I'm trying to match SERVICED from the SecondStruct structure with that of
the FirstStruct structure and print out messageOne if the SERVSTAT="Y". If
there is no matching SERVICEID in FirstStruct, print out messageTwo. For
example, my output could look like this:


So, process Rows in SecondStruct and for every one check out appropriate status field in FirstStructure, imo it's work for keys. Try this one:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> <xsl:key name="kStat" match="Structure[@StructId='FirstStruct']/Row" use="@SERVICEID"/> <xsl:template match="root"> <xsl:apply-templates/> </xsl:template> <xsl:template match="Structure"/> <xsl:template match="Structure[@StructId='SecondStruct']"> <xsl:apply-templates/> </xsl:template> <xsl:template match="Row"> <xsl:value-of select="@SERVICEID"/> <xsl:text> </xsl:text> <xsl:choose> <xsl:when test="key('kStat', @SERVICEID)/@SERVSTAT = 'Y'">On</xsl:when> <xsl:otherwise>Off</xsl:otherwise> </xsl:choose> <xsl:text>&#xD;</xsl:text> </xsl:template> </xsl:stylesheet>

--
Oleg Tkachenko
Multiconn International, Israel


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread