472,353 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Pass Query String Value to XSL for filtering

All,

I am relatively new to XML and I have what may sound like a dumb
question. I want to pass a query string variable to my xml document
and filter the output based on that variable. For example, if I type
in www.mysite.com?geid=0000123468 I want to display only
AccessReview/Report where GEID='0000123468'. I appreciate any help you
can provide.

Corey

Here is the code for my request.

---------------------------------------------------
XML file
---------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="AccessReview.xsl"?>
<Records>
<AccessReview>
<Report>Corey's Report</Report>
<GEID>0003620195</GEID>
</AccessReview>
<AccessReview>
<Report>Kim's Report #1</Report>
<GEID>0000123468</GEID>
</AccessReview>
<AccessReview>
<Report>Kim's Report #2</Report>
<GEID>0000123468</GEID>
</AccessReview>
<AccessReview>
<Report>Kim's Report #3</Report>
<GEID>0000123468</GEID>
</AccessReview>
<AccessReview>
<Report>Ron's Report #1</Report>
<GEID>0000204138</GEID>
</AccessReview>
<AccessReview>
<Report>Ron's Report #2</Report>
<GEID>0000204138</GEID>
</AccessReview>
<AccessReview>
<Report>Ron's Report #3</Report>
<GEID>0000204138</GEID>
</AccessReview>
<AccessReview>
<Report>Ron's Report #4</Report>
<GEID>0000204138</GEID>
</AccessReview>
</Records>

---------------------------------------------------
XSL file
---------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head><title>Access Review</title>
</head>

<body>
<pre>
<xsl:for-each select="Records/AccessReview[GEID=variableName]">
<xsl:value-of select="Report"/>
</xsl:for-each>
</pre>
</body>
</html>

</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #1
4 14152


Corey wrote:

I am relatively new to XML and I have what may sound like a dumb
question. I want to pass a query string variable to my xml document
and filter the output based on that variable. For example, if I type
in www.mysite.com?geid=0000123468 I want to display only
AccessReview/Report where GEID='0000123468'.
Write a server-side script in the language of your choice (or the one
your server supports) to read out the query string first, then create an
XSLT processor, pass in the query string value as a parameter to the
stylesheet, run the transformation and send the result back to the browser.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
A global stylesheet parameter is defined as
<xsl:param name="GEID" />
and then used as
<xsl:for-each select="Records/AccessReview[GEID=variableName]">


<xsl:for-each select="Records/AccessReview[GEID=$GEID]">

How you pass parameters to a stylesheet depends on the processor used,
usually there is an API alike
processor.setParam(name, value)
respectively
processor.setParam(name, namespace, value)
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Thanks Martin. Is there any way to do it without using a server side
script? I'm a .NET guy but this project requires the use of a Unix
server which I know nothing about, including PHP and perl. Is there
any other way to do this? I appreciate your help.

Corey

Jul 20 '05 #3


Corey wrote:
Is there any way to do it without using a server side
script? I'm a .NET guy but this project requires the use of a Unix
server which I know nothing about, including PHP and perl. Is there
any other way to do this?


If you want to ensure visitors see the result of the XSLT transformation
then you have to do the transformation on the server, whether you want
to read the query string or not, browser support for XSLT
transformations is certainly not something to rely on on the web in general.
If you are sure you have only IE 6/Win clients (or IE 5/5.5 Win clients
with an updated version of MSXML 3 installed) or Mozilla 1.2 and later
clients with scripting enabled then of course you could start with an
HTML page with Javascript reading the query string and then doing the
transformation client-side triggered by script.
Sarissa is a library which can help with that:
<http://sarissa.sourceforge.net/doc/>
But as said, on the web in general relying on client-side XSLT is not a
solution, you need to provide alternatives then anyway.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
I completely agree with your thoughts. This is just a band-aid
approach until an enterprise application can be built. Thanks for your
help.

Corey

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Satrapa | last post by:
I have a table from which I'm trying to extract certain information. For historical reasons, we archive every action on a particular thing ('thing'...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why...
1
by: Eskil | last post by:
Hi I have a form that supplies my query with information on two different variables. The form uses a lookup to display a list of 5 different...
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a...
3
by: Zlatko Matić | last post by:
Hello. I'm wondernig what is happennig whith saved pass-through queries nested in regular JET query if regular JET query just filtrates result by...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to...
0
by: cephal0n | last post by:
Hi All! I have two table tblHome1, contains all the unique PinNo and tblHome2 contains a duplicated PinNo and description. I put an automatic...
17
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.