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

Re: Inserting into a href tag

Subject: Re: Inserting into a href tag
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 4 Nov 2000 10:47:02 +0000
us1234
Chris,

> This is the XML file:
>
> <product>
>    <prodnum>
>       US1234
>    </prodnum>
> </product>
>
> This value will need to be used in many places, such as this inside my XSL 
> file:
>
> <A href="/details/{prodnum}">
[snip]
>
> I'm get output that looks like this:
>
> <A href="/details/%0A%20US1234%0A%20"}
[snip]
>
> What am I doing wrong here?  I've tried references like {product/prodnum}, 
> but that returns a blank.  Is there something outside of this code that I 
> need to declare?

The HTML output method is a clever little beast and knows that the
content of an 'href' attribute is a URL, and should be escaped like
one.  You have four escaped characters that are making your URL look
funny: two %0A (line breaks) and two %20 (spaces).  This is because
the value for the href that you're putting in is:

"
 US1234
 "

which is due to the formatting of your source XML.
 
You can get rid of line breaks and spaces from the value using the
normalize-space() function.  So try:

<A href="/details/{normalize-space(prodnum)}">...</A>

instead.  Or change your source so that it's:

<product>
  <prodnum>US1234</prodnum>
</product>

I hope that helps,

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.