Discussions

XML & Web services: It's boring, XSLT ...

  1. It's boring, XSLT ... (2 messages)

    I want to use XSLT to format xml, next is my xml file and xsl file

    XML
    ...
    <root>
      <user>
      <user_id>27</user_id>
      <name>John</name>
      </user>
    ......
    </root>

    XSL file

    <xsl:template match="/">
      <xsl:for-each select="root/user">
      <tr>
        <td>& href="#">Link &</td>
        <td><xsl:value-of select="name"/></td>
      </tr>
      </xsl:for-each>
    </xsl:template>

    In line 4 of xsl file , I want to put value from <xsl:value-of select="user_id"/> into html link. just href="<xsl:value-of select="user_id"/>"
    I tried several methods to do it, anyone didn't work successfully.

    Please help ....

    Threaded Messages (2)

  2. It's boring, XSLT ...[ Go to top ]

    Try xsl:attribute

    <a>
       <xsl:attribute name="href"><xsl:value-of select="user_id"/></xsl:attribute>
    </a>

    David
  3. It's boring, XSLT ...[ Go to top ]

    Another mechanism: use an attribute value template: {user_id}

    <xsl:template match="/">
      <xsl:for-each select="root/user">
      <tr>
        <td><a href="{user_id}">Link</a></td>
        <td><xsl:value-of select="name"/></td>
      </tr>
      </xsl:for-each>
    </xsl:template>