This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Making dynamic href's in XSL
- To: xsl-list at mulberrytech dot com
- Subject: Re: Making dynamic href's in XSL
- From: Mike Brown <mike at skew dot org>
- Date: Wed, 31 May 2000 16:57:39 -0600 (MDT)
- Reply-To: xsl-list at mulberrytech dot com
> I'm trying to build a dynamic href like this:
> <xsl:if test="num_active_tasks>0"><a
> href="show_tasks.jsp?pcode=<xsl:value-of select="site_code"
> />project_number=<xsl:value-of select="number" />"><xsl:value-of
> select="number" /></a>
>
> but I get the error "The value of attribute "href" must not contain the
> '<' character. ". I understand what the error means, but I'm not sure
> how to get around it. Is there a better way of building a dynamic href?
Regarding the , 26 dec = 1A hex = the "SUBSTITUTE" C0 control
character, which is not allowed in an XML document. & (hex 26 = 38
decimal) is what you meant, for ampersand. Just use &. I'm going to
guess, though, that you tried doing that and didn't like the fact that
you saw '&' in the output. It's not a direct cause-and-effect,
though:
& or & or & in XML doc becomes & in stylesheet tree;
& in stylesheet tree is copied to the result tree; and finally
& in result tree is output via the XML or HTML output method as &.
The thing is, unless you are writing for a broken HTML user agent, you
*want* & in the output. This is a FAQ; see also
http://freespace.virgin.net/b.pawson/xsl/N7150.html#N11391
Regarding constructing an attribute, literal result elements are a
shortcut to using <xsl:element> and <xsl:attribute> instructions.
Sometimes it's easier to use the instructions:
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('show_tasks.jsp?pcode=',site_code,'&project_number=',number)" />
</xsl:attribute>
<xsl:value-of select="number"/>
</a>
Although you could also do
<a href="{concat(blahblahblah)}">
<xsl:value-of select="number"/>
</a>
- Mike
____________________________________________________________________
Mike J. Brown, software engineer at My XML/XSL resources:
webb.net in Denver, Colorado, USA http://www.skew.org/xml/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list