Re: [xslt] CDATA sections, nested entities



Daniel Veillard wrote:
> 
> On Wed, Jan 07, 2004 at 03:26:14PM +0100, Markus Bayerlein wrote:
> > However, xsltproc still ignores the cdata-section-elements attribute:
> > <xsl:stylesheet version="1.0"
> >                 xmlns="&svgns;"
> 
>    default namespace
> 
> >                 xmlns:xsl="&xsltns;"
> >                 exclude-result-prefixes="xsl">
> >
> > <xsl:output method="xml" indent="yes" encoding="iso-8859-1" standalone="yes"
> >             cdata-section-elements="script"/>
> 
>    script -> no namespace indicated so applies only to element
>              named script in no namespace.
> 
> > <xsl:variable name="foo" select="'bar'"/>
> >
> > <xsl:template match="/">
> >   <script type="text/ecmascript">
> 
>   script is in a namespace, the one from "&xsltns;"
> 
> Not a bug, you misunderstood the XSLT spec IMHO.
> 
> Daniel
> 
> --
> Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
> veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt

Hi.

The "script" element is in the default namespace "&svgns;".

I quote from the XSLT spec (http://www.w3.org/TR/xslt#output):
"...Each QName is expanded into an expanded name using the namespace
declarations in effect on the xsl:output element in which th QName
occurs; if there is a default namespace, it is used for QNames that do
not have a prefix...."

By the way, the CDATA section is properly created when the
xmlns="&svgns;" declaration on the xsl:stylesheet element is omitted.

xsltproc testcase8.xsl testcase.xml
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<script type="text/ecmascript"><![CDATA[
  var foo2 = text;
  ]]></script>

Cheers

Markus
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>

<!DOCTYPE xsl:stylesheet [

<!ENTITY bar "bar"> 

<!ENTITY foo "var foo = &bar;"> 

<!-- namespace for SVG -->
<!ENTITY svgns "http://www.w3.org/2000/svg";>
<!-- namespace for XSLT -->
<!ENTITY xsltns "http://www.w3.org/1999/XSL/Transform";>

]>

<xsl:stylesheet version="1.0" 
                xmlns:xsl="&xsltns;"
                exclude-result-prefixes="xsl">

<xsl:output method="xml" indent="yes" encoding="iso-8859-1" standalone="yes"
            cdata-section-elements="script"/>

<xsl:variable name="foo" select="'bar'"/>

<xsl:template match="/">
  <script type="text/ecmascript">
  var foo2 = text;
  </script>
</xsl:template>            

</xsl:stylesheet>
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<rootelement>
  <childelement/>
  <childelement/>
</rootelement>


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