xsl-list
[Top] [All Lists]

[xsl] Got some cool XSLT code that assembles parts together to create larger parts?

2012-03-19 14:58:42
Hi Folks,

I need code that assembles parts together to create larger parts.

For example, consider this XML document:
------------------------------------------------------
<Document>
    <head id="head" idref="body" />
    
    <body id="body" idref="leg" />
    
    <leg id="leg" idref="toes" />
    
    <toes id="toes" />
  
</Document>
------------------------------------------------------
It contains a lot of parts - head, body, leg, toes. 

Each part references another part (except toes doesn't reference another part).

If a part references another part, I would like to inline the referenced part, 
and then recurses on the referenced part.

After assembly the document should be this:
------------------------------------------------------
<Document>
    <head id="head">
        <body id="body">
            <leg id="leg">
                <toes id="toes" />
            </leg>
        </body>
    </head>
    
    <body id="body">
        <leg id="leg">
            <toes id="toes" />
        </leg>
    </body>
    
    <leg id="leg">
        <toes id="toes" />
    </leg>
    
    <toes id="toes" />
</Document>
------------------------------------------------------

I wonder if this particular example is a special case of a general case of 
assembling parts together to create larger parts?

In any event, do you have some cool code that does the job?

Note that it's possible for a part A to reference a part B which references 
part A (i.e., circular reference). So the code must avoid going into an 
infinite loop.

/Roger

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>