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>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值