|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Content of Script element getting wrapped by CDATA
I tested the code, but I am getting errors on line
> <!--Identity Transform-->
> <xsl:template match="element()">
> <xsl:copy>
> <xsl:apply-templates select="@*,node()"/>
> </xsl:copy>
> </xsl:template>
> <xsl:template
> match="attribute()|text()|comment()|processing-instruction()">
> <xsl:copy/>
> </xsl:template>
The processor doesn't like the selectors "element()", "@*,node()" and
"attribute()|text()|comment()|processing-instruction()".
Using TestXSLT (http://www.entropy.ch/software/macosx/), I checked the
code with Xalan, Sablotron, Libxslt and Saxon. And all of them showed
errors. Sablotron and PHP Libxslt showed the error was on line 41. If
I change element() with node(), then the error is shown for the
selector "@*,node()".
@David - Unfortunately, it is not working. I am getting syntax error,
since Javascript doesn't understand the statement <![CDATA[
Here is my complete code
<!-- XML code -->
<?xml version="1.0"?>
<root>
<head>
<title>XSLT</title>
<link href="/manage/style.css" type="text/css" rel="stylesheet"/>
<script src="/js/jquery.js" type="text/javascript"/>
<script src="/js/tablesort.js" type="text/javascript"/>
<script type="text/javascript">//<![CDATA[
alert('JOYCE');
//]]></script>
</head>
</root>
<!--xsl code-->
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " " >
<!ENTITY copy "©">
<!ENTITY laquo "«" >
<!ENTITY raquo "»">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
xsl:extension-element-prefixes="php"
xmlns=""
>
<xsl:output method="xml" standalone="no" indent="no" encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
cdata-section-elements="script style" omit-xml-declaration="yes"/>
<!-- standard match to include all child elements -->
<xsl:template match="/">
<html xml:lang="en" lang="en">
<!-- Include Header -->
<xsl:apply-templates select="/root/head" />
<body>
</body>
</html>
</xsl:template>
<!-- Identity Template -->
<xsl:template match="script | style">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<!--Note: The 
 characters at the end of the CDATA start tag
and before the CDATA end tag are important because the script
text may begin and end with new lines.-->
<xsl:value-of disable-output-escaping="yes"
select="concat('//<![CDATA[
',text(),'
//]]>')"/>
</xsl:copy>
</xsl:template>
<!--Identity Transform-->
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*,node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="attribute()|text()|comment()|processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








