Jump to content

Filtering xml for xslt through query string variable


Guest mnli19

Recommended Posts

Guest mnli19

I am working on a web site where I click on a link and it will navigate to a detail page to show the detail information related to the link. I have created the detail page using a xslt template and all contents in the detail page are comming from a xml file.To filter out only the relevant data from xml, I thought of passing a variable through query string and declare it as a xslt parameter in the detail xslt page. But I have no idea whether there is a way to pass variables through query string to the xslt page.I am new to xslt so It is greatly appreciated if someone can tell how this can be done or whether there is another easy way to do this?

Link to comment
Share on other sites

Assuming you run the XSLT transformation server-side with some code (e.g. ASP.NET or PHP or JSP or another server-side technology) then read out the query string as usually done with that server-side language/framework, then define a global parameter with xsl: param in your stylesheet and set that parameter before you run the transformation. How you do that depends entirely on the API your XSLT processor exposes.

Link to comment
Share on other sites

  • 5 months later...
Assuming you run the XSLT transformation server-side with some code (e.g. ASP.NET or PHP or JSP or another server-side technology) then read out the query string as usually done with that server-side language/framework, then define a global parameter with xsl: param in your stylesheet and set that parameter before you run the transformation. How you do that depends entirely on the API your XSLT processor exposes.
Hi.. I have a same problem, what the thread is explaining about.. I do not use any server-side scripting. My tool (test automation tool) generates an xml file which contains logs for a test suite. I made a html report, where it shows all the test cases in a table form. When I click on a particular test case, I expect to open that particular test case' logs should be open in a new window. I have given the link for each of the test case to a log_report.xml file with the test case name as a query parameter. Now the xsl file is expected to read the query parameter and filter the logs accordingly. Please let me know how can I read the query parameter in xsl file. I can't launch all the logs to the page and filter them using java-script. This leads to some performance issue. Thanks in advance.
Link to comment
Share on other sites

To my knowledge XSLT 1.0 has no means to access the input URI or to access any query string parameters. XSLT 2.0 has http://www.w3.org/TR/xpath-functions/#func-document-uri but I don't know any browser supporting XSLT 2.0. So inside the browser within XSLT 1.0 code I don't think there is a way to access the input URI or its query string parameters. I am not even sure whether a file: URI allows query string parameters.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...