Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Links with XSL

  1. #1
    piz
    piz is offline
    Regular Coder
    Join Date
    Jul 2002
    Location
    Barcelona
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Links with XSL

    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.
    Code:
    <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??
    Code:
    <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?
    Last edited by piz; 09-13-2002 at 11:51 AM.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    <a href="{website}">thelink</a>

  • #3
    piz
    piz is offline
    Regular Coder
    Join Date
    Jul 2002
    Location
    Barcelona
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, sorry - it doesn't work.

    Do I have to specify something special in the DTD?

  • #4
    New Coder
    Join Date
    Jul 2002
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by Guardian23; 09-13-2002 at 04:21 PM.

  • #5
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    <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>

  • #6
    piz
    piz is offline
    Regular Coder
    Join Date
    Jul 2002
    Location
    Barcelona
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thx!
    That works!

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

    Saludo, piz

  • #7
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    What's your XSLT program? IE? Mozilla/Transfomiix? Xalan?

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

  • #8
    piz
    piz is offline
    Regular Coder
    Join Date
    Jul 2002
    Location
    Barcelona
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried it in IE6.

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    Newcastle, England
    Posts
    178
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The shortcut works for me in IE6.

    patrick


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •