Problem with XSLT Sablotron
| From: | Juan Torres | Date: | Wed, 11 Feb 2004 11:06:59 +0000 |
| Subject: | Problem with XSLT Sablotron | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-177364@lists.php.net to get a copy of this message | ||
Hi,
I have got this XML file:
<!--
<?xml version="1.0" encoding="UTF-16"?>
<DOC>
<PARA>texto 1</PARA>
<PARA>texto 2</PARA>
<PARA>texto 3</PARA>
<PARA>texto 4</PARA>
<PARA>texto 5</PARA>
</DOC>
-->
and this XSL file:
<!--
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:user="urn:star-xslt-lib-namespace"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>xsl</title>
</head>
<body>
<xsl:apply-templates select="DOC" />
</body>
</html>
</xsl:template>
<xsl:template match="DOC">
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<b>
<xsl:value-of select="user:EscapeURL('DOC')"/>
</b>
</td>
</tr>
<tr>
<td>
<xsl:apply-templates select="PARA"/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="PARA">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<i>
PARA:
</i>
</td>
<td style="color: green">
<xsl:value-of select="."/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="text()">
<xsl:copy-of select="."/>
</xsl:template>
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
function EscapeURL(selection) {
if (selection(0) == null)
return "";
else if (selection(0).hasChildNodes())
return escape(selection(0).childNodes(0).nodeTypedValue);
else
return escape(selection(0).nodeTypedValue);
}
]]>
</msxsl:script>
</xsl:stylesheet>
-->
finally, my PHP file is:
<!--
-->
<?
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
if ($result = xslt_process($xh, 'projects_php/testing/sample.xml',
'projects_php/testing/sample.xsl')) {
echo ($result);
}
else {
echo "Sorry, sample.xml could not be transformed by sample.xsl into";
echo " result.xml the reason is that " . xslt_error($xh) . " and the
";
echo "error code is " . xslt_errno($xh);
}
xslt_free($xh);
?>
-->
When I run my php file, this error message is shown:
Warning: Sablotron error on line 27: function 'user:EscapeURL' not supported
in c:\inetpub\wwwroot\projects_php\testing\test_xsl.php on line 7
Sorry, sample.xml could not be transformed by sample.xsl into result.xml the
reason is that function 'user:EscapeURL' not supported and the error code is
51
Can anybody help me? I cann't solve this error.
Thanks very much!
Juan Torres.
PS: Excuse me, my english is bad :(