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

RE: Re: getting all nodes from a certain level in the

Subject: RE: Re: getting all nodes from a certain level in the xml hierarchy
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 27 Sep 2002 14:45:29 +0100
xsl output all
> When i try this, I get a  "Cannot convert number to NodeSet" 
> Error... I use the Oracle XSLProcessor Classes. 

Looks like an Oracle bug. If the second argument to key() is a number,
it should convert it to a string, not to a node-set. You could probably
circumvent it by converting explicitly to a string using the string()
function.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 
> 
> 
> -----Ursprungliche Nachricht-----
> Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von 
> Dimitre Novatchev
> Gesendet: Freitag, 27. September 2002 12:46
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff:  Re: getting all nodes from a certain level in 
> the xml hierarchy
> 
> 
> Here's a simple solution using the Muenchian method for grouping:
> 
> source xml (provided by you):
> ----------------------------
> <Folder NAME="/">
>   <Folder NAME="a"/>
>   
>   <Folder NAME="b">
>     <Folder NAME="ba"/>
>     <Folder NAME="bb"/>
>   </Folder>
>   
>   <Folder NAME="z">
>     <Folder NAME="za">
>       <Folder NAME="very deep folder"/>
>     </Folder>
>   </Folder>
> </Folder>
> 
> stylesheet:
> ----------
> <xsl:stylesheet version="1.0" 
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  
>  <xsl:output method="text"/>
>  
>   <xsl:key name="kDepth" match="Folder" 
>            use="count(ancestor::*)" />
>   
>   <xsl:template match="/">
>     <xsl:for-each select="//Folder
>                              [
>                               generate-id()
>                              =
>                               generate-id(key('kDepth',
>                                               count(ancestor::*)
>                                               )[1]
>                                           ) 
>                               ]">
>     
>       <xsl:value-of select="concat('Level ', 
>                                    count(ancestor::*),
>                                    ': ' 
>                                    )"/>
>       <xsl:for-each select="key('kDepth',count(ancestor::*))">
>         <xsl:value-of select="concat(@NAME, '; ')"/>
>       </xsl:for-each>
>       
>       <xsl:text>&#xA;</xsl:text>
>     </xsl:for-each>
>   
> 
>   </xsl:template>
> </xsl:stylesheet>
> 
> 
> Result:
> ------
> 
> Level 0: /; 
> Level 1: a; b; z; 
> Level 2: ba; bb; za; 
> Level 3: very deep folder;
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.