By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

XSL question-- walking a hierarchy

P: n/a
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.

Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
http://www.topxml.com/code/default.a...20010323001030
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" <bo*********@nospam.yahoo.com> wrote in message
news:e9*****************@news.uswest.net...
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.


Jul 20 '05 #2

P: n/a
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?
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bu************@ID-152440.news.uni-berlin.de...
http://www.topxml.com/code/default.a...20010323001030
Dimitre Novatchev.
FXSL developer, XML Insider,

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


Jul 20 '05 #3

P: n/a

"Jim Bancroft" <bo*********@nospam.yahoo.com> wrote in message
news:wS****************@news.uswest.net...
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
Jul 20 '05 #4

P: n/a
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'.
<.....>


Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.