George Cristian Bina wrote:
Abel,
Your solution does not work correctly, on the sample input it gives:
<dir name="cn"/>
<dir name="cn"/>
Ah, forgot to mention, you are right. I cheated: I first "corrected" the
list, but left it out of the solution...
Since it uses following-sibling[1] to check if a file/directory belongs
to the same node, it can only work when the list is ordered in a certain
way. Analyzing the input, I assumed directory order (like, output of
dir, or ls) which is: directory first, then files, then subdirectories.
I figured the OP had put the "cn" entry erroneously at the end, so I
corrected it like this:
<item>cn</item>
<item>cn/test.xml</item>
<item>en</item>
<item>en/test.html</item>
<item>en/test1.html</item>
<item>en/resource</item>
<item>en/resource/style</item>
<item>en/resource/style/test.css</item>
<item>favicon.ico</item>
In addition, it assumes that a dot in the name is a file, which is not
ideal. It were better if a directory is considered a directory when it
occurs more than once. Which still does not solve the favicon.ico, which
can be either a directory or a file. I choose the latter for ease of
implementation.
To make my solution working with any order of input, some adjustments
must be made. I tried a few, and I am sure it can be done, but got a bit
entangled while trying to keep the solution short and with pure match
templates. No doubt I would end above my 12 lines ;-)
-- Abel
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--