How can I include the attribute?

Discussion in 'XML' started by Zhou Lei, Feb 28, 2005.

  1. Zhou Lei

    Zhou Lei Guest

    Hello now I'm writing the XSL to transform the XML to an html file, and some
    xml elements are:

    <user login="loginname">
    <name>James Cook</name>
    </user>

    I need to include the login attribute value in my target HTML file, and
    concatenate the value with @my.addr.com. So my target HTML code will be

    <a href="mailto:">
    James Cook
    </a>

    Anyone can give me some suggestions on it, thank you.
     
    Zhou Lei, Feb 28, 2005
    #1
    1. Advertising

  2. Zhou Lei

    Joris Gillis Guest

    Tempore 18:24:34, die Monday 28 February 2005 AD, hinc in foro {comp.text.xml} scripsit Zhou Lei <>:

    > <user login="loginname">
    > <name>James Cook</name>
    > </user>
    >
    > I need to include the login attribute value in my target HTML file, and
    > concatenate the value with @my.addr.com. So my target HTML code will be
    >
    > <a href="mailto:">
    > James Cook
    > </a>


    You can use:
    a) an attribute value template:
    <xsl:template match="user">
    <a href="mailto:{@login}@my.addr.com">
    <xsl:apply-templates/>
    </a>
    </xsl:template>

    or b)explicit attribute node creation:
    <xsl:template match="user">
    <a>
    <xsl:attribute name="href">
    <xsl:text>mailto:</xsl:text>
    <xsl:apply-templates select="@login"/>
    <xsl:text>@my.addr.com</xsl:text>
    </xsl:attribute>
    <xsl:apply-templates/>
    </a>
    </xsl:template>



    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Fiat W3C in tenebris
     
    Joris Gillis, Feb 28, 2005
    #2
    1. Advertising

  3. Zhou Lei wrote:

    > Hello now I'm writing the XSL to transform the XML to an html file, and some
    > xml elements are:
    >
    > <user login="loginname">
    > <name>James Cook</name>
    > </user>
    >
    > I need to include the login attribute value in my target HTML file, and
    > concatenate the value with @my.addr.com. So my target HTML code will be
    >
    > <a href="mailto:">
    > James Cook
    > </a>


    <xsl:template match="user">
    <a href="mailto:{concat(@login, '@example.com')}">
    <xsl:value-of select="name" />
    </a>
    </xsl:template>



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 28, 2005
    #3
  4. Zhou Lei

    Zhou Lei Guest

    "Joris Gillis" <> дÈëÓʼþ
    news:eek:...
    > Tempore 18:24:34, die Monday 28 February 2005 AD, hinc in foro

    {comp.text.xml} scripsit Zhou Lei <>:
    >
    > > <user login="loginname">
    > > <name>James Cook</name>
    > > </user>
    > >
    > > I need to include the login attribute value in my target HTML file, and
    > > concatenate the value with @my.addr.com. So my target HTML code will be
    > >
    > > <a href="mailto:">
    > > James Cook
    > > </a>

    >
    > You can use:
    > a) an attribute value template:
    > <xsl:template match="user">
    > <a href="mailto:{@login}@my.addr.com">
    > <xsl:apply-templates/>
    > </a>
    > </xsl:template>
    >
    > or b)explicit attribute node creation:
    > <xsl:template match="user">
    > <a>
    > <xsl:attribute name="href">
    > <xsl:text>mailto:</xsl:text>
    > <xsl:apply-templates select="@login"/>
    > <xsl:text>@my.addr.com</xsl:text>
    > </xsl:attribute>
    > <xsl:apply-templates/>
    > </a>
    > </xsl:template>
    >
    >
    >
    > regards,
    > --
    > Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    > Fiat W3C in tenebris


    Thank you and Martin very much it works! :)
     
    Zhou Lei, Feb 28, 2005
    #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. Danny Anderson
    Replies:
    5
    Views:
    508
    Victor Bazarov
    Aug 15, 2003
  2. Rolf Magnus
    Replies:
    2
    Views:
    606
    Karl Heinz Buchegger
    Nov 28, 2003
  3. Elie Nader
    Replies:
    1
    Views:
    643
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    937
    Andreas Bogenberger
    Feb 22, 2008
  5. Fredxx
    Replies:
    3
    Views:
    648
    Martin Thompson
    Jul 15, 2009
Loading...

Share This Page