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. Advertisements

  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. Advertisements

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. Xenia
    Replies:
    4
    Views:
    619
    Xenia
    Nov 25, 2003
  2. Kathryn
    Replies:
    0
    Views:
    584
    Kathryn
    Jun 3, 2004
  3. Harry Zoroc
    Replies:
    1
    Views:
    1,189
    Gregory Vaughan
    Jul 12, 2004
  4. jkflens
    Replies:
    2
    Views:
    1,752
    jkflens
    May 30, 2006
  5. Rick
    Replies:
    1
    Views:
    2,957
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 19, 2007
  6. HANM
    Replies:
    2
    Views:
    1,527
    Joseph Kesselman
    Jan 29, 2008
  7. Mike N.
    Replies:
    3
    Views:
    688
    Joseph Kesselman
    Mar 17, 2008
  8. Percy Tambunan

    parsing multiple root element XML into text

    Percy Tambunan, May 9, 2014, in forum: Python
    Replies:
    19
    Views:
    211
    Peter Otten
    May 12, 2014
Loading...