RE: [xsl] xslt for hierarchical data

Subject: RE: [xsl] xslt for hierarchical data
From: omprakash.v@xxxxxxxxxxxxx
Date: Wed, 11 Jan 2006 18:24:35 +0530
Hi Jody,

        I would think that the best way to solve your problem would be to
use a 2-phase transformation. You first create a nodeset that way you have
the  hierarchical relationship readily available.


Thus your xml becomes,

<records>
<record id="1" name="Jack">

<record id="1" name="Jack Jr">
<record id="7" name="Jack III"/>
</record>

<record id="4" name="William">
<record id="3" name="William Jr.">
<record id="3" name="William III">
<record id="3" name="William IV"/>
</record>
</record>
</record>

</record>
</records>

and in the second phase you emit the result with the elements correctly
intendeted. Ofcourse to do this in XSLT 1.0, you would need the nodeset
extension function.

Hope this helps.

cheers,
prakash







                                                                                                                                       
                      Jody Robert Ford                                                                                                 
                      <jody.r.ford@gma         To:      <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>                                              
                      il.com>                  cc:      (bcc: omprakash.v/Polaris)                                                     
                                               Subject: RE: [xsl] xslt for hierarchical data                                           
                      01/11/2006 05:16                                                                                                 
                      PM                                                                                                               
                      Please respond                                                                                                   
                      to xsl-list                                                                                                      
                                                                                                                                       
                                                                                                                                       




Sample code would be extremely helpful.

Thanks,

Jody

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Wednesday, January 11, 2006 4:26 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] xslt for hierarchical data

I gave you an answer to this question when you asked it on xml-dev. Did you
have difficulties with that answer? If so, please explain what you didn't
understand and I will try to explain in more detail.

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

> -----Original Message-----
> From: Jody Robert Ford [mailto:jody.r.ford@xxxxxxxxx]
> Sent: 11 January 2006 01:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xslt for hierarchical data
>
> Given a data structure:
>
>
>
> <record id=1 parent="Jack" parentid=0>Jack Jr</record>
>
> <record id=4 parent="Jack" parentid=1>William</record>
>
> <record id=3 parent="Jack Jr" parentid=1>Jack III</record>
>
> <record id=7 parent="William" parentid=4>William Jr.</record>
>
> <record id=9 parent="William Jr" parentid=7>William III</record>
>
> <record id=11 parent="William III" parentid=9>William IV</record>
>
>
>
> How do I get.
>
>
>
> Jack, 0
>
>             Jack Jr., 1
>
>                         Jack III, 3
>
>             William, 4
>
>                         William Jr., 7
>
>                                     William III, 9
>
>                                                 William IV, 11
>
>
>
> Special problems.
>
> The number of generations can be infinite.
> Please note I don't have a Jack record, but I need to display
> Jack. (Logical
> root Record)
> Please note some parent records can be physical records too.
>
>
>
>
> Anyone got any ideas?
>
>
>
> Thanks,
>
>
>
> Jody





This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Current Thread