当使用浏览器转换XML(Google Chrome或IE7)时,是否可以通过URL将参数传递给XSLT样式表
例如:
data.xml
<;?xml version=“1.0”encoding=“UTF-8”?>;
<;?xml样式表type=“text/xsl”href=”https://stackoverflow.com/questions/65926/sample.xsl“?>;
<;根>;
<;文档类型=“简历”>;
<;作者>;无名氏</作者>;
</文件>;
<;文档类型=“novella”>;
<;作者>;无名氏</作者>;
</文件>;
</根>;
sample.xsl
<;?xml version=“1.0”encoding=“UTF-8”?>;
<;xsl:样式表
version=“1.0”
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform"
xmlns:fo=”http://www.w3.org/1999/XSL/Format“>;
<;xsl:output method=“html”/>;
<;xsl:template match=“/”>;
<;xsl:param name=“doctype”/>;
<;html>;
<;头>;
<;标题>;列表<;xsl:select=“$doctype”/>;的值</标题>;
</头>;
<;车身>;
<;xsl:for each select=“//document[@type=$doctype]”;
<;p>&书信电报;xsl:select=“author”/></p>;
</xsl:for each>;
</车身>;
</html>;
</&书信电报;xsl:stylesheet>;
不幸的是,没有-您不能仅在客户端将参数传递给XSLT。
web浏览器从XML中获取处理指令;并使用XSLT直接转换它
可以通过querystring URL传递值,然后使用JavaScript动态读取它们。但是,这些不能在XSLT(XPath表达式)中使用,因为浏览器已经转换了XML/XSLT。它们只能在呈现的HTML输出中使用