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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT help

Status
Not open for further replies.

LOW

Programmer
Sep 27, 2000
45
0
0
US
I'm trying to add a little more logic to the following template named "drawcell" specifically to the "target" attribute within <a>. If the value within the DOCUMENT_URL column row contains "sirepub", I'd like the value to be "_blank", otherwise the value should be "_self". The param $document_url has been defined as DOCUMENT_URL (a column name in a SQL database). Currently, the results being returned show the target within the <a> as target="". Neither _blank or _self are being added. Is this even doable using XSLT? Here's my code.

<xsl:template name="drawcell">
<xsl:param name="meta"/>
<xsl:param name="linkfield"/>
<xsl:param name="document_url"/>
<td valign="top">
<xsl:if test="$linkfield=$meta">
<a>
<xsl:attribute name="href">
<xsl:value-of select="MT[@N='DOCUMENT_URL']/@V"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:choose>
<xsl:when test="$meta=$document_url and contains(/@value, 'sirepub')">
<xsl:value-of select="_blank" />
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="_self"/>
</xsl:eek:therwise>
</xsl:choose>
</xsl:attribute>
</a>
</xsl:if>
</td>
</xsl:template>
 
> Neither _blank or _self are being added. Is this even doable using XSLT?
Sure, it is doable.

><xsl:value-of select="_blank" />
><xsl:value-of select="_self" />
Here is the problem. On the face of it, it means the text of the child _blank or _self under the context node. You certainly do not mean to be so. You mean literal string.
[tt]<xsl:value-of select="[red]'[/red]_blank[red]'[/red]" />
<xsl:value-of select="[red]'[/red]_self[red]'[/red]" />[/tt]
 
Thank you. Now at least I'm returning target="_self" however that value is returned for all records not just the ones contained "sirepub" in the DOCUMENT_URL column. I believe my problem is with the way I'm trying to evalute the value in DOCUMENT_URL.

<xsl:when test="$meta=$document_url and contains(/@value, 'sirepub')">

Is XSLT capable of evaluating values within a SQL database?
 
Correction on my last message. I want the records containing 'sirepub' in the DOCUMENT_URL to have the target attribute value of "_blank". Currently, all records returned have the target value of "_self" including those containing "sirepub".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top