[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Newbie Question: Convert "flat" hierarchy to nested hierarchy
Subject: [xsl] Newbie Question: Convert "flat" hierarchy to nested hierarchy From: "Watch-O-Matic" <watchomatic@xxxxxxxxxxx> Date: Sat, 14 Oct 2006 08:08:34 -0700 |
I'm a newbie among newbies in XSLT, so I request your patience. I'm interested in knowing if I can write an XSLT to transform a "flat" hierarchy, representing the hierarchy of a document, into a true nested hierarchy. And do the reverse direction transformation. To illustrate, here's an example of a "flat" hierarchy, where the hierachical level of each {markupx} item is specified using the 'lvl' attribute. (Each {markupx} item contains a mix of marked-up content.) <flat lvl="1"> {markupA} </flat> <flat lvl="2"> {markupB} </flat> <flat lvl="2"> {markupC} </flat> <flat lvl="1"> {markupD} </flat> <flat lvl="2"> {markupE} </flat> <flat lvl="2"> {markupF} </flat> <flat lvl="3"> {markupG} </flat> <flat lvl="4"> {markupH} </flat> <flat lvl="4"> {markupI} </flat> <flat lvl="3"> {markupJ} </flat> <flat lvl="3"> {markupK} </flat> <flat lvl="2"> {markupL} </flat> <flat lvl="1"> {markupM} </flat> Here's what I'd like to transform it into, and back again: <nest> {markupA} <nest> {markupB} </nest> <nest> {markupC} </nest> </nest> <nest> {markupD} <nest> {markupE} </nest> <nest> {markupF} <nest> {markupG} <nest> {markupH} </nest> <nest> {markupI} </nest> </nest> <nest> {markupJ} </nest> <nest> {markupK} </nest> </nest> <nest> {markupL} </nest> </nest> <nest> {markupM} </nest> Assume also that there will be other shared attributes for both <flat> and <nest> -- I've left them out in the above markup examples to make it easier to visualize the problem. Are the two-way transformations doable in XSLT? I humbly request the discussion focus on the feasibility of the two-way transformation, and not on alternatives to the markup models I'm working with. I don't have much say in the matter since this task was dropped in my lap (and having to come up to speed in XSLT.) Thanks! Mark -- Watch-O-Matic watchomatic@xxxxxxxxxxx -- http://www.fastmail.fm - Same, same, but different
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Forcing the order of temp, Geert Josten | Thread | RE: [xsl] Newbie Question: Convert , Michael Kay |
Re: [xsl] XSL and XML Help, Florent Georges | Date | [xsl] A union of two document() doe, Mikhail Edoshin |
Month |
Keywords