...

Links with XSL

piz
09-13-2002, 11:49 AM
Hi!

I have an XML Dokument with this values:

<persons>
&nbsp;&nbsp;&nbsp;<name>PaulWB</name>
&nbsp;&nbsp;&nbsp;<website>http://www.yeti-networks.net</website>
&nbsp;&nbsp;&nbsp;<website>http://www.pizzahawai.de</website>
</persons>

Now i am creating an XSL-Stylesheet and I want to display the name in <h1> - that works perfectly.
<div><b><xsl:value-of select="name"/></b></div>

Now I want to display all elements called website with al link which directs to this website.

How do I do that??
<a href=""><xsl:value-of select="website"/>'</a>
Like this I get a link, but without Target.

Thx for all help!

Saludo, Paule

By the way... how do I include a stylesheet in the XML-File? Or do I have to use an external stylesheet?

jkd
09-13-2002, 12:14 PM
<a href="{website}">thelink</a>

piz
09-13-2002, 12:17 PM
No, sorry - it doesn't work.

Do I have to specify something special in the DTD?

Guardian23
09-13-2002, 04:18 PM
Well what I'd do, although it's a bit annoying, is this:

<script type="text/javascript">
var links= new Array()
var i=0
<xsl:foreach select="website">
links[i] = "\"" + <xsl:value-of select = "self::node()" /> + "\""
/*is that quite right? the self::node() part?*/
/*the quotes might not need to be placed in quotes, I can't quite remember how the quote thing worked out so they wouldn't create a reference to a non existent variable*/
i++
</xsl:foreach>
for (m=0; m<=links.length; m++) {
document.getElementById("div'sID").innerHTML += "<a href=\"" +links[m] + "\">" + links[m] + "</a>"
}
</script>
That's all I can think of... But I've tried using XSL links in JScript, and
usually something like this goes through ok.

Guardian

jkd
09-13-2002, 04:33 PM
<a href="{selector}">text</a> is a shortcut for:

<a>
<xsl:attribute name="href>
<xsl:value-of select="selector"/>
</xsl:attribute>
<xsl:text>text</xsl:text>
</a>

piz
09-14-2002, 12:28 AM
Thx!
That works!

The shortcut doesn't worked, no idea why not.

Saludo, piz

jkd
09-14-2002, 12:47 AM
What's your XSLT program? IE? Mozilla/Transfomiix? Xalan?

Wouldn't surpise me if IE failed to support it.

piz
09-18-2002, 09:52 AM
I tried it in IE6.

mpjbrennan
09-19-2002, 06:41 PM
The shortcut works for me in IE6.

patrick



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum