[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Newbie Question: Convert "flat" hierarchy to nested h
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|