XSL question-- walking a hierarchy

Discussion in 'XML' started by Jim Bancroft, Jan 15, 2004.

  1. Jim Bancroft

    Jim Bancroft Guest

    Sorry for the basic nature of this question. I know XSL can do this, but I
    don't recall a good method...

    Say I have an xml structure like this:

    <folder_structure>
    <folder name="folder1">
    <file name="myfile"/>
    </folder>
    <folder name="folder2">
    </folder>
    <folder name="folder3">
    <file name="somefile"/>
    <file name="anotherfile"/>
    </folder>
    <folder name="folder4">
    <folder name="folder5">
    <file name="newfile"/>
    </folder>
    </folder>
    </folder_structure>


    I need to use XSL to whip up a series of file paths, like this:

    folder1\myfile
    folder3\somefile
    folder3\anotherfile
    folder4\folder5\newfile

    I'm having trouble with walking the subfolders; for instance, the
    folder4\folder5 path above.

    The file paths can be arbitrarily deep, and I'm stumped on how to create a
    file <xsl:template> that recuruses up the tree and pulls all the parent
    folder names. If you have any advice, I'd be grateful. Thanks.
    Jim Bancroft, Jan 15, 2004
    #1
    1. Advertising

  2. http://www.topxml.com/code/default.asp?p=3&id=v20010323001030


    Dimitre Novatchev.
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


    "Jim Bancroft" <> wrote in message
    news:e9mNb.425$...
    > Sorry for the basic nature of this question. I know XSL can do this, but

    I
    > don't recall a good method...
    >
    > Say I have an xml structure like this:
    >
    > <folder_structure>
    > <folder name="folder1">
    > <file name="myfile"/>
    > </folder>
    > <folder name="folder2">
    > </folder>
    > <folder name="folder3">
    > <file name="somefile"/>
    > <file name="anotherfile"/>
    > </folder>
    > <folder name="folder4">
    > <folder name="folder5">
    > <file name="newfile"/>
    > </folder>
    > </folder>
    > </folder_structure>
    >
    >
    > I need to use XSL to whip up a series of file paths, like this:
    >
    > folder1\myfile
    > folder3\somefile
    > folder3\anotherfile
    > folder4\folder5\newfile
    >
    > I'm having trouble with walking the subfolders; for instance, the
    > folder4\folder5 path above.
    >
    > The file paths can be arbitrarily deep, and I'm stumped on how to create a
    > file <xsl:template> that recuruses up the tree and pulls all the parent
    > folder names. If you have any advice, I'd be grateful. Thanks.
    >
    >
    >
    >
    >
    Dimitre Novatchev, Jan 15, 2004
    #2
    1. Advertising

  3. Jim Bancroft

    Jim Bancroft Guest

    Jim Bancroft, Jan 15, 2004
    #3
  4. "Jim Bancroft" <> wrote in message
    news:wSyNb.10$...
    > Thanks, Dimitre.
    >
    > I'm still a little unclear on how I'm supposed to use your snippet--

    do
    > I paste it whole into my XSL code somewhere, then pass my node into it?
    >


    In the snippet there is:

    <xsl:variable name="theParmNodes" select="//namespace::*[local-name() =
    'myNamespace']"/>

    This causes the code to produce XPath expressions for all namespace nodes
    having prefix 'myNamespace'.

    If you want to get the XPath expression for a specific node, it should be
    specified as the "theParmNodes" xsl:param

    Of coourse, it is best to group the snippet into a named template, so that
    it can be called from different places simply with

    <xsl:with-param name="theParmNodes" select="."/>

    Dimitre Novatchev.
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
    Dimitre Novatchev, Jan 15, 2004
    #4
  5. Jim Bancroft

    Jim Bancroft Guest

    Ah, got it-- thanks again, Dimitre.

    -Jim


    > In the snippet there is:
    >
    > <xsl:variable name="theParmNodes" select="//namespace::*[local-name() =
    > 'myNamespace']"/>
    >
    > This causes the code to produce XPath expressions for all namespace nodes
    > having prefix 'myNamespace'.
    ><.....>
    Jim Bancroft, Jan 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mikito Harakiri

    tree walking -- saved recursion state

    Mikito Harakiri, Jan 3, 2004, in forum: Java
    Replies:
    13
    Views:
    712
    Matt Humphrey
    Jan 5, 2004
  2. Tina - AffordableHOST.com

    Re: Pain while walking

    Tina - AffordableHOST.com, Jul 14, 2003, in forum: HTML
    Replies:
    0
    Views:
    385
    Tina - AffordableHOST.com
    Jul 14, 2003
  3. Tim Burch

    Re: Pain while walking

    Tim Burch, Jul 14, 2003, in forum: HTML
    Replies:
    5
    Views:
    440
    T. Audry Glamour
    Jul 16, 2003
  4. Whitecrest

    Re: Pain while walking

    Whitecrest, Jul 14, 2003, in forum: HTML
    Replies:
    5
    Views:
    1,937
    Whitecrest
    Jul 15, 2003
  5. Replies:
    1
    Views:
    3,595
    A. Bolmarcich
    May 27, 2005
Loading...

Share This Page