File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes xsl: create href for one tag with value in param among multiple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl: create href for one tag with value in param among multiple" Watch "xsl: create href for one tag with value in param among multiple" New topic
Author

xsl: create href for one tag with value in param among multiple

raj agastya
Greenhorn

Joined: Nov 27, 2001
Posts: 22
Hi,
My generated XML doc structure looks like the following:

I need to create href (link) pointing to another JSP with a parameter of its value from the first <col> only. I have written the following XSL but, it
creates wrong output. Please help me creating the correct XSL.
I want to create a link to editProd.jsp?id=3400 for only this tag: <col>3400</col> and rest of the other columns should be just displayed with created as links.

Thank you.
Raj.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Show us exactly what you want the output to look like, then we can help you with the XSL to generate it.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
raj agastya
Greenhorn

Joined: Nov 27, 2001
Posts: 22
Hi,
I am sorry I wasn't able to put it properly. I'll try again.
In my xml document, information under <Row> tag corresponds to one record in the database, and each <col> represent different columns within it.
I first need to display all the products, basically all <Row> data in products.jsp that leads to editProduct.jsp when the name link is pressed.
Only 'name' represented by second <col> tag value should be displayed as a href link where as, rest of them as plain text.
The href link calls another JSP called editProduct.jsp where I need to pass all the <col> data as parameters values.
So for example, my href link for the below <Row> should be like:
editProduct.jsp?id=3400&name="Black and white"&stat="orderable"&price="300"

Hope I am clearer now. Thank you for your time and help.
Raj.
raj agastya
Greenhorn

Joined: Nov 27, 2001
Posts: 22
Hi,
Please can somebody help me??
Thanks
Raj.
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
First, your XML is not correct, you need to close <data> and <Row> tags:

Second, in the first for-each operator, the sequence of nodes should follow your input document hierarchy, i.e. not
<xsl:for-each select="/RowSet/data/row">
but
<xsl:for-each select="RowSet/Row/data">
Then, instead of second for-each cycle, you can access your col elements via col[n] construct, where n is 1, 2, 3 etc. We want to use them as attribute value, for this reason we will use so-called "attribute-value template", which is a shorthand for xsl:value-of element. Practically it means we put col[n] in curly braces.
If I understood your requirements correctly, it will be

[ July 30, 2003: Message edited by: Mapraputa Is ]

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsl: create href for one tag with value in param among multiple