I want to preload an XML document (called XMLParam) and pass it to an XSLT processing of another document (oXML), as a parameter, using setParameter.
However, the XSLT does not handle it as a node, nodelist or anything, just reports [object Element]
oXML = XMLDoc_load(sXMLURL);
oXMLParam = XMLDoc_load(sXMLParamURL);
oXSLT = XMLDoc_load(sXSLTURL);
var oXSLTProcessor = new XSLTProcessor();
oXSLTProcessor.importStylesheet(oXSLT);
oXSLTProcessor.setParameter(null,"oDocument",oXMLParam.documentElement);
var oResultDoc = oXSLTProcessor.transformToFragment(oXML, document);
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<x开发者_开发问答sl:param name="oDocument"/>
<xsl:template match="/"><p>Parameter:<xsl:copy-of select="$oDocument"/></p></xsl:template>
Consider to pass in the URL of the document you want to load as the parameter value, then use the XSLT document
function to load the document with XSLT. That way it might be possible to achieve what you want.
I am afraid http://www.w3.org/TR/xslt#top-level-variables does not really specify in detail what kind of types a processor needs to support to be passed in from an application to a stylesheet. It sounds as if Chrome simply calls toString on the DOM element node you pass in and then XSLT works with a string and not with a node-set as you want it.
精彩评论