XSL

Order.xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Order.xsl"?>
<Order OrderNo="1234">
 <OrderDate>2001-01-01</OrderDate>
 <Customer>Graeme Malcolm</Customer>
 <Item>
  <Product ProductID="1" UnitPrice="18">Chai</Product>
  <Quantity>2</Quantity>
 </Item>
 <Item>
  <Product ProductID="2" UnitPrice="19">Chang</Product>
  <Quantity>1</Quantity>
 </Item>
</Order>

Order.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:template match="/">
  <html>
   <title>Northwind Web Page</title>
   <body bgcolor="#DDDDDD">
    <table border="1" cellSpacing="0" cellPadding="0" width="500">
     <tr>
      <th>OrderNo</th>
      <th>OrderDate</th>
      <th>Customer</th>
     </tr>
     <tr>
      <td><xsl:value-of select=" Order/@OrderNo"/></td>
      <td><xsl:value-of select="Order/OrderDate"/></td>
      <td><xsl:value-of select="Order/Customer"/></td>
     </tr>
    </table>
    <br/>
    <table border="1" cellSpacing="0" cellPadding="0" width="500">
     <tr>
      <th>ProductID</th>
      <th>ProductName</th>
      <th>UnitPrice</th>
      <th>Quantity</th>
     </tr>
     <xsl:for-each select="Order/Item">
      <tr>
       <td><xsl:value-of select=" Product/@ProductID"></xsl:value-of></td>
       <td>
        <a><xsl:attribute name="HREF">products.aspx?ProductID=<xsl:value-of select="Product/@ProductID"></xsl:value-of></xsl:attribute>
        <xsl:value-of select="Product"></xsl:value-of></a>
       </td>
       <td><xsl:value-of select=" Product/@UnitPrice"></xsl:value-of></td>
       <td><xsl:value-of select="Quantity"></xsl:value-of></td>
      </tr>
     </xsl:for-each>
    </table>
   </body>
  </html>
 </xsl:template>
</xsl:stylesheet>
posted @ 2006-11-06 21:16  RobotTech  阅读(387)  评论(0编辑  收藏  举报