[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: parsing a variable from a ASP page to XSL file

Subject: RE: parsing a variable from a ASP page to XSL file
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Thu, 7 Jun 2001 22:32:46 +0100
proc.transform
Howard,
You have asked this question so many times in different ways and have been
given an answer. Let's try again.
You can't use the <%=someValue%> syntax in your XSL. To do that you it has
to go through the ASP processor.
You could use it if instead of an XSL file you had an ASP page that
delivered XSL i.e.

<%@ Language=JavaScript %>
<%
//calculate someValue
var someValue = "this is the some value string";
%>
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="/">
	<xsl:variable name="someValue><%=someValue%></xsl:variable>
	<xsl:value-of select="$someValue" />
</xsl:template>
</xsl:stylesheet>

To do that however you would need to specify the input to a transformation
as a full url i.e. stylesheet.load("http://localhost/stylesheet.asp"), That
way the ASP goes through the ASP processor and produces XSL with the
someValue in it. It also [expletive deleted] as a solution.

The other way to do this is to pass a parameter into the transformation.

   dim doc, stylesheet
   set doc = Server.CreateObject("msxml2.DOMDocument")
   set stylesheet = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
   set template = Server.CreateObject("MSXML2.XSLTemplate");
   xmlsource=Server.MapPath("XML/XML_1.xml")
   xslsource=Server.MapPath("XSL/XSL_1.xsl")
   doc.async = false
   stylesheet.async = false
   doc.load(xmlsource)
   stylesheet.load(xslsource)
   template.stylesheet = stylesheet
   set proc = tem.createProcessor()
   proc.addParameter("someValue", someValue) ' someValue="this is the some
value string"
   proc.input = doc
   proc.transform();
   str = proc.output;
   Response.Write(str)

Then within your stylesheet you have
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:param name="someValue" />
<xsl:template match="/">
	<xsl:value-of select="$someValue" />
</xsl:template>
</xsl:stylesheet>

If you want a default value for someValue you would do
<xsl:param name="someValue" select="'this is the some value string'" />

You can also do
   proc.output(Response);
   proc.transform();
to send the result of the transform directly to the Response object

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Howard Lim
>Sent: 07 June 2001 22:04
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject:
>
>
>I  am having some problem in parsing a variable from a ASP page to
>XSL file.
>this is the ASP page:
><%
>   dim doc, stylesheet
>
>   set doc = Server.CreateObject("msxml2.DOMDocument")
>   set stylesheet = Server.CreateObject("msxml2.DOMDocument")
>
>   xmlsource=Server.MapPath("XML/XML_1.xml")
>   xslsource=Server.MapPath("XSL/XSL_1.xsl")
>   doc.async = false
>   stylesheet.async = false
>
>   doc.load(xmlsource)
>   stylesheet.load(xslsource)
>
>   oParam=SelectSingleNode("//xsl:param[@name='param1']")
>   oparam.text="hello"
>
>
>   Response.Write(doc.transformNode(stylesheet))
>%>
>
>i have the following code in my XSL file to get the variable parse from ASP
>page.
><xsl:value-of select="item[$param1]"/>
>
>Is this the right way to parse a variable to XSL file???
>
>Please help, thank you guys.
>
>Howard (Kian-How) Lim
>howard.lim@xxxxxxxxxxxx
>847-934-8100 ext 104
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • [no subject]
    • Howard Lim - Thu, 7 Jun 2001 16:39:28 -0400 (EDT)
      • Chris Bayes - Thu, 7 Jun 2001 17:30:23 -0400 (EDT) <=
      • Andrew Welch - Mon, 11 Jun 2001 07:26:06 -0400 (EDT)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.