[
Lists Home |
Date Index |
Thread Index
]
- From: Newsha Makooi <Newsha@imrgold.com>
- To: "'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
- Date: Tue, 11 Jul 2000 14:52:06 -0600
Title: RE: Hierarchy
Thanks for the info. I am a bit confused about the second step you mentioned. Do you see the <path="x/y/z"> parsed out as
<folder name="x"/><folder name="y"/><folder name="z"/>
-OR-
<folder name="x">
<folder name="y">
<folder name="z">
</folder>
</folder>
</folder>
??
Then, the grouping would happen, right?
------------
Also, I could not find any examples for Preceding-Sibling. Just an explanation on page 736 (XSLT, Programmer's Reference). Where can I find more info on Preceding-Sibling/Following-Sibling?
PS
Just to clarify my objective, I am using an XML document which has a listing of files and their location (absolute, such as Root\Folder1\Folder2\Folder3). Each file has its own Path. The XML feed has these files all over without any order. I am trying to use XSLT to build a new XML document which groups all files that belong to the same folder Path. So, I'll need to build a new XML tree structure and 'stick' the incoming XML entries into their appropriate location, thereby building hierarchy into the resulting XML.
Also, I am using MSXML3.
Thanks.
Newsha
-----Original Message-----
From: Kay Michael [mailto:Michael.Kay@icl.com]
Sent: Friday, July 07, 2000 2:30 AM
To: 'Newsha Makooi'
Subject: RE: Hierarchy
This kind of grouping problem is never easy in XSLT, and this is one of the
more complex ones! I think I'd break it up into several passes, either using
a sequence of stylesheets or using the node-set() extension (create a result
tree fragment, then process it further). The first pass might sort by path,
as you've already done, the second might parse the path (so path="x/y/z"
becomes <folder name="x"><folder name="y"><folder name="z">, and the third
might do grouping of adjacent entries that belong to the same folder: this
is then a classic grouping which you can do as
<xsl:for-each
select="folder[not(@name=preceding-sibling::folder[1]/@name)]">
<folder name="{@name}">
<xsl:for-each select="self::* |
following-sibling::folder[@name=current/@name]">
[folder details]
Then the next trick is for this template to be applied recursively to each
level of folder.
Hope these ideas help.
Mike
-----Original Message-----
From: Newsha Makooi [mailto:Newsha@imrgold.com]
Sent: 07 July 2000 01:17
To: 'Kay Michael'
Subject: Hierarchy
Hi Michael,
Sorry I am writing to you directly, but I think I am running out of options
and I needed your guidance if you have the time.
I am dealing with the following XML document (ZDocList.xml).
In my XSL document (TOC.xsl), I sort the XML document in order to group all
the elements. Next, I would like to build a hierarchy based on the
FolderPath for all of the document entries. But the XSL that I have only
builds the hierarchy for that node! I want all of the nodes to be put into
the hierarchy based on their FolderPath.
In essence I want to end up with something similar to this:
<TOC>
<entry folderpath="Level1">
<entry folderpath="Level2">
<entry folderpath="">actual document</entry>
</entry>
<entry folderpath="Level2">
<entry folderpath="">actual document</entry>
<entry folderpath="">actual document</entry>
<entry folderpath="">actual document</entry>
</entry>
</entry>
<entry folderpath="Level1">
<entry folderpath="Level2">
<entry folderpath="">actual document</entry>
<entry folderpath="">actual document</entry>
<entry folderpath="">actual document</entry>
</entry>
</entry>
</TOC>
How can I get the above from what I have so far? Would you please direct
me?
Please ignore this if it takes too much of your time. I don't want to be a
bother. Support@Wrox has not been able to help because it does not pertain
to 'source code' mistakes in a book.
Thanks for your time and assistance.
Regards,
Newsha
|