Fran Cotton wrote:
> Hi, I'd greatly appreciate it if someone could cast light on my problem - I
> can't seem to find any reference to it anywhere. Consider the following XML:
>
> <paragraph> I am <emphasize>emphasized</emphasize> text inside a paragraph
> </paragraph>
>
> How do I go about transforming this into HTML like the following:
>
> <P>I am <EM>emphasized</EM> text inside a paragraph</P>
>
> The problem is that <emphasize> is a child of <paragraph>, but <paragraph>
> itself contains textual data too. The best I can do is to get the emphasized
> text output after the paragraph, not inside it!
Two Solutions.
First one: use the generix <xsl:apply-templates/>. Like this:
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="paragraph">
<P>
<xsl:apply-templates/>
</P>
</xsl:template>
<xsl:template match="emphasize">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
This is the simpler Way.
If you need to selectively process the content of paragraph, you may
want to use node():
<xsl:template match="paragraph">
<p>
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="name()='EM'">
<em><xsl:apply-templates/></em>
</xsl:when>
<xsl

therwise>
<xsl:apply-templates />
</xsl

therwise>
</xsl:choose>
</xsl:for-each>
</p>
</xsl:template>
As you can see, this example is a little bit bad for the second variant.
--
Erhard Schwenk
Akkordeonjugend Baden-Württemberg -
http://www.akkordeonjugend.de
K-ITX Webhosting -
http://webhosting.k-itx.net