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

RE: Flat XML: Problem getting children

Subject: RE: Flat XML: Problem getting children
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 7 Oct 2004 17:48:15 +0100
problem of children
We had someone else ask this a couple of days ago: the problem is called
"positional grouping" and you'll find a lot of material by googling on that.

There are broadly three approaches:

(a) in XSLT 2.0, use xsl:for-each-group group-starting-with=pattern

(b) handle it in the same way as value-based grouping (ie Muenchian grouping
using keys, but with a carefully-crafted grouping key: in this case
something like generate-id(self::NT|preceding-sibling::NT[1])

(c) recurse over the logical tree using xsl:apply-templates; on each
iteration instead of selecting the physical children, you select the logical
children, which are the following siblings that have the current record as
the most recent logical parent: something like apply-templates
select="following-sibling::*[generate-id(preceding-sibling::NT[1]) =
generate-id(current())]".

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Jacqui Moore [mailto:jacquimoore1@xxxxxxxxxxx]
> Sent: 07 October 2004 17:27
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Flat XML: Problem getting children
>
> I have an xml file that has the following structure:
>
> <thesaurus>
> <concept>
> <descriptor>House</descriptor>
> <NT>Rooms</NT>
> <NT>Roofs</NT>
> <SN>All About houses</SN>
> </concept>
> <concept>
> <descriptor>Rooms</descriptor>
> <BT>House</BT>
> <NT>Lounge</NT>
> <NT>Kitchen</NT>
> <SN>We have rooms in houses</SN>
> </concept>
> <concept>
> <descriptor> Lounge </descriptor>
> <BT> Rooms </BT>
> <SN>Lounges are nice places</SN>
> </concept>
> <concept>
> <descriptor> Roofs </descriptor>
> <BT>House</BT>
> <NT>Kitchen</NT>
> <SN>Roofs go on houses</SN>
> </concept>
> <concept>
> <descriptor> Utensils </descriptor>
> <BT>Kitchen</BT>
> <SN>Utensils belong in the draw</SN>
> </concept>
>
> </thesaurus>
>
> NT - the children categories
> BT - the parent category
>
> The objective is to create a expandable client side tree
> structure, and the
> user will click on a category and the category information
> (SN) will be
> displayed in the right frame.
>
> - HOUSE
>    - Rooms
>        o Lounge
>        o Kitchen
>             ' Utensils
>    - Roofs
>        o Kitchen
>            ' Utensils
>
> I can get the top level categories:
> <xsl:for-each select="thesaurus/concept[boolean(BT)=false]">
>
> My problem is I do not know how to get the children and their
> children etc.
> (loop until the concept has no NT element) . There is no
> limit to the number
> of children levels and a child can appear in more than one
> parent. I think I
> need to use a key but am not having ANY success.
>
> Thanks in advance!!
>
> Jacqui


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