This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Conditional processing by matching elements


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]