This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Conditional processing by matching elements
- From: Oleg Tkachenko <olegt at multiconn dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 26 Dec 2001 19:16:55 +0200
- Subject: Re: [xsl] Conditional processing by matching elements
- Organization: Multiconn International
- References: <53FEA05B1DD1D411AF8C0060B0679CE136BAB5@msgmro539nts.fmr.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
--
Oleg Tkachenko
Multiconn International, Israel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list