简体   繁体   中英

Accessing XSL Variable with Classic ASP Code?

I am curious if there is anyway to access a XSL variable's data from ASP code. 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.

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. 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? I realize I might need to get creative and somehow retrieve "50" from the markup, similar to client-side DOM parsing. 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?

Assuming your XML Document is called mm_doc you could try something like:

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

and now you have an age variable with the same contents from your Xml Document.

You need to look into the MSXML documentation how to get the result of the transformation as a string (from either VBScript or JavaScript). I believe this is possible.

Then your XSLT transformation will just output the value of the variable (and nothing else).

As Dmitre said, you need to use MSXML, which is the XML plugin to ASP.

Tutorials and documentation are available at:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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