将URL变量传递给xsl

Str*_*_99 5 xml xslt xpath xslt-1.0

是否可以将URL变量传递给xsl.

例如.HTTP:www.somedomain.com/index.aspx myVar的=试验&myVar2 = anotherTest

我希望能够在我的xsl文件的逻辑中使用myVar和myVar2的值.谢谢.

Kir*_*huk 5

你当然可以.xsl:paramxsl:stylesheet元素中使用element 并从XSL引擎传递参数.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="url"/>
Run Code Online (Sandbox Code Playgroud)

然后使用字符串函数,例如:

<xsl:variable name="right-part" select="substring-after($url, 'myVar=')"/>
<xsl:value-of select="substring-before(substring-before($right-part, 'myVar2='), '&amp;')"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="substring-after($right-part, 'myVar2=')"/>
Run Code Online (Sandbox Code Playgroud)