xsl-list
[Top] [All Lists]

[xsl] reversing or swapping nested node hierarchy

2006-03-19 11:41:32
Hi all.
In an XML document:

<root>
  <a>
    <b />
  </a>
  <a />
</root>

Is it possible to reverse the a/b hierarchy to produce b/a on output?
To complicate the problem, not all <a>'s have <b>'s.

So, in solving the problem, I've come up with something like this:

<template name="a" match="a">
  <a />
</template>

<template match="a[b]">
  <b>
    <call-template name="a" />
  </b>
</template>

..which works, but the <b> template now has working knowledge of <a>.

I'd like to find a generic solution where <b> doesn't have to know about
<a> so that <b> can be nested inside other elements too and yet work the
same way.

Thanks, Chris.


--~------------------------------------------------------------------
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>