XSL寫的時候要注意的一個小問題

這是XML文件

<?xml version="1.0" encoding="GB2312" standalone="no" ?>
<?xml-stylesheet href="hxh.xsl" type="text/xsl" ?>

<HxHBookShop>
 <WebSite>http://www.ezhi.cn</WebSite>
 <BookStore>
  <Book>
   <BookName No="F01001">哈哈哈</BookName>
   <Price> 560 </Price>
   <Authors>
    <Author>賀星河</Author>
    <Author>可以嗎</Author>
   </Authors>
   <Intro> 賀星河是個大英雄</Intro>
   <Picture>D:/Picture.jpg</Picture>
  </Book>
 </BookStore>
</HxHBookShop>

//這裏是XSL樣式表文件

<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">  //十二分注意不能把TR和WD寫成小寫了,否則瀏覽器不識別!

<xsl:template match="/">
<html>
 <Body>
  <xsl:for-each select="HxHBookShop">
   <xsl:apply-templates/>
  </xsl:for-each>
  <Table border="1" cellpadding="5">
   <Tr>
    <th>書名</th>
    <th>定價</th>
    <th>作者</th>
    <th>簡介</th>
    <th>圖片</th>
   </Tr>
   <xsl:for-each select="//Book" order-by="+Price">
    <tr>
     <xsl:apply-templates/>
    </tr>
   </xsl:for-each>
  </Table>
 </Body>
</html>
</xsl:template>

<xsl:template match="//WebSite">
 <font size = "5">
  <a>
   <xsl:attribute name="href">
      <xsl:value-of/>
   </xsl:attribute>
   E旨網址
  </a>
 </font>
</xsl:template>

<xsl:template match="BookName">
 <td width="100%" style="font-size:12px;color:#cc0000;">
 <br/>
  <font size = "5" color="black">書號</font>
 </td>
</xsl:template>

<xsl:template match="Price">
 <td style="color:red;"></td>
</xsl:template>

<xsl:template match="Authors">
 <td style="color:blue;"></td>
</xsl:template>

<xsl:template match="Author">
 <br/>
</xsl:template>

<xsl:template match="Intro">
 <td width="220" style="font-size:10pt;">
 </td>
 
</xsl:template>

<xsl:template match="Picture">
 <td width="120" height="180">
 <img width="120" height="180">
  <xsl:attribute name="src">
   <xsl:value-of/>
  </xsl:attribute>
 </img>
 </td>
</xsl:template>

</xsl:stylesheet>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章