使用XSL的@顯示元素的屬性

1.XML文檔的內容

<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="book3.xsl"?>
<BookLib>
 <Book>
  <Title>Windows程序設計</Title>
  <Author sex="男">
   <name>好孩子</name>
   <Email>[email protected]</Email>
  </Author>
  <Press>
  <PressDate>2000年5月1日</PressDate>
  <PressCompany>南京出版社</PressCompany>
  </Press>
  <Price>49.00元</Price>t66
 </Book>
 <Book>
  <Title>深入潛出XML</Title>
  <Author sex="女">
   <name>老虎工作室</name>
   <Email>[email protected]</Email>
  </Author>
  <Press>
  <PressDate>2006年5月12日</PressDate>
  <PressCompany>北京出版社</PressCompany>
  </Press>
  <Price>28.00元</Price>
 </Book>
 <Book>
  <Title>人工智能技術導論</Title>
  <Author sex="男">
   <name>廉師友</name>
   <Email>[email protected]</Email>
  </Author>
  <Press>
  <PressDate>2006年7月12日</PressDate>
  <PressCompany>上海出版社</PressCompany>
  </Press>
  <Price>18.00元</Price>
 </Book>
</BookLib>


2.XSL的文檔

<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/TR/WD-xsl">
 <xsl:template match="/">
  <html>
   <xsl:apply-templates/>
  </html>
 </xsl:template>
 <xsl:template match="BookLib">
  <body>
   <xsl:for-each select="Book" >
   
   <xsl:value-of select="Title"/>
   <HR></HR>
   <xsl:value-of select="
Author/@sex"/
   <br></br>
   <xsl:value-of select="Author/name"/>
   <hr></hr>
   <xsl:value-of select="Price"/>
   <hr></hr>
 </xsl:for-each>
  </body>
 </xsl:template>
 
  
 
</xsl:stylesheet>

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