xsl-list
[Top] [All Lists]

Re: [xsl] reversing or swapping nested node hierarchy

2006-03-20 14:06:51

G. Ken Holman wrote:

I hope the code below helps.  You don't say what you want done with 
attributes, so I didn't do anything with them myself.

. . . . . . . . . Ken
 

Thanks for your reply.  My example may have been too simple for what I'm
trying to do.  I should have specified that <a>, <b>, etc need to be
transformed, so a simple node copy would not be enough.

What I'm essentially looking for is a way to change the node hierarchy
during transformation.

So, if my document were:

<root>
  <a name="alpha">
    <b tag="beta" />
  </a>
</root>

and my templates were:

<template match="a">
  <aa>
    <copy-of select="@name" />
  </aa>
</template>
<template match="b">
  <bb>
    <copy-of select="@tag" />
  </bb>
</template>

would there be a way to produce this output:

<doc>
  <bb tag="beta">
    <aa name="alpha">
  </bb>
</doc>

where the node hierarchy  a/b  has been reversed to become  bb/aa  ?

The optimal solution would leave the "b" template generic so the element
could be included under other elements like  <a>, <c> and <d> in your
example.

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