• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
raj agastya
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us exactly what you want the output to look like, then we can help you with the XSL to generate it.
 
raj agastya
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please can somebody help me??
Thanks
Raj.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic