This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Problem with <a> conversion
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "ashu t" <aashut at rediffmail dot com>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Mon, 1 Jul 2002 10:42:57 +0100
- Subject: Re: [xsl] Problem with <a> conversion
- Organization: Jeni Tennison Consulting Ltd
- References: <20020701091858.7743.qmail@mailFA12.rediffmail.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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