Splitting elements with XSLT?

Here should go questions about transforming XML with XSLT and FOP.
booiboa
Posts: 2
Joined: Tue Jun 01, 2010 3:54 pm

Splitting elements with XSLT?

Post 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!
booiboa
Posts: 2
Joined: Tue Jun 01, 2010 3:54 pm

Re: Splitting elements with XSLT?

Post 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
Post Reply