Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with XSL.

 
Cristian Cardenas
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using XSL to create a table with the details of one invoice, and I need to put an href in each row with two parameters (invoiceId, and productId) to the servlet which is going to do the row delete. I can find the way to generate the URL, because I can't concatenate the parameters to the rest of the URL. The code is like the following one.
<td align="right">
<xsl:for-each select="invoiceId">
<xsl:apply-templates/>
</xsl:for-each>
</td>
<td align="right">
<xsl:for-each select="productId">
<xsl:apply-templates/>
</xsl:for-each>
</td>
<td align="right">
<xsl:for-each select="amount">
<xsl:apply-templates/>
</xsl:for-each>
</td><td><a href="deleteDetail.do?invoiceId=<PARAMETER 1>&productId=<PARAMETER 2>">Delete</a></td>
Thanks in advance.
Cristian.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can declare your invoiceId, and productId as parameters:
<xsl:param name="invoiceId">1234</xsl:param>
<xsl:param name="productId">4321</xsl:param>
(here I put default values, but you can pass them to your XSLT)
and then use an attribute-value template {$parameter-name}to read parameter values:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="invoiceId">1234</xsl:param>
<xsl:param name="productId">4321</xsl:param>
<xslutput method="html"/>
<xsl:template match="/">
<a href="deleteDetail.do?invoiceId={$invoiceId}&amp;productId={$productId}">Delete</a>
</xsl:template>
</xsl:stylesheet>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic