Parameter issue using setparameter and XSLT
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
I am attempting to pass the location.href as a parameter to the XSL.
On opera this works but on Firefox it does not. What am I doing wrong?
The problem is the parameter is "empty" on Firefox .
Note: When I attempt a simple javscript string as a parameter instead
of the href it still does not work.
HTML
<html>
<head>
<script type="text/javascript">
function transform()
{
var href = document.location.href;
var xsl = document.implementation.createDocument("", "", null);
xsl.async = false;
xsl.load("p.xsl");
var processor = new XSLTProcessor();
processor.importStylesheet(xsl);
processor.setParameter(null, "url", href);
var result = processor.transformToDocument(document);
document.removeChild(document.firstChild);
document.appendChild(result.firstChild);
}
</script>
</head>
<body onload="transform();">
<div>Input document</div>
</body>
</html>
XSL (p.xsl)
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:param name="url"/>
<html>
<body>
<div>Browser URL</div>
<div><xsl:value-of select="$url"/></div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>