Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a link using xsl

Status
Not open for further replies.

NickMalloy

Programmer
Apr 15, 2005
68
US
I have an xml file created by a database and I want to create a html link using a xsl which contains values basically from the xml document. The problem is I don't know how to format the link. Basically it would be something like this
<xsl:value-of select="vendor"/>
<a id="<xsl:value-of select="vendor"/>" href="javascript:__doPostBack('<xsl:value-of select="vendor"/>','')"><xsl:value-of select="vendor"/></a>

How would I fill out this link so I can place those values in the link itself.
 
You need to study xsl:attribute, which you use to place attributes into unclosed elements in the output document. The general idea is:
Code:
<a>
<xsl:attribute name="id"><xsl:value-of select="vendor"/></xsl-attribute>
<xsl:attribute name="href"> [i]form href value here[/i]</xsl-attribute>
<xsl:value-of select="vendor"/>
</a>

Tom Morrison
[URL unfurl="true"]www.liant.com[/URL]
 
well I have seen the atribute tag. If I do my code like below I still don't know how to handle the href tag.

<a>
<xsl:attribute name="id"><xsl:value-of select="address"/></xsl-attribute>
<xsl:attribute name="href">javascript:__doPostBack('<xsl:apply templates select="address"/>','')
</xsl-attribute>
<xsl:value-of select="vendor"/>
</a>
 
any idea why the link wouldn't be showing up. Do I need to add something to the element to display it.

This part displays

<h1>Hello bobby</h1><a href=" but not the element information


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="/vendors/test1">
<TABLE>
<TR>
<xsl:value-of select="Vendor_x0020_Name"/>
<xsl:apply-templates/>
</TR>
</TABLE>>
</xsl:template>
<xsl:template match="test2">
<xsl:for-each select="address">
<h1>Hello bobby</h1>
<a href=" <xsl:element name="a">
<xsl:attribute name="id"><xsl:value-of select="address"/></xsl:attribute>
<xsl:attribute name="href">"><![CDATA[javascript:popupPic(']]><xsl:apply-templates select="address"/><![CDATA[','')]]></xsl:attribute>
<xsl:value-of select="vendor"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="address">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
 
Use:
Code:
<a id="{address}" href="javascript:PopupPic('{address}');">
  <xsl:value-of select="vendor"/>
</a>

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top