Re: [xslt] problem with special carater in CDATA (part 2)



Philipp Dunkel wrote:

>Just a question:
>
>Why don't you do either:
>
><xsl:value-of select="'&lt;br/&gt;'" disable-output-escaping="yes"/>
>
>or just
>
><br/>
>
>Could you just tell me?
>  
>
simply because i have something like this

  <![CDATA[<textarea class="p" name="]]><xsl:call-template 
name="fabriquechemin" /><![CDATA[">]]><xsl:value-of select="." 
/><![CDATA[</textarea>]]>

and
  < become &lt;
 > become &gt;

<br /> was just a simple exemple of my problem

i do that because i don't know how to use <xsl:call-template 
name="fabriquechemin" /> to specify the content of name !


Arnaud.








>TTY Philipp
>
>On Wed, 2003-02-12 at 18:26, Arnaud Blancher wrote:
>  
>
>>I have a problem with special carater in CDATA
>>for exemple
>><![CDATA[<]]><![CDATA[br />]]> in xslt
>>
>>become
>>&lt;br /&gt;
>>
>>or i want <br />
>>
>>in old version of redhat i haven't this problem
>>
>>Daniel tell :
>>
>>    
>>
>>> There was a bug in the old version apparently and it has been fixed
>>>since it's a correct behaviour.
>>> If you want XHTML1 special formating, make sure your xsl:output ask
>>>for xml output and to add the XHTML1 DOCTYPE system and public ID. I
>>>let you check section 16 of the XHTML1 spec and the XHTML1 spec for the
>>>correct system and public IDs.
>>>      
>>>
>>so, i'have change my xslt, but the problem is still here
>>if you can help me.
>>thanks
>>
>>the same examples:
>> - with xmlproc
>>- in perl
>>
>>    
>>
>>> 
>>>
>>>      
>>>
>>#---------------------------------------------------------------------------------------------
>>xsltproc t.xsl t.xml
>>
>>#-----------------------------------------------
>># t.xsl
>>#----------------------------------------------
>>
>><?xml version="1.0"?>
>>
>><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
>>
>><xsl:output method="xml" 
>>doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
>>doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
>> />
>>
>><xsl:template match="xml">
>><html>
>><xsl:call-template name="XeditHidden" />
>></html>
>></xsl:template>
>>
>><xsl:template name="XeditHidden">
>><![CDATA[<]]><![CDATA[br />]]>
>></xsl:template>
>>
>></xsl:stylesheet>
>>
>>
>>
>>
>>#----------------------------------
>># t.xml
>>#----------------------------------
>><?xml version="1.0"?>
>><xml>
>><p chemin="/html_2" position="2"></p>
>></xml>
>>
>>#---------------------------------
>># return
>>#---------------------------------
>>
>><?xml version="1.0"?>
>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>><html>&lt;br /&gt;</html>
>>
>>#---------------------------------------------------------------------------------------------
>># perl exemple
>>#---------------------------------------------------------------------------------------------
>>#!/usr/bin/perl
>>
>># used version
>># redhat 8
>># libxml2-2.5.3-1.i386.rpm
>># zlib-devel-1.1.4-4.i386.rpm
>># libxml2-devel-2.5.3-1.i386.rpm
>># libxslt-1.0.26-1.i386.rpm
>># libxslt-devel-1.0.26-1.i386.rpm
>># perl 5.8
>># XML-LibXSLT-1.52
>># XML-LibXML-1.53
>>
>># problem whith CDATA section
>># <![CDATA[<]]><![CDATA[br />]]> in xslt
>># become
>># &lt;br /&gt;
>># in the output
>>
>>
>>use XML::LibXSLT;
>>use XML::LibXML;
>>
>>my $parser = XML::LibXML->new();
>>my $xslt = XML::LibXSLT->new();
>>
>>my $xmlsource=<<EOF;
>><?xml version="1.0"?>
>><xml>
>><html chemin="/html_2" position="2"></html>
>></xml>
>>EOF
>>;
>>
>>my $xslsource =<<EOF2;
>><?xml version="1.0"?>
>>
>><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
>>version="1.0">
>>
>><xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 
>>Strict//EN" 
>>doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
>>/>
>>
>><xsl:template match="xml">
>><html>
>><xsl:call-template name="XeditHidden" />
>></html>
>></xsl:template>
>>
>><xsl:template name="XeditHidden">
>><![CDATA[<]]><![CDATA[br />]]>
>></xsl:template>
>>
>></xsl:stylesheet>
>>EOF2
>>;
>>
>>#------------------------------------------------------------
>># transformation xml
>>
>> my $objXml = $parser->parse_string($xmlsource);
>> my $style = $parser->parse_string($xslsource);
>> my $stylesheet = $xslt->parse_stylesheet($style);
>> my $results = $stylesheet->transform($objXml);
>> my $xmlresult = $stylesheet->output_string($results);
>>
>> print $xmlresult;
>>#------------------------------------------------------------
>>
>>1;
>>
>>__END__
>>
>>result:
>><?xml version="1.0"?>
>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
>>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>><html>&lt;br /&gt;</html>
>>
>>
>>
>>_______________________________________________
>>xslt mailing list, project page http://xmlsoft.org/XSLT/
>>xslt@gnome.org
>>http://mail.gnome.org/mailman/listinfo/xslt
>>    
>>
>
>
>_______________________________________________
>xslt mailing list, project page http://xmlsoft.org/XSLT/
>xslt@gnome.org
>http://mail.gnome.org/mailman/listinfo/xslt
>
>  
>






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]