开发者

Attributes in XLS - How can I get them from XML and add to generated HTML

I have this XML returned from an ajax event:

<result>
    <row id="0">
        <column description="Publication ID" id="PUBLICATIONID" name="ID">72</column>
        <column description="Paper name" id="ADBPMAPPAPERNAME" name="PAPER_NAME">NAME</column>
        <column description="Paper Reference" id="ADBPMAPPAPERREF" name="PAPER_REF">PAPER_REF</column>
    </row>
</result>

Actually, the original XML has a lot of rows, this is a simple one. I want to fill a table and I'm doing this:

<?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="/">
<html>
    <body>
        <table>
            <tr bgcolor="#9acd32">
            <th>ID</th>
            <th>Name</th>
            <th>Reference</th>
            </tr>
            <xsl:for-each select="result/row">
                <tr>
                    <td><xsl:value-of select="ID"/></td>
                    <td><xsl:value-of select="PAPER_NAME"/></td>
                    <td><xsl:value-of select="PAPER_REF"/></td>
                </tr>
            </xsl:for-each>
        </table>
    </body>
</html>
</xsl:template>
</xsl:stylesheet>

My question is: How can I add to the generated HTML code, the attribute "id" for each "tr" of the table? Explaning better, now, that XLS do this:

<tr>
    <td></td>
    ...
</tr>

When I want to do this:

<tr id开发者_运维技巧="ROW_ID_PRESENTS_IN_XML">
    <td></td>
    ...
</tr>

Thanks.


<tr id="{@id}">

You can of course use any XPath inside the {}.

This is, by the way, shorthand for

<tr>
  <xsl:attribute name="id">
    <xsl:value-of select="@id" />
  </xsl:attribute>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜