Listing 1 展示一个具有三个项目的XML文档
Listing 1: order.xml
<?xml version="1.0" ?> <Order> <Account>9900234</Account> <Item id="1"> <SKU>1234</SKU> <PricePer>5.95</PricePer> <Quantity>100</Quantity> <Subtotal>595.00</Subtotal> <Description>Super Widget Clamp</Description> </Item> <Item id="2"> <SKU>6234</SKU> <PricePer>22.00</PricePer> <Quantity>10</Quantity> <Subtotal>220.00</Subtotal> <Description>Mighty Foobar Flange</Description> </Item> <Item id="3"> <SKU>9982</SKU> <PricePer>2.50</PricePer> <Quantity>1000</Quantity> <Subtotal>2500.00</Subtotal> <Description>Deluxe Doohickie</Description> </Item> </Order>
Listing 2 展示一个简单的XSL模板,将上面的文档转换成HTML
Listing 2: simple.xsl
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="Order" /> </body> </html> </xsl:template> <xsl:template match="Order"> <table border="1"> <tr> <th>SKU</th> <th>Description</th> <th>Price</th> <th>Quantity</th> <th>Subtotal</th> </tr> <xsl:apply-templates select="Item" /> </table> </xsl:template> <xsl:template match="Item"> <tr> <td><xsl:value-of select="SKU" /></td> <td><xsl:value-of select="Description" /></td> <td><xsl:value-of select="PricePer" /></td> <td><xsl:value-of select="Quantity" /></td> <td><xsl:value-of select="Subtotal" /></td> </tr> </xsl:template> </xsl:stylesheet>
微软嵌入式产品总监谈WEC 7的7大
《边看边读》第14期:读《Java加