매우 간단한 코드로 작동하지 못했습니다. XSLT의 매개 변수는 항상 비어 있습니다. 내가 뭘 놓치고 있니? 나는 FF6을 사용하고있다. 날카로운 눈으로 도와주세요. 감사!
자바 스크립트에서 매개 변수가 전달되지 않는 XSLT
index.html을
<html>
<head>
<script>
function loadXMLDoc(dname) {
xhttp = new XMLHttpRequest();
xhttp.open("GET", dname, false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult(source,styledoc,section) {
xml = loadXMLDoc(source);
xsl = loadXMLDoc(styledoc);
if (window.ActiveXObject) {
ex = xml.transformNode(xsl);
document.getElementById("display").innerHTML = ex;
}
else if (document.implementation && document.implementation.createDocument) {
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
xsltProcessor.setParameter(null,"section",section);
alert(xsltProcessor.getParameter(null,"section"));
resultDocument = xsltProcessor.transformToFragment(xml, document);
document.getElementById("display").appendChild(resultDocument);
}
}
</script>
</head>
<body onload="displayResult('test.xml','test.xslt','somevalue')">
<div id="display"/>
</body>
</html>
test.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:param name="section"/>
section=<xsl:value-of select="$section"/>
</xsl:template>
</xsl:stylesheet>
test.xml의
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<test/>
어디에서 스크립트의 firdt 부분에 매개 변수를 전달합니까? (IE 버전) – SergeS