小编use*_*547的帖子

使用浏览器转换XML时,是否可以通过URL将参数传递给XSLT?

使用浏览器转换XML(谷歌浏览器或IE7)时,是否可以通过URL将参数传递给XSLT样式表?

例:

data.xml中

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<root>
    <document type="resume">
        <author>John Doe</author>
    </document>
    <document type="novella">
        <author>Jane Doe</author>
    </document>
</root>
Run Code Online (Sandbox Code Playgroud)

sample.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    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>
        <head>
            <title>List of <xsl:value-of select="$doctype" /></title>
        </head>
        <body>
            <xsl:for-each select="//document[@type = $doctype]">
                <p><xsl:value-of select="author" /></p>
            </xsl:for-each>
        </body>
    </html>
</<xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

xml browser xslt param transform

16
推荐指数
3
解决办法
1万
查看次数

标签 统计

browser ×1

param ×1

transform ×1

xml ×1

xslt ×1