Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically querying XML using XSL

 
Sham Jowsaki
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
My requirement is to dynamically send a query to XML file depends upon the user's selection and get the output.
<result>
<row>
<uid>1</uid>
<name>sham</name>
</row>
<row>
<uid>2</uid>
<name>guru</name>
</row>
</result>
we are giving the option of getting the uid from the user. Assume the user enters the uid 1 and it should give the output "Sham".
How to do this using XSL / JSP. Expecting your valuable reply in the near future.
Thanks in advance.
Jowsaki

 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can pass uid as a parameter to your XSLT. How to do it depends on which XSLT processor you use, check documentation! Here is how you would do it with Xalan.
Then you have to declare this parameter in your XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="uid" select="'default value'"/>

And then you can use it like this (for example):
<xsl:template match = "result/row[./uid=$uid">

[This message has been edited by Mapraputa Is (edited July 31, 2001).]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic