[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem involving position() and COnditional filtering

Subject: Problem involving position() and COnditional filtering
From: "Pankaj Bishnoi" <pankaj.bishnoi@xxxxxxxxxxx>
Date: Tue, 30 May 2006 15:28:07 +0530
pankaj bishnoi
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=&apos;43&apos;">
                              <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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.