W3C home > Mailing lists > Public > www-xsl-fo@w3.org > November 2004

Re: About XSL and CDATA HTML content management...

From: Mark Lundquist <ml@wrinkledog.com>
Date: Fri, 26 Nov 2004 11:30:12 -0800
Message-Id: <972B6430-3FE1-11D9-9DF0-000A95908E0E@wrinkledog.com>
Cc: www-xsl-fo@w3.org
To: patrick.gelin@rpn.ch

Hi Patrick,

On Nov 26, 2004, at 12:56 AM, Patrick Gelin wrote:

>
> Hi,
>
> I want to manage new line into tags contents. I'm working with a PHP  
> web
> site, using a PHP-XMLRPC client and then the XML data received is  
> parsed
> with a XSL script. This is the input XML data:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <requirement identifier="aaaaaaaa" name="aaaaaaaaa" priority="high"
> status="draft">
>   <revision date="2004-11-25 13:29:22" label="aaaaaaaa">
>     <author id="gelinp">Patrick Gelin</author>
>     <comment><![CDATA[aaaaaaaa aaaaaaa]]></comment>
>   </revision>
>   <description><![CDATA[aaaaaaa<br /><br />
> bbbbbbbb]]></description>
> </requirement>
>
> So, Firstly I tried to use \n with <comment> tag but XML-RPC replaced  
> it
> with a space...
>
> Then, I tried with <br> tag, it's ok for PHP-XMLRPC but the XSL script
> (below) modify the HTML content tag and '<BR>' to '&lt;br /&gt;'...
>
> The XSL script:
> ----------------
> (...)
> <td colspan="2">
>   <out:attribute xmlns:out="http://www.w3.org/1999/XSL/Transform"
> name="class">
>   <out:value-of select="$CSSPrefix"/>FormData</out:attribute>
>   <textarea name="req_description" cols="100" rows="10" style="width: 
> 100%">
>     <out:if xmlns:out="http://www.w3.org/1999/XSL/Transform"
> test="$ChangeHandler != ''">
>       <out:attribute name="onChange">
>         <out:value-of select="$ChangeHandler"/>
>       </out:attribute>
>     </out:if>
>     <out:attribute xmlns:out="http://www.w3.org/1999/XSL/Transform"
> name="class">
>     <out:value-of select="$CSSPrefix"/>FormControl</out:attribute>
>     <out:value-of xmlns:out="http://www.w3.org/1999/XSL/Transform"
> select="normalize-space(/requirement/description)"/>
>   </textarea>
> </td>
> (...)
>
> and the HTML result:
> ----------------
> (...)
> <td colspan="2" class="FormData">
> <textarea name="req_description" cols="100" rows="10"  
> style="width:100%"
> class="FormControl">aaaaaaa&lt;br /&gt;&lt;br /&gt; bbbbbbbb</textarea>
> </td>
> (...)
>

1) This is an XSL-FO mailing list; your question is about XSLT (the  
nomenclature unfortunately is confusing, for "historical" — i.e. lame  
— reasons :-).

2) There is an XSLT discussion list:  
http://www.mulberrytech.com/xsl/xsl-list/, for next time :-)

3) Your stylesheet is kind of bizarre... is it automatically generated  
or something?  The 'xmlns:out' attribute on XSLT elements doesn't need  
to be repeated every time, it only needs to occur once in the  
stylesheet (a common convention is to load all the xmlns: attributes  
into the root element of an XML document).  Also... you can of course  
call the namespace for XSLT whatever you want to call it, but "out:" is  
certainly unconventional... might I suggest the more common "xsl:" or  
"xslt:"?  That will make your stylesheet excerpts easier to read for  
others (i.e., we on http://www.mulberrytech.com/xsl/xsl-list/ :-)

4) And finally,

> So, I'm asking myself why XSL modified my CDATA HTML section ?

It didn't.  The output of the transformation is equivalent to what you  
wrote in your CDATA section, just expressed using entities instead.   
There is no requirement that the transformer preserve your CDATA  
syntax.  CDATA just tells the XML parser what it's looking at, that's  
all.  Once the XML is parsed, CDATA doesn't exist anymore.  It's just  
syntax.

For example: "<" in a CDATA section means a left angle bracket, right?   
Well, "&lt;" outside of a CDATA section means exactly the same thing  
— a left angle bracket.

HTH,
— Mark
Received on Friday, 26 November 2004 19:30:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:13 GMT