|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Transforming XML to XML (diff. format) using XSL
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.vij@xxxxxxxxxx">Vipul Vij</author>
</properties>
<body>
<section name="Bugs fixed">
<xsl:variable name="fixed" select="mysqldump/database/table/row[field[@name = 'status_id'] = 7 and field[@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[@name = 'bug_id']"/>
<li>
<xsl:value-of select="field[@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[@name = 'bug_id']"/>
<tr>
<td>
<a href="http://intranet/phpbt-0.9.1/bug.php?op=show&bugid={field[@name = 'bug_id']}">
<xsl:value-of select="field[@name = 'bug_id']"/>
</a>
</td>
<td>
<xsl:value-of select="field[@name = 'title']"/>
</td>
<td>
<xsl:value-of select="field[@name = 'description']"/>
</td>
<td>
<a href="mailto:vipul.vij@xxxxxxxxxx">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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








