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

Re: How do I generate an HTML anchor element?

Subject: Re: How do I generate an HTML anchor element?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 28 Oct 2002 14:19:19 +0000
xslt html anchor
Hi Jim,

> I have checked the FAQ's for mulberrytech, jennitennison, and
> Pawson's without any success. I must not be inputting the search
> criteria correctly.

The XSLT FAQs tend not to go into XML well-formedness problems, which
is what you're experiencing. Remember that XSLT stylesheets must be
well-formed XML documents -- use an XML parser or editor to locate the
syntax errors first (so that, for example, IE will display your
stylesheet as a nice collapsible tree), then start worrying about XSLT
problems.

> All I'm trying to do is generate an HTML anchor tag. I all the
> combinations get syntax errors .
>
> Here is where I originally started:
> <table>
> <tr>
>     <td>
>          <a HREF="SomeURL.jsp?FirstName=FirstValue&SecondValue
> =<xsl:value-of select="AAA/BBB"/>>        <xsl:value-of select="DDD"/>
>          </a>
>     </td>
>    </tr>
> </table>

This isn't well-formed XML because of two things. First, you've got an
unescaped & in there when you shouldn't have. Second, you've got an
<xsl:value-of> element inside an attribute value. Usually when people
try the latter it's because they haven't heard of attribute value
templates -- use {}s in an attribute value to say "insert this value
here". In your case try:

<a HREF="SomeURL.jsp?FirstName=FirstValue&amp;SecondValue={AAA/BBB}">
  <xsl:value-of select="DDD" />
</a>

Note the escaped & as well as the attribute value template. A longer
alternative would be to create the HREF attribute using
<xsl:attribute>:

  <a>
    <xsl:attribute name="HREF">
      <xsl:text>SomeURL.jsp?FirstName=FirstValue&amp;SecondValue=</xsl:text>
      <xsl:value-of select="AAA/BBB" />
    </xsl:attribute>
    <xsl:value-of select="DDD" />
  </a>

XSLT isn't like ASP or JSP -- you can't just insert XSLT instructions
wherever you like and have the result inserted textually into the
document. Instead, you're creating a tree of element, attribute and
text nodes (and some others, but those are the main ones). If you keep
that in mind, the solutions are often easier to find.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.