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

Re: Problem with <a> conversion

Subject: Re: Problem with <a> conversion
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 1 Jul 2002 10:42:57 +0100
php a href problem
Hi Ashu,

> i am trying to convert html to wml using xslt. when there is <a> tag
> in html i am trying to fetch the href of that and send that to my
> php program which is using xslt to convert it into wml.but it is
> giving error.
> i tried
>   <xsl:template match="div/a | center/a | p/a | ul/a | li/a | tr/a
> | td/a | th/a | table/a | font/a">
>           <xsl:variable name="url">
>           <xsl:value-of select="@href"/>
>           </xsl:variable>
>           <a 
> href="http://localhost/ashu/transform.php?url=@href">
>           <xsl:value-of select="."/></a>
>     </xsl:template>

What you're creating here are a elements like:

  <a href="http://localhost/ashu/transform.php?url=@href">
    ...
  </a>

In other words, the value of the url parameter passed to your
transform.php script is always the literal string '@href'. You want to
pass the *value* of the 'href' attribute instead, so use {}s around
the '@href' as follows:

<xsl:template match="a">
  <a href="http://localhost/ashu/transform.php?url={@href}">
    <xsl:apply-templates />
  </a>
</xsl:template>

(BTW, it's a good idea to use xsl:apply-templates rather than
xsl:value-of in the content of the a element in case the a element
contains other markup.)

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.