This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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)
Joined: Nov 27, 2001
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.
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 ]