Re: [xsl] inline XML <emphasis>

Subject: Re: [xsl] inline XML <emphasis>
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Sun, 24 Feb 2008 21:52:31 +0100
Hi Thomas,

>  I'm working with XML in the following form:
>  <cat>
>  <para>This is unstyled text <emphasis type="bold">and
>  this is bold. </emphasis>Now back to unstyled
>  text.</para>
>  </cat>
>  As you can see it has some inline style information
>  that's borderline not-well-formed. For my ease of use
>  I want the XML in this form (or the equivalent
>  result):
>  <cat>
>  <para><emphasis type="default">This is unstyled text
>  </emphasis><emphasis type="bold">and this is bold.
>  </emphasis><emphasis type="default">Now back to
>  unstyled text.</emphasis></para>
>  </cat>
Just take the identity transformation and add:
<xsl:template match="para/text()">
   <emphasis type="default">
      <xsl:value-of select="."/>
This way you select only text-nodes which are children of the para element.

> As extra credit :~) I want to keep possible nesting in
> mind, although my initial problem is already a sort of
> nesting problem, isn't it?
Can you give some details?

Hope this helps.

Current Thread