How do I embed a link into the text of an xml element's value?

Discussion in 'XML' started by Thomas P. Fuller, Sep 8, 2003.

  1. Hi,

    Thanks in advance for any help in this matter.

    I need to embed a link in the text portion of an xml element's value.

    For example,

    <some_element>
    Hi, my name is Tom, and you can find my webpage <URL
    link="www.xyz.net/~tom">here</URL>
    </some_element>

    so when this element is transformed into xhtml (using xsl, of course)
    we will see the link properly.

    If anyone can offer me a suggestion regarding how to tackle this
    issue, I would much appreciate it.

    Tom
     
    Thomas P. Fuller, Sep 8, 2003
    #1
    1. Advertising

  2. Thomas P. Fuller

    ted Guest

    If you include the protocol in your link attribute (eg,
    http://www.xyz.net/~tom) then you can use this:

    <xsl:template match="URL">
    <a href="{@link}"><xsl:apply-templates/></a>
    </xsl:template>

    Otherwise, you'll need to add the "http://" part like this:

    <xsl:template match="URL">
    <xsl:variable name="myUrl" select="concat('http://', @link)"/>
    <a href="{$myUrl}"><xsl:apply-templates/></a>
    </xsl:template>




    "Thomas P. Fuller" <> wrote in message
    news:...
    > Hi,
    >
    > Thanks in advance for any help in this matter.
    >
    > I need to embed a link in the text portion of an xml element's value.
    >
    > For example,
    >
    > <some_element>
    > Hi, my name is Tom, and you can find my webpage <URL
    > link="www.xyz.net/~tom">here</URL>
    > </some_element>
    >
    > so when this element is transformed into xhtml (using xsl, of course)
    > we will see the link properly.
    >
    > If anyone can offer me a suggestion regarding how to tackle this
    > issue, I would much appreciate it.
    >
    > Tom
    >
     
    ted, Sep 11, 2003
    #2
    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:
    959
    Kevin Spencer
    May 17, 2005
  2. Kathryn
    Replies:
    0
    Views:
    511
    Kathryn
    Jun 3, 2004
  3. jkflens
    Replies:
    2
    Views:
    1,548
    jkflens
    May 30, 2006
  4. Rick
    Replies:
    1
    Views:
    2,315
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 19, 2007
  5. HANM
    Replies:
    2
    Views:
    767
    Joseph Kesselman
    Jan 29, 2008
Loading...

Share This Page