Hi,
I'm trying to extract an inner node and place it at the level
as the element <para>. However I'm unable to figure it out.
Source XML:
<para>
Lorem ipsum dolor sit amet, <i>consectetur</i>
adipiscing elit. Aenean vestibulum pharetra metus.
<formula altimg="fig1">E = mc^2</formula>
Curabitur ac nibh purus, eget molestie dui. Integer
vulputate porta volutpat.
</para>
Expected result:
<p>
Lorem ipsum dolor sit amet, <i>consectetur</i>
adipiscing elit. Aenean vestibulum pharetra metus.
</p>
<p class="formula">
<img src="fig1.png" alt="E = mc^2" />
</p>
<p>
Curabitur ac nibh purus, eget molestie dui. Integer
vulputate porta volutpat.
</p>
I tried something like the following, but this will move the formules to the
end of the paragraph and thats not what I want. I also tried to loop over all the elements in the <para>, but then I can't figure out how to group the text nodes to one paragraph.
Source XSLT:
<xsl:template match="para">
<p>
<xsl:apply-templates select="node()[not(name() = 'formula')]" />
</p>
<xsl:apply-templates select="node()[name() = 'formula']" />
</xsl:template>
<xsl:template match="i">
<i><xsl:apply-templates /></i>
</xsl:template>
<xsl:template match="formula">
<p class="formula">
<img>
<xsl:attribute name="src">
<xsl:value-of select="@altimg" />
<xsl:text>.png</xsl:text>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:apply-templates />
</xsl:attribute>
</img>
</p>
</xsl:template>
--
Stefan Kuip