将 URL 变量传递到 xsl [英] Passing a URL variable into xsl

查看:28
本文介绍了将 URL 变量传递到 xsl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to pass a URL variable into xsl.

EG.http:www.somedomain.com/index.aspx?myVar=test&myVar2=anotherTest

EG. http:www.somedomain.com/index.aspx?myVar=test&myVar2=anotherTest

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

I'd like to be able to use the values of myVar and myVar2 in the logic of my xsl file. Thanks.

推荐答案

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

Sure, you can. Use xsl:param element in xsl:stylesheet element and pass parameter from your XSL engine.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="url"/>

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

Then use string-functions, e.g.:

<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=')"/>

这篇关于将 URL 变量传递到 xsl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆