[xml] special carater in CDATA
- From: arnaud <arnaud ungi net>
- To: xml gnome org
- Subject: [xml] special carater in CDATA
- Date: Wed, 12 Feb 2003 16:18:40 +0100
Hello,
(i not sure I am in the right list, but hope)
I have a problem with special carater in CDATA
for exemple
<![CDATA[<]]><![CDATA[br />]]> in xslt
become
<br />
or i want <br />
in old version of redhat i haven't this problem
here a complete script to show the problem.
If anyone can help me !
Thanks.
#!/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
# <br />
# 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="html"/>
<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
;
#------------------------------------------------------------
# transfomation 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:
<html>
<head><meta content="text/html; charset=iso-8859-1"
http-equiv="Content-Type"></head>
<body><br /></body>
</html>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]