Page 1 of 1

Splitting elements with XSLT?

Posted: Tue Jun 01, 2010 4:10 pm
by booiboa
Hi!

Sitting with a document conversion/transformation where an element needs to split and I do not know how to handle it with XSL.

An example of input data:

Code: Select all


<document>
<container>
<p>TEXT HERE</p>
<graphic ref="test.eps"/>
<p>MORE TEXT</p>
<graphic ref="newtest.eps"/>
<p>EVEN MORE TEXT</p>
</container>
</document>
An example of what I want to see in the output data:

Code: Select all


<document>
<container>
<p>TEXT HERE</p>
<graphic ref="test.eps"/>
<p>MORE TEXT</p>
</container>
<container>
<graphic ref="newtest.eps"/>
<p>EVEN MORE TEXT</p>
</container>
</document>
The rule here is that only one graphic can exist in each container, so you want to match second graphic within a container and split the container.

What I like to do is match the second and put in this:
</container>
<container>
but that is not valid XML!

So I thought that a split-function, like for instance Arbortext Editor have, would solve the situation.
Any ideas someone?

Thanx!

Re: Splitting elements with XSLT?

Posted: Wed Jun 09, 2010 10:14 am
by booiboa
Hi again,

Found a way myself.
I use the CDATA-functionality, then it works.
I do this:

Code: Select all


<xsl:text disable-output-escaping="yes"><![CDATA[</container><container>
]]></xsl:text>
Not nice, but works!
BGood everyone!
/B