xsl-list
[Top] [All Lists]

Re: CDATA question

2004-04-14 14:57:52

<xsl:template match="emphasis">
 <b><xsl:apply-templates/></b>
</xsl:template>

That would generate a b element in the output, but you don't want a b
element you want

<xsl:template match="emphasis">
 &lt;b&gt;<xsl:apply-templates/>&lt;/b&gt;
</xsl:template>

as what you want is

<mattext texttype="text/html"><![CDATA[Select the <b>GPO Part Additional
Info</b> link in the <b>Navigation</b>screen.]]></mattext>


which is the same thing as

<mattext texttype="text/html">Select the &lt;b>GPO Part Additional
Info&lt;/b> link in the &lt;b>Navigation</b>screen.</mattext>

The difference between using CDATA and using &lt; should be seen as a
purely syntactic artifact with no difference in meaning just as using "
or ' around attribute values has no effect on the meaning.
So you use the same xslt templates in either case, and just request the
CDATA style of linearisation.

Since you have used 

cdata-section-elements="mattext feedback">

The text node will be output in CDATA style (even if entered using &lt;)
but you have to create a single text node, not a a tree of elements and
attributes. 

Of course better, if you have any control over the output format, is not
to use a CDATA section and to have elements in there. Since that <b> is
presumably intended to be markup, it's slightly peverse (although
depressingly common) to declare that it is _not_ markup but C(haracter )Data.


David


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


<Prev in Thread] Current Thread [Next in Thread>