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

RE: accessing URL parameters from XSL

Subject: RE: accessing URL parameters from XSL
From: John Pallister <jpallister@xxxxxxxxxxxx>
Date: Mon, 4 Nov 2002 08:38:26 -0500
nodelist.nextnode .url
If you want the parameter value from a URL and you are not using ASP,
client-side applications for example, then you could do
something like the following example.

(using E:\xslt\post\theData.xml?myparam=test1 as an example URL...)

Sample XSL: (doGraph.xsl)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:url="uri:find-url.org">

<xsl:param name="theParam" />
<xsl:variable name="xmlpath" select="url:findURL(.)" />

<msxsl:script language="JScript" implements-prefix="url">
<![CDATA[ 
     function findURL(nodelist) {      
       return nodelist.nextNode().url;      
     }     
]]>
</msxsl:script>

<xsl:template match="/">
<html>
<head>
</head>

 <body>
  <table>
   <tr><td>The URL is: <xsl:value-of select="$xmlpath" /></td></tr>
  </table>

   <!-- Draw a chart based on selection... -->
   <xsl:call-template name="bar-chart">
    <xsl:with-param name="theParam"
select="substring-after($xmlpath,'myparam=')" />
   </xsl:call-template>

  </body>
 </html>
</xsl:template>

<xsl:template name="bar-chart">
 <xsl:param name="theParam" />
  <table>
   <tr><td>The value is: <xsl:value-of select="$theParam" /></td></tr>
  </table>
  <!-- other code not listed for brevity... -->
</xsl:template>

</xsl:stylesheet>


Sample XML: (theData.xml)

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="doGraph.xsl" ?>
<data>
<test id="test1" score="10"/>
<test id="test3" score="12"/>
<test id="test1" score="10"/>
<test id="test2" score="16"/>
<test id="test4" score="12"/>
</data>


Then when the following is passed to the browser:

E:\xslt\post\theData.xml?myparam=test1

The following result is displayed:

The URL is: file:///E:/xslt/post/theData.xml?myparam=test1

The value is: test1	


John Pallister
jpallister@xxxxxxxxxxxx




-----Original Message-----
From: Viktor [mailto:viktoras@xxxxxx]
Sent: Monday, November 04, 2002 7:36 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  accessing URL parameters from XSL


Hello all,

I'm having problem with accessing URL parameters from XSL. How can I solve
this problem?
I'm using server-side Microsoft MSXML parser.

Viktor.



 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

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.