Recursive xslt expansion

  • Thread starter Hallvard B Furuseth
  • Start date
H

Hallvard B Furuseth

Can I have one XSLT style sheet which expands some brief XML to a longer
"normalized" form, which one of several other XSLT style sheets expands
further (or one of several parts of one sheet)? Finally, I'll render it
with a CSS style sheet. Or is there some other way one normally does
that?

E.g. in this xml:

<library>
<author a_id="me" name="Myself"/>
<series s_id="mine" name="My series">
<by a_ref="me"/>
<omnibus name="Foobar">
<with>You</with>
<novel name="Foobar #1"/>
<novel name="Foobar #3"> <by name="Her"/> </novel>
<novel name="Foobar #2"> <with name="Him"/> </novel>
</omnibus>
</series>
</library>

outer <by>s are inherited if there is no other <by> to use at a level,
while <with> adds a new <by> to the currently active <by>s. Also, not
sure if I'll implement this but here author names not directly inside
<library> are dragged out to <library> and given an a_id. So the above
expands to (maybe with numbered new a_ids rather than those shown here):

<library>
<author a_id="me" name="Myself"/>
<!-- Author IDs generated from authors without IDs: -->
<author a_id="id_You" name="You"/>
<author a_id="id_Her" name="Her"/>
<author a_id="id_Him" name="Him"/>
<series s_id="mine" name="My series">
<by a_ref="me"/>
<omnibus name="Foobar">
<by a_ref="me"/>
<by a_ref="id_You"/>
<novel name="Foobar #1">
<by a_ref="me"/>
<by a_ref="id_You"/>
</novel>
<novel name="Foobar #3">
<by a_ref="id_Her"/>
</novel>
<novel name="Foobar #2">
<by a_ref="me"/>
<by a_ref="id_You"/>
<by a_ref="id_Him"/>
</novel>
</omnibus>
</series>
</library>

which is then expanded further by some other sheet.
 
M

Martin Honnen

Hallvard said:
Can I have one XSLT style sheet which expands some brief XML to a longer
"normalized" form, which one of several other XSLT style sheets expands
further (or one of several parts of one sheet)? Finally, I'll render it
with a CSS style sheet. Or is there some other way one normally does
that?

You can chain XSLT transformations as long as the stylesheets transform
to XML respectively don't depend on stuff like disable-output-escaping.
The last stylesheet in the chain can then transform to HTML.

Using one stylesheet to do several transformation passes is also
possible with XSLT 1.0 but only if the XSLT processsor supports an
extension function like exsl:node-set to transform a result tree
fragment to a node set so that each pass creates a result tree fragment,
the extension functions then creates a temporary node set on which the
next pass works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top