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

Newbie Question: Convert "flat" hierarchy to nested h

Subject: Newbie Question: Convert "flat" hierarchy to nested hierarchy
From: "Watch-O-Matic" <watchomatic@xxxxxxxxxxx>
Date: Sat, 14 Oct 2006 08:08:34 -0700
nested hierarchy
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

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.