xsl-list
[Top] [All Lists]

[xsl] Shallow (in-place) parent-child swap

2006-12-11 02:56:03
Greetings all,

I have a significant amount of experience with XSLT but I'm struggling
to find a way to accomplish the following:

<sentence>
 <w>...</w>
 ...
 <w>
   <phr>
     <seg>word</seg>
   </phr>
 </w>
 ...
 <w>...</w>
</sentence>

==>

<sentence>
 <w>...</w>
 ...
 <phr>
   <w>
     <seg>word</seg>
   </w>
 </phr>
 ...
 <w>...</w>
</sentence>

(Singleton phrases are erroneously getting nested within words... This
occurs here and there throughout a large body of marked-up text.)

Note that the order of the <w> elements is significant (words within a
sentence), and that all of the above elements may or may not have
attributes.

I've tried various approaches, but I'm stumped as to how to copy the
<phr> (without its children/text) and then get the <w> copied within.
Perhaps I'm overlooking the obvious here...

I've found similar questions on the list, but the requirements were a
little different and I can't seem to adapt the solutions to this case.

Thanks in advance for any help,

David

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