当前位置:主页>xml>文章内容
在模板中指定XSL样式表
来源: 作者: 发布时间:2007-04-04  

模板文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:sql="urn:schemas-microsoft-com:xml-sql" sql:xsl="MyXsl.xsl">
<sql:query>
    Select FirstName,LastName from Employees For XML auto
</sql:query>
</root>


  在这里将模板文件tempxsl.xml存储在与template类型的虚拟名称(template)关联的目录中.XSL文件(MyXsl.xsl)也存储在同一目录中.MyXsl.xsl文件如下:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Employees">
<tr>
<td><xsl:value-of select="@FirstName"/></td>
<td><xsl:value-of select="@LastName"/></td>
</tr>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<style>th{background-color:#cccccc}</style>
</head>
<body>
<table border="2" style="width:300;">
<tr><th colspan="2">Employees</th></tr>
<tr><th>First Name</th><th>Last Name</th></tr>
<xsl:apply-templates select="root"/>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


执行模板:http://localhost/template/tempxsl.xml


 
上一篇:建立MS XML 测试环境   下一篇:HTML如何向XML迁移
 
  相关文章
·建立MS XML 测试环境
·HTML如何向XML迁移
·利用ASP从远程服务器上接收XML数据
·XML串行化数据的基础
·XML与面向Web的数据挖掘技术
·W3C有意推广XML新标准 为兼容性吵翻了
·使用模板执行SQL查询
·如何在HTML中引用XML数据
·用XML在页面内刷新数据
·XML CDATA的作用
·用XSL和ASP实现分页功能
·概述IE和SQL2k开发一个XML聊天程序
 
【关闭窗口】
推荐本站资源
最新文章