Madlik, Monika (LNG-VIE) wrote:
>
> I'd like to write a macro, which wraps some sections with a complex
> element.
>
> Here is an example:
> -------------------
>
> This are my sections, I want to wrap:
> <sect>test</sect>
> <sect>test</sect>
> <sect>test</sect>
> <sect>test</sect>
>
> This is the complex element:
> <randziffer>
> <rz-zaehlung/>
> <sect/>
> </randziffer>
>
> This should be the result:
> <randziffer>
> <rz-zaehlung/>
> <sect>test</sect>
> <sect>test</sect>
> <sect>test</sect>
> <sect>test</sect>
> </randziffer>
>
> Is this possible?
>
Yes. Here's the *outline* of such macro (do not forget to cope with
namespaces if you use them):
---
<command name="myWrap">
<macro undoable="true">
<sequence>
<pass><command name="replace"
parameter="randziffer"/></pass><!--TO BE IMPROVED-->
<command name="myWrap2" />
<command name="paste" parameter="to %_" />
</sequence>
</macro>
</command>
<command name="myWrap2">
<process showProgress="false">
<copyDocument selection="true" to="selection.xml" />
<transform stylesheet="myWrap.xslt" cacheStylesheet="true"
file="selection.xml" to="wrapped.xml" />
<read file="wrapped.xml" encoding="UTF-8" />
</process>
</command>
---
This looks very much like this example:
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/para_to_simpara.html
Please read it to learn how to write an XSLT style sheet working on a
XML document containing a multi-node selection coming from XXE.