This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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 sucks 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@lists.mulberrytech.com
>[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Howard Lim
>Sent: 07 June 2001 22:04
>To: xsl-list@lists.mulberrytech.com
>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@us.net56.net
>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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]