如何将变量发送到xlst? [英] How to send a variable to xlst?

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

问题描述

我现在可以通过手动输入一个值得到我想要的结果..

< xsl:for-each select =" dataroot / sexoffenders [Zip ='31520']">

哪个课程只给我拉链31520 ......

但是我仍然无法弄清楚如何让url查询字符串发送一个值并将其设置为等于xsl中的变量...

我可以向页面发送查询字符串并使用vbscipt提取值但是如何将其添加到我的xsl ...

< xsl:for-each select =" dataroot / sexoffenders [Zip ='Variable']">

所以上面的变量将等于查询字符串中发送的变量。

推荐答案

XSLT处理器应该公开一个API,您可以在运行转换之前设置全局样式表参数。在.NET框架中,您需要创建一个 System.Xml.Xsl的实例。 XsltArgumentList ,调用AddParam方法来设置您在XSLT样式表中使用顶级xsl:param元素定义的任何参数,然后将该XsltArgumentList实例传递给用于运行XslCompiledTransform实例的Transform方法。转换。
因此在样式表中你可以使用例如

An XSLT processor is supposed to expose an API where you can set global stylesheet parameters before you run the transformation. In the .NET framework you need to create an instance of System.Xml.Xsl.XsltArgumentList , call the AddParam method to set any parameters you have defined in the XSLT stylesheet with top-level xsl:param elements, and then pass in that XsltArgumentList instance to the Transform method of an XslCompiledTransform instance you use to run the transformation.
So in the stylesheet you would use e.g.
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:param name="foo"/>

  <xsl:template match="/">
    <xsl:for-each select="root/bar[baz =


foo]">
...
< / xsl:for-each>
< / xsl:template>

< / xsl:stylesheet>
foo]"> ... </xsl:for-each> </xsl:template> </xsl:stylesheet>


定义名为foo的全局参数,然后可以将其用作

to define a global parameter named foo that you can then use as


你的XPath表达式中的foo。然后,您的.NET代码将使用XsltArgumentList并调用AddParam("foo",""",Response.QueryString("whatever"))来传递查询字符串中收到的值。
foo in your XPath expressions. Your .NET code would then use an XsltArgumentList and call AddParam("foo", "", Response.QueryString("whatever")) to pass in a value received in the query string.


这篇关于如何将变量发送到xlst?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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