简体   繁体   English

使用经典ASP代码访问XSL变量?

[英]Accessing XSL Variable with Classic ASP Code?

I am curious if there is anyway to access a XSL variable's data from ASP code. 我很好奇是否有从ASP代码访问XSL变量的数据。 First some background information... 首先是一些背景资料......

I have an ASPX page that is pulling data from an XML file, and using a separate classic ASP page for the "Response.write(mm_xsl.Transform())" aspect. 我有一个ASPX页面,它从XML文件中提取数据,并使用单独的经典ASP页面来表示“Response.write(mm_xsl.Transform())”方面。

In the classic ASP page that dictates the HTML output to the viewer, I have XSL variables used to print certain data from the XML file. 在指向HTML输出到查看器的经典ASP页面中,我有XSL变量用于从XML文件中打印某些数据。 For example I use this code to initialize the variable: 例如,我使用此代码初始化变量:

<xsl:variable name="age" select="person/Age" />

And then this code to print/echo the variable: 然后这段代码打印/回显变量:

{$age}

Let's say the value of the variable was 50. Is there anyway I can somehow pass "50" into an ASP variable? 假设变量的值为50. 无论如何,我可以以某种方式将“50”传递给ASP变量吗? I realize I might need to get creative and somehow retrieve "50" from the markup, similar to client-side DOM parsing. 我意识到我可能需要创造性并以某种方式从标记中检索“50”,类似于客户端DOM解析。 Is there any server-side parsing method similar to this? 是否有类似于此的服务器端解析方法?

Any other ideas? 还有其他想法吗? Any tips or relevant links are greatly appreciated. 非常感谢任何提示或相关链接。 Thanks! 谢谢!

Can't you just execute the same select you have in your xsl:variable statement in VBScript inline on the Classic Asp page? 难道你不能只在Classic Asp页面的VBScript内联中执行xsl:variable语句中的相同选择吗?

Assuming your XML Document is called mm_doc you could try something like: 假设您的XML文档名为mm_doc您可以尝试以下方法:

  dim age
  age = mm_doc.selectSingleNode("person/Age").text

and now you have an age variable with the same contents from your Xml Document. 现在你有一个年龄变量与你的Xml文档相同的内容。

You need to look into the MSXML documentation how to get the result of the transformation as a string (from either VBScript or JavaScript). 您需要查看MSXML文档,了解如何将转换结果作为字符串(来自VBScript或JavaScript)。 I believe this is possible. 我相信这是可能的。

Then your XSLT transformation will just output the value of the variable (and nothing else). 然后你的XSLT转换将只输出变量的值(而不是其他)。

As Dmitre said, you need to use MSXML, which is the XML plugin to ASP. 正如Dmitre所说,你需要使用MSXML,这是ASP的XML插件。

Tutorials and documentation are available at: 教程和文档可在以下位置获得:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM