|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem involving position() and COnditional filtering
Hi All
I am facing a issue while using position() function with conditional
filtering. My Source xml is:::
<?xml version="1.0" encoding="UTF-8"?>
<NounOutcome>
<DocumentIds>
<DocumentIdType>
<Id>Id10</Id>
<Revision>Revision11</Revision>
</DocumentIdType>
<DocumentIdType>
<Id>43</Id>
<Revision>Revision14</Revision>
</DocumentIdType>
<DocumentIdType>
<Id>Id10</Id>
<Revision>Revision11</Revision>
</DocumentIdType>
<DocumentIdType>
<Id>43</Id>
<Revision>Revision14</Revision>
</DocumentIdType>
</DocumentIds>
<NounOutcomeValue>NounOutcomeValue17</NounOutcomeValue>
<UserArea>UserArea18</UserArea>
</NounOutcome>
and the xsl is
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1" xmlns:java="http://xml.apache.org/xslt/java"
xmlns="http://www.openapplications.org/oagis"
xmlns:str="http://exslt.org/strings"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1"
indent="yes"/>
<xsl:template match="/">
<NounOutcome>
<DocumentIds>
<xsl:for-each
select="/NounOutcome/DocumentIds/DocumentIdType">
<xsl:if test="Id='43'">
<DocumentIdType>
<Id>
<xsl:value-of select="Id"/>
</Id>
<Revision>
<xsl:value-of select="position()"/>
</Revision>
</DocumentIdType>
</xsl:if>
</xsl:for-each>
</DocumentIds>
<NounOutcomeValue>
<xsl:value-of select="/NounOutcome/NounOutcomeValue"/>
</NounOutcomeValue>
<UserArea></UserArea>
</NounOutcome>
</xsl:template>
</xsl:stylesheet>
Now here in the XSL i am filtering the source DocumentIdType record based on
Id value. The problem is that the position function generates value
according to the source xml occurrences and not the actual occurrence in
output. So for two matching record I get the output value in Revision field
as 2,4 but I want 1,2.
The output generated is
<?xml version="1.0" encoding="UTF-8"?>
<NounOutcome xmlns="http://www.openapplications.org/oagis"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:str="http://exslt.org/strings">
<DocumentIds>
<DocumentIdType>
<Id>43</Id>
<Revision>2</Revision>
</DocumentIdType>
<DocumentIdType>
<Id>43</Id>
<Revision>4</Revision>
</DocumentIdType>
</DocumentIds>
<NounOutcomeValue>NounOutcomeValue17</NounOutcomeValue>
<UserArea/>
</NounOutcome>
Is there any other way to generate such sequence.
Thanks in advance for any help!
Thanks
Pankaj
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







