Re: link

Discussion in 'XML' started by Christophe Jacquet, Jul 3, 2003.

  1. Hi,

    > How can i display <url> as hyperlink? tnx


    I personaly use a template like this:

    <xsl:template match="url">
    <a href="{text()}">
    <xsl:value-of select="text()" />
    </a>
    </xsl:template>


    Regards.


    --
    Christophe Jacquet
    http://jacquetc.free.fr/
     
    Christophe Jacquet, Jul 3, 2003
    #1
    1. Advertising

  2. EniGMistA wrote:
    > in my code?
    > where i must put it?


    You have to do two things:
    - insert my template for "url" as a sibling of your template for
    "curriculum" (you will have two templates in your stylesheet),
    - replace your ' <xsl:value-of select="url" /> ' with '
    <xsl:apply-templates select="url" /> ' in order to call the appropriate
    template.

    To make things clear, here is your modified XSL file:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="curriculum">
    <html>
    <head> [...] </head>
    <body>
    <div id="testa">
    <ul type="square">
    <xsl:for-each select="lavori">
    <xsl:sort select="nome"/>
    <li>
    <em><xsl:value-of select="nome" /></em><br />
    URL:
    <xsl:choose>
    <xsl:when test="url=''">Non disponibile</xsl:when>
    <xsl:eek:therwise>
    <xsl:apply-templates select="url" />
    </xsl:eek:therwise>
    </xsl:choose>
    <br />
    Descrizione: <xsl:value-of select="descrizione" /><br />
    Tecnologia: <xsl:value-of select="tecnologia" />
    </li>
    </xsl:for-each>
    </ul>
    </div>
    </body>
    </html>
    </xsl:template>


    <xsl:template match="url">
    <a href="{text()}">
    <xsl:value-of select="text()" />
    </a>
    </xsl:template>


    </xsl:stylesheet>


    Instead of creating a template for "url", it must be possible to put the
    code directly into the main template, but I think it is better to build
    modular stylesheets.

    --
    Christophe Jacquet
    http://jacquetc.free.fr/
     
    Christophe Jacquet, Jul 3, 2003
    #2
    1. Advertising

  3. Christophe Jacquet

    EniGMistA Guest

    tnx a lot. Now i have understand the templates :))
    text() is a function?

    --
    .__.
    NN""4N
    N 4)
    .N) EniGMistA
    (NF`
    ()
    _.
    (NN
     
    EniGMistA, Jul 3, 2003
    #3
  4. EniGMistA wrote:

    > text() is a function?


    Not exactly: it is a "location step" that selects all text-node
    children of the current node.


    --
    Christophe Jacquet
    http://jacquetc.free.fr/
     
    Christophe Jacquet, Jul 4, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    865
    Kevin Spencer
    May 17, 2005
  2. Graham Thomson
    Replies:
    3
    Views:
    468
    Eki Y. Baskoro
    Dec 18, 2003
  3. Dan M
    Replies:
    5
    Views:
    428
  4. kolesdz
    Replies:
    9
    Views:
    538
    Blinky the Shark
    Aug 22, 2007
  5. Marina Limeira

    LINK with another link

    Marina Limeira, Feb 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    119
    Marina Limeira
    Feb 7, 2006
Loading...

Share This Page