[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

Subject: RE: Transforming XML to XML (diff. format) using XSL
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 3 Jun 2003 14:08:20 +0300
xml diff format
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&amp;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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.