OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] xslt for hierarchical data

[ Lists Home | Date Index | Thread Index ]

XSLT coding questions are better asked on the xsl-list at mulberrytech. This one comes up quite often.
 
A record is a logical root if it is named in an @parent attribute but does not appear in the content of any <record> element.
 
For each logical root, apply-templates to its logical children.
 
The logical children of a record R are those whose @parent attribute matches the string value of R.
 
The template rule for record adds a hierarchic level (e.g. by creating an element, or by creating indentation), outputs the string value of that record, and then applies-templates to the logical children of the record.
 
You can use keys to make the search for the logical children of a record more efficient.
 
Michael Kay


From: Jody Robert Ford [mailto:jody.r.ford@gmail.com]
Sent: 09 January 2006 23:39
To: xml-dev@lists.xml.org
Subject: [xml-dev] xslt for hierarchical data

Given a data structure:

 

<record id=1 parent=”Jack”>Jack Jr</record>

<record id=4 parent=”Jack”>William</record>

<record id=3 parent=”Jack Jr”>Jack III</record>

<record id=7 parent=”William”>William Jr.</record>

<record id=7 parent=”William Jr”>William III</record>

<record id=7 parent=”William III”>William IV</record>

 

How do I get…

 

Jack

            Jack Jr.

                        Jack III

            William            

                        William Jr.        

                                    William III

                                                William IV

 

Special problems.

  1. The number of generations can be infinite.
  2. Please note I don’t have a Jack record, but I need to display Jack.

 

 

Anyone got any ideas?

 

Thanks,

 

Jody

 

 

 





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS