xsl-list
[Top] [All Lists]

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

2009-05-15 09:19:36
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[(_at_)alias='ITEM_CODE']='PENEMR'">
                        <xsl:variable name="ProdDeptId" 
select="./Field[(_at_)alias='PROD_DEPT_ID']"/>
                        <xsl:variable name="numberOfArtpays"
select="count(/Rows/Row[./Field[(_at_)alias='ITEM_CODE']='ARTPAY' and
./Field[(_at_)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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>