Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Making dynamic href's in XSL

From: Mike Brown <mike@-------->
To:
Date: 5/31/2000 10:58:00 AM
> 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent