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

XSLT Grouping/Filtering issue with preceding/following

Subject: XSLT Grouping/Filtering issue with preceding/following axes
From: Jacquo Johnson <genxgeek@xxxxxxxxx>
Date: Fri, 5 Aug 2005 08:51:16 -0600
xslt preceding following
Hi,

I am very new to XSLT and need some enlightenment per the following
issue grouping filtering issue.

Any information (I'm sure this is FAQ'd somewhere) would be greatly
appreciated.

Thank you.

Description:

I am having the following problem when grouping/filtering as such in
that some nodes are getting filtered out/grouped  correctly while others do
not
based on position when using either preceding or following.

XSL:

...
 <xsl:template match="/">

   <!-- This doesn't work...group is not filtered correctly -->
   <xsl:variable name="uh" select="//Record[CodeId='FRED']"/>
   <xsl:element name="Copy">
       <xsl:copy-of select="$uh"/>
    </xsl:element>
    <xsl:element name="Filter">
       <xsl:copy-of
select="$uh[(not(AttributeName=preceding::*/AttributeName)]"/>
    </xsl:element>

    <!-- This works but I'm sure is not the best way to do this... -->
   <xsl:variable name="uh" select="//Record[CodeId='FRED']"/>
   <xsl:element name="Copy">
       <xsl:copy-of select="$uh"/>
    </xsl:element>
    <xsl:element name="Filter">
       <xsl:copy-of
select="$uh[(not(AttributeName=preceding::*/AttributeName) and
           position()=1) or
(not(AttributeName=following::*/AttributeName))]"/>
    </xsl:element>
 </xsl:template>

</xsl:stylesheet>


XML:

<Results>
               <Record>
                       <CodeId>FRED</CodeId>
                       <AttributeName>LT</AttributeName>
                       <OID>647f802e5f8675a6</OID>
                       <Id>AU  100-1</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>FRED</CodeId>
                       <AttributeName>CPQ</AttributeName>
                       <OID>647f802e5f8675a6</OID>
                       <Id>AU  100-2</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>30DAYPM</CodeId>
                       <AttributeName>LT</AttributeName>
                       <OID>daa575325f8675a6</OID>
                       <Id>AU  100-3</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>30DAYPM</CodeId>
                       <AttributeName>CSW</AttributeName>
                       <OID>daa575325f8675a6</OID>
                       <Id>AU  100-4</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>FRED</CodeId>
                       <AttributeName>LT</AttributeName>
                       <OID>647f802e5f8675a6</OID>
                       <Id>AU  100-5</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>FRED</CodeId>
                       <AttributeName>CPQ</AttributeName>
                       <OID>647f802e5f8675a6</OID>
                       <Id>AU  100-6</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>30DAYPM</CodeId>
                       <AttributeName>LT</AttributeName>
                       <OID>daa575325f8675a6</OID>
                       <Id>AU  100-7</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
               <Record>
                       <CodeId>30DAYPM</CodeId>
                       <AttributeName>CCSW</AttributeName>
                       <OID>daa575325f8675a6</OID>
                       <Id>AU  100-8</Id>
                       <AttributeValue>YES</AttributeValue>
               </Record>
</Results>

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.