I am trying to convert an XML & XSL script from ASP to PHP.
I can get the XML and XSL to work fine, but for ASP i am using msxml to apply javascript functions.
Of course I cannot use that in PHP, so I was wondering if there is a way to do the same thing?
Here is the ASP:
and the XSL:
and the PHP im using:
This doesnt work currently because of the msxml part, but if I take that out its does work.
I need a replacement for it that will work witht he PHP XSL.
Thanks in advance to any help
I can get the XML and XSL to work fine, but for ASP i am using msxml to apply javascript functions.
Of course I cannot use that in PHP, so I was wondering if there is a way to do the same thing?
Here is the ASP:
Code:
<%
dim url
url = "file.xml"
dim xmlhttp
set xmlhttp = server.createObject("msxml2.serverXMLHttp")
xmlhttp.open "GET", url, false
xmlhttp.send()
rspxml = xmlhttp.responseText
set xmlhttp = nothing
dim xmldoc
set xmldoc = createObject("msxml2.DOMDocument")
xmldoc.Async = false
xmldoc.loadXML(rspxml)
dim style
set style = createObject("msxml2.DOMDocument")
style.async = false
style.load(server.mapPath("file.xsl"))
dim outHtml
outHtml = xmldoc.transformNode (style)
set xmldoc = nothing
set style = nothing
%>
and the XSL:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
function ChopURL(url)
{
var retstr, i, pos;
retstr = unescape(url);
pos = retstr.indexOf("://", 1);
if(pos >= 0)
retstr = retstr.substring(pos + 3, retstr.length);
pos = retstr.indexOf("/", 1);
if(pos >= 0)
retstr = retstr.substring(0, pos);
retstr = LeftStr(retstr, 50);
return retstr;
}
]]>
</msxsl:script>
<xsl:template match="/">
<a>
<xsl:attribute name="href"><xsl:value-of select="user:ChopURL(string(URL))"/></xsl:attribute>
</a>
</xsl:template>
</xsl:stylesheet>
and the PHP im using:
Code:
<?
$xml = new DOMDocument;
$xml->load('file.xml');
$xsl = new DOMDocument;
$xsl->load('file.xsl');
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);
?>
This doesnt work currently because of the msxml part, but if I take that out its does work.
I need a replacement for it that will work witht he PHP XSL.
Thanks in advance to any help