RE: [xsl] problem with processing CDATA tags in xml

Subject: RE: [xsl] problem with processing CDATA tags in xml
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Thu, 8 Apr 2010 14:01:16 +0200
Ok....

I need to clarify one thing...

Their product schema does not allow a <Value> to have subtags... That's why
they use CDATA.  And in my opinion that's not so bad since from a data point
of view these html tags are pure a rendition thing.

But basically I see 2 options from the responses:

(1): Use cdata-sections attribute  on <xsl:output>
(2): make changes to the schema for all elements which may have html tags as
children


I still see a problem with (1)... in the end when serializing to html I still
want to disable-output-escaping so the browser will recognize <sub> and <sup>
as tags instead of plain text... but then the greater then '>' will result in
invalid xml.

And I'm not sure if (2) will be accepted since this will involve quite a bit
of work to implement the changes.

Kind regards,
Robby




-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Thursday, April 08, 2010 1:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] problem with processing CDATA tags in xml

> I have a problem processing following tag:
>
> The original tag before transformation was:
> <Value><![CDATA[G<sub>p(max)</sub> is the maximum power gain,
> if K > 1. If K < 1 then G<sub>p(max</sub> = MSG.]]></Value>
>
>
> My customer wants to use <sub> and <sup> tags so in the
> rendition it's formatted nicely.
>

An excellent idea. If you want <sub> and <sup> to be recognized as tags, all
they need to do is get rid of the CDATA:

<Value>G<sub>p(max)</sub> is the maximum power gain,
  if K > 1. If K &lt; 1 then G<sub>p(max</sub> = MSG.</Value>

The only possible reason for having the CDATA is to prevent the <sub> and
<sup> being recognized as tags, so if you want them treated as tags, just
cut out the CDATA.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

Current Thread