Hi,
I trying to transform a XML file (created from a MySQL DB)
into another
XML file listing FIXED bug details in a table and a brief
description in an
order list . Problem: how do I use <xsl:for-each select="">
to refer to
each of the field names in the source? I would like to say
display the
value of "bug_id" inside the <li> tag within a ordered list
and create a
hyperlink to the bug page inside the table.
Use AVTs <http://www.w3.org/TR/xslt#attribute-value-templates>. See the
stylesheet fragment below, for the AVT usage and how to select the fields you
want.
<xsl:template match="/">
<xml>
<document>
<properties>
<author email="vipul(_dot_)vij(_at_)orange(_dot_)net">Vipul
Vij</author>
</properties>
<body>
<section name="Bugs fixed">
<xsl:variable name="fixed"
select="mysqldump/database/table/row[field[(_at_)name = 'status_id'] = 7 and
field[(_at_)name = 'resolution_id'] = 1]"/>
<p>Summary of bugs that have been now fixed</p>
<xsl:if test="$fixed">
<ol>
<xsl:for-each select="$fixed">
<xsl:sort select="field[(_at_)name = 'bug_id']"/>
<li>
<xsl:value-of select="field[(_at_)name = 'title']"/>
</li>
</xsl:for-each>
</ol>
</xsl:if>
<table>
<tr>
<td>Bug ID</td>
<td>Name</td>
<td>Description</td>
<td>Fixed by</td>
</tr>
<xsl:for-each select="$fixed">
<xsl:sort select="field[(_at_)name = 'bug_id']"/>
<tr>
<td>
<a
href="http://intranet/phpbt-0.9.1/bug.php?op=show&bugid={field[(_at_)name =
'bug_id']}">
<xsl:value-of select="field[(_at_)name = 'bug_id']"/>
</a>
</td>
<td>
<xsl:value-of select="field[(_at_)name = 'title']"/>
</td>
<td>
<xsl:value-of select="field[(_at_)name = 'description']"/>
</td>
<td>
<a
href="mailto:vipul(_dot_)vij(_at_)orange(_dot_)net">Vipul Vij</a>
</td>
</tr>
</xsl:for-each>
</table>
</section>
</body>
</document>
</xml>
</xsl:template>
Cheers,
Jarno - Delerium: Heaven's Earth (Matt Darey remix)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list