Page is a not externally linkable
sotu - 8:23 pm on Jun 26, 2012 (gmt 0)
Hello,
Currently I have following XML:
<Rowsets>
<Rowset>
<Row>
<DrilldownDepth>0</DrilldownDepth>
<ScheduleWeek>---</ScheduleWeek>
<ABC>---</ABC>
<PQR>1500</PQR>
<XYZ>15000</XYZ>
<Quant>285</Quant>
</Row>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ScheduleWeek>12</ScheduleWeek>
<ABC>---</ABC>
<PQR>1500</PQR>
<XYZ>15000</XYZ>
<Quant>285</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>12</ScheduleWeek>
<ABC>SUPER</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>12</ScheduleWeek>
<ABC>Duper</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>12</ScheduleWeek>
<ABC>Fun</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>7</ScheduleWeek>
<ABC>SUPER</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>7</ScheduleWeek>
<ABC>Duper</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
<Row>
<DrilldownDepth>2</DrilldownDepth>
<ScheduleWeek>8</ScheduleWeek>
<ABC>SUPER</ABC>
<PQR>100</PQR>
<XYZ>200</XYZ>
<Quant>300</Quant>
</Row>
</Rowset>
</Rowsets>
Now I need only those <Row> where <DrilldownDepth>2</DrilldownDepth> and <ScheduleWeek>12</ScheduleWeek>.
So I have written following XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java" version="1.0">
<xsl:output media-type="text/xml" method="xml"/>
<xsl:variable name="depth">2</xsl:variable>
<xsl:variable name="week">12</xsl:variable>
<xsl:template match="/Rowsets">
<Rowsets>
<xsl:for-each select= "Rowset[ Row[DrilldownDepth=$depth and ScheduleWeek=$week] ]">
<xsl:copy-of select="."/>
</xsl:for-each>
</Rowsets>
</xsl:template>
</xsl:stylesheet>
But it is not giving me desired output. Can anyone help me with that?
Also the values that I am passing in XSLT 2 and 12, how can I make it dynamic to pass from outside?