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

Re: interating through tree structure

Subject: Re: interating through tree structure
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 31 Mar 2009 06:30:49 -0700
Re:  interating through tree structure
> Hopefully someone can help me with something that I thought was going to be
straight forward but has been giving me a few problems!
>


I don't see any code in this message.

For generic operations on a tree one can use the FXSL function

     f:foldl-tree()

http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-foldl-tree.xsl?
revision=1.1&view=markup


Here is the test for this function:

This transformation:

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://fxsl.sf.net/"
exclude-result-prefixes="f"
>
    <xsl:import href="../f/func-foldl-tree.xsl"/>
    <xsl:import href="../f/func-Operators.xsl"/>

   <!-- This transformation must be applied to:
        ../data/numTree.xml

        Expected result: 66
    -->
    <xsl:output method="text"/>

    <xsl:template match="/">
      <xsl:value-of select="f:foldl-tree(f:add(), f:add(), 0, /*)"/>
    </xsl:template>
</xsl:stylesheet>

when applied on this XML document:


<nums tree-nodeLabel="01">
  <num tree-nodeLabel="02">01</num>
  <num tree-nodeLabel="03">02</num>
  <num tree-nodeLabel="04">03</num>
  <num tree-nodeLabel="05">04</num>
  <num tree-nodeLabel="06">05</num>
  <num tree-nodeLabel="07">06</num>
  <num tree-nodeLabel="08">07</num>
  <num tree-nodeLabel="09">08</num>
  <num tree-nodeLabel="10">09</num>
  <num tree-nodeLabel="11">10</num>
</nums>

produces the wanted result:

66


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play





On Tue, Mar 31, 2009 at 3:18 AM, jim mcgovern
<jim_mcgovern@xxxxxxxxxxxxx> wrote:
>
> Hi there
>
> Hopefully someone can help me with something that I thought was going to be
straight forward but has been giving me a few problems!
>
> I'm trying to generate site navigation from an xml file which is pretty much
as below:-
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> The above is a snapshot as it can go down "n" levels. B If I'm at page6 then
my navigation needs to be:-
>
>
> B dir1
> B dir2
> B dir4
>
>
> B dir5
> B dir6
>
>
> What I'm having difficulty with is how to close the opening ul and open a
new ul when I'm a directory up from the directory level I'm actully on.
>
> A stripped down but working version of What I'm trying is:-
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Can anyone advise me on how to achieve the formatting where I have 2 sets of
ULs? Any pointers much appreciated.
>
> Jim
> _________________________________________________________________
> All your Twitter and other social updates in one place
> http://clk.atdmt.com/UKM/go/137984870/direct/01/

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-2007 All Rights Reserved.