Menu

#13 XSLT for ULink

closed-rejected
nobody
None
5
2001-07-09
2001-07-08
No

Just wanted to share my ULink XSLT transform for HTML
pages. It strips off the schema component of the URL
and the trailing slash to make it look prettier

<xsl:template match="ulink"><a><xsl:attribute
name="href"><xsl:value-of
select="@url"/></xsl:attribute>
<xsl:if test="string-length(.) > 0"><xsl:value-of
select="."/></xsl:if>
<xsl:if test="string-length(.) = 0">
<xsl:if test="substring(@url, string-length(@url))
= '/'">
<xsl:value-of select="substring-after(substring
(@url, 1, string-length(@url) - 1), '://')"/>
</xsl:if>
<xsl:if test="substring(@url, string-length
(@url)) != '/'">
<xsl:value-of select="substring-after
(@url, '://')"/>
</xsl:if>
</xsl:if>
</a></xsl:template>

Discussion

  • Norman Walsh

    Norman Walsh - 2001-07-09
    • status: open --> closed-rejected
     
  • Norman Walsh

    Norman Walsh - 2001-07-09

    Logged In: YES
    user_id=81663

    I like the full format better, but in any event for your
    local test, you should look more closely at the current
    ulink template. Your use of string-length may not always
    work and using value-of instead of apply-templates means
    that inline markup in the ulink won't be processed.

     

Log in to post a comment.