您的位置:首页 > 其它

使用XSL的@显示元素的属性

2006-05-29 23:26 495 查看
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>haohaizi@163.com</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>laohu@163.com</Email>
</Author>
<Press>
<PressDate>2006年5月12日</PressDate>
<PressCompany>北京出版社</PressCompany>
</Press>
<Price>28.00元</Price>
</Book>
<Book>
<Title>人工智能技术导论</Title>
<Author sex="男">
<name>廉师友</name>
<Email>laolian@163.com</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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐