This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please can somebody help me??
Thanks
Raj.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic