在模板中指定XSL样式表

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

模板文件如下:

<?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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航