This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: specifying a target for a hyperlink
- To: "Rachel Doolan" <racheldoolan at hotmail dot com>
- Subject: Re: [xsl] specifying a target for a hyperlink
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Mon, 26 Mar 2001 16:06:12 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <F120s4KWiGtXsL1c00g00005673@hotmail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Rach,
> hopefully someone will be able to help me solve this problem. I have
> hyperlinks in my xml document that I am applying xsl to and then
> opening them in a html page. This is all working find, but I want
> the new page (as a result of clicking the hyperlink to open in a new
> page. I can't get the target element of the hyperlink working
> properly. Currently I have the target as an attribute of the
> hyper;ink. I don't know if this is correct! maybe it would be easier
> if I contained the information in a separate tag? I have included
> snippets of the xml and xsl below. the information for calling the
> files is all in an asp file.
For a start, you should be using XSLT rather than the strange dialect
that's used in old versions of MSXML. Have a look at the MSXML FAQ at
http://www.netcrucible.com/xslt/msxml-faq.htm for a description.
Secondly, you shouldn't be using the xmlns attribute to do anything
aside from setting the default namespace of an element. This:
> <url xmlns="_blank"> http://www.vbxml.com/downloads/#software</url>
Fixes the default namespace to the namespace URI '_blank' (which I
think it not a legal namespace URI). Instead, use a different name,
like 'target' for the attribute:
<url target="_blank">http://www.vbxml.com/downloads/#software</url>
Finally, in order to aim an HTML link at another target, you need to
have a 'target' attribute on the HTML 'a' element. If you always want
it to open in another window, you could use:
<A HREF="{url}" TARGET="_blank"><xsl:value-of select="url" /></A>
If you want to use the 'target' attribute on the 'url' element to
determine the location, then you could use an attribute value template
to fix it:
<A HREF="{url}" TARGET="{url/@target}">
<xsl:value-of select="url" />
</A>
Note that this is just a shortened syntax from the spelt-out version,
which uses xsl:attribute:
<A>
<xsl:attribute name="HREF">
<xsl:value-of select="url" />
</xsl:attribute>
<xsl:attribute name="TARGET">
<xsl:value-of select="url/@target" />
</xsl:attribute>
<xsl:value-of select="url" />
</A>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list