Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi Guys, Howzit going? I'm havi

Status
Not open for further replies.

msturges

Programmer
Mar 29, 2001
32
ZA
Hi Guys,

Howzit going?
I'm having trouble with an XSL file that I'm trying to code.
Is there a way that one could read url parameter variables into an xsl file?

This is what I have tried:

ASP File which links to XML file.

xmlReadDocument = strPath & "/inbox/" & CStr(serviceRef) & ".xml?sRef=" & serviceRef

response.redirect(xmlReadDocument)

XML file:

<?xml version=&quot;1.0&quot;?>
<?xml-stylesheet href=&quot;WAstylesheet.xsl&quot; type=&quot;text/xsl&quot;?>
<order no=&quot;0002&quot;>
<Sender>Karim Abdul Jabbar</Sender>
<orderNo>5005</orderNo>
<orderDate>2002/01/22</orderDate>
<orderPoint>6004930005005</orderPoint>
<invoicePoint>6004930001575</invoicePoint>
<supplierPoint>6004931241000</supplierPoint>
<deliveryDates>
<earliest>2002/01/22</earliest>
<latest>2002/01/31</latest>
</deliveryDates>
<transactionCode>Transaction Code </transactionCode>
<narrative>Order Narrative 1</narrative>
<narrative>Order Narrative 2</narrative>
<narrative>Order Narrative 3</narrative>
<Product id=&quot;555-000004&quot;>
<Prod_Code>555-000004</Prod_Code>
<Colour>Blue</Colour>
<Qty_Ordered>4</Qty_Ordered>
<Size>Large</Size>
<Price>R40.00</Price>
<sellPrice>R46.00</sellPrice>
<prTotal>R160.00</prTotal>
</Product>
<orTotal>210</orTotal>
</order>


XSL File

<xsl:script language=&quot;VBScript&quot;>
<![CDATA[
function sref()
sref= CStr(request.querystring(&quot;sRef&quot;))
end function
]]>
</xsl:script>

In the code above(XSL), note that I'm trying to use VBScript's 'request' object. This however doesn't seem to be supported by XML/XSL, cause I get the following error:

Microsoft VBScript runtime error Object required: 'request' line = 3, col = 2 (line is offset from the start of the script block). Error returned from property or method call.

Any input would be greatly appreciated.

thanks


 
Hi JJR,

I tried the following:

XSL file:

<xsl:param name=&quot;sRef&quot;>default value</xsl:param>

<xsl:template match=&quot;/&quot;>
sRef = <xsl:value-of select=&quot;$sRef&quot;/>
</xsl:template>


-----

ASP File:

xmlReadDocument = &quot;xmlFile.xml?sRef=1234&quot;
response.redirect(xmlReadDocument)


But when I view the document from a browser it displays the following:

sRef = default value

ie. The parameter value in the url is not replacing the existing value of the parameter within the xsl file.

What I want is for it to display this:

sRef = 1234

Any reason why this is not happening?

Please help!!!!

thanks






 
Hmmmm...

Strange...

It should work and replace the default value of the param in your stylesheet. Try making a dummy xml file (any xml file will do) and assign the stylesheet to it. Then open this dummy xml in your browser with the querystring behind it. That way you can be sure the problem isn't in your asp code but has to be in your browser.

If you get stuck post all the code of your stylesheet, so we can have a look at it.

I can also give you some asp code so you can perform the transformation server-side (with passing the param) and then you can write the result to the screen.

Good luck!

Jordi Reineman
 
Hi Jordi,

At the moment I'v got the following(simplified):

MyASP.asp
=========

<%@LANGUAGE=VBSCRIPT%>
<%
response.buffer=true
response.redirect(&quot;myxml.xml?testVar=Sturges&quot;)
%>

MyXML.xml
=========

<?xml version=&quot;1.0&quot;?>
<?xml-stylesheet href=&quot;MyXSL.xsl&quot; type=&quot;text/xsl&quot;?>
<root>
...
...
...
...
</root>

MyXSL.xsl
=========

<?xml version='1.0'?>
<xsl:stylesheet version=&quot;1.0&quot; exclude-result-prefixes=&quot;xsl msxsl&quot; xmlns:xsl=&quot; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; xmlns:sql=&quot;urn:schemas-microsoft-com:xml-sql&quot; xmlns:xsi=&quot;
(Note that the ';' character at the end of the above line is not really in the code, it seems to be assigned within this form text box)

<xsl:param name=&quot;testVar&quot;>null</xsl:param>

<xsl:template match=&quot;/&quot;>
testVar is equal to <xsl:value-of select=&quot;$testVar&quot;/>
</xsl:template>

</xsl:stylesheet>



I've created an 'htm' file which then links to the 'MyASP.asp' page, which, (according to my knowledge), shoulde redirect the browser to the 'MyXML.xml' file while passing the value 'Sturges' as the url Paramenter.

But when I browse the file the value of testVar stays [red]'null'[/red], indicating that the value from the url is not being assigned (or something).

Am I maybe missing something vital??

Thanks for the help!!
Much Appreciated

Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top