[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Making dynamic href's in XSL

Subject: Re: Making dynamic href's in XSL
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 31 May 2000 16:57:39 -0600 (MDT)
href in xsl
> 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"
> />&#0026;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 &#0026;, 26 dec = 1A hex = the "SUBSTITUTE" C0 control
character, which is not allowed in an XML document. &#x26; (hex 26 = 38
decimal) is what you meant, for ampersand. Just use &amp;. I'm going to
guess, though, that you tried doing that and didn't like the fact that
you saw '&amp;' in the output. It's not a direct cause-and-effect,
though:

  &#38; or &#x26; or &amp; 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 &amp;.

The thing is, unless you are writing for a broken HTML user agent, you
*want* &amp; 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,'&amp;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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.