使用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>
<?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>
相关文章推荐
- 使用Devexpress 的gridControl 绑定List列表(元素对象包含List属性)的Master-Detail显示
- WCF已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性
- 使用struts bean:write标签时不能显示Integer,Date等类型的属性问题的解决
- 使用jquery给加载失败的img元素显示默认图片
- spring bean属性及子元素使用总结
- 使用Inspector查看App元素属性
- IMG 元素的 complete 属性:不在标签上使用 onload 自动调整图像大小
- 使用jQuery筛选排除元素以修改指定标签的属性
- 使用shape来定义控件的一些显示属性
- JComBox下拉框使用对象封装,显示时指定显示对象中的某一属性
- h5的全局属性-对任何元素都可使用的属性
- 在Windows 2008 server 64位平台上可以使用旧版Acctinfo.dll以显示账户属性-Additional Account Info
- 使用jQuery操作元素的属性与样式
- Visibility属性控制元素的显示和隐藏
- 使用jQuery操作元素的属性与样式
- 如何使用Phoenix Framework定制的浏览器录制元素属性
- 使用HashSet和TreeSet存储多个商品信息,遍历并输出;其中商品属性:编号,名称,单价,出版社;要求向其中添加多个相同的商品,验证集合中元素的唯一性。 提示:向HashSet中添加自定义
- 使用layout_weight属性实现视图的居中显示
- QT 使用自定义状态(属性)来显示不同的样式表
- jquery之操作元素属性和特性(操作元素属性,each()方法的使用)