Re: [xsl] Multiple Filtering of rows based on attributes values

Subject: Re: [xsl] Multiple Filtering of rows based on attributes values
From: Jagdishwar B <jagdishwar.beemanati@xxxxxxxxx>
Date: Fri, 15 May 2009 18:49:03 +0530
Hi Kamlesh,

can you try below xslt:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
	<xsl:output indent="yes" method="xml" encoding="UTF-8"
omit-xml-declaration="yes"/>
	<xsl:template match="/">
		<SQLXMLExport>
			<xsl:apply-templates/>
		</SQLXMLExport>
	</xsl:template>
	<xsl:template match="Rows">
		<Rows>
			<xsl:apply-templates select="Row"/>
		</Rows>
	</xsl:template>
	<xsl:template match="Row">
		<xsl:copy-of select="."/>
		<xsl:if test="./Field[@alias='ITEM_CODE']='PENEMR'">
			<xsl:variable name="ProdDeptId" select="./Field[@alias='PROD_DEPT_ID']"/>
			<xsl:variable name="numberOfArtpays"
select="count(/Rows/Row[./Field[@alias='ITEM_CODE']='ARTPAY' and
./Field[@alias='PROD_DEPT_ID']=$ProdDeptId])"/>
			<xsl:choose>
				<xsl:when test="$numberOfArtpays=0">
				<xsl:comment>Inserting new Row element</xsl:comment>
					<Row>
						<Field alias="ITEM_CODE">ARTPAY</Field>
						<Field alias="PENSIONALBE">N</Field>
						<Field alias="PROD_DEPT_ID">
							<xsl:value-of select="$ProdDeptId"/>
						</Field>
					</Row>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

-- 

Jagdishwar B.

Current Thread