8,907
社区成员
发帖
与我相关
我的任务
分享<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="./test.xsl"?>
<article>
<title name="标题">hello</title>
<content name="内容">hello, world!</content>
<time name="时间">2007-10-01</time>
<url name="地址">www.csdn.net</url>
</article><?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
</head>
<body>
<table border="1">
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="title">
<tr>
<td class="col1"><xsl:value-of select="@name"/></td>
<td class="col2"><xsl:value-of select="."/></td>
</tr>
</xsl:template>
<xsl:template match="content">
<tr>
<td class="col1"><xsl:value-of select="@name"/></td>
<td class="col2"><xsl:value-of select="."/></td>
</tr>
</xsl:template>
<xsl:template match="text()|@*">
<tr>
<td class="col1"><xsl:value-of select="@name"/></td>
<td class="col2"><xsl:value-of select="."/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="text( )|@*">
<tr>
<td class="col1">
<xsl:value-of select="../@name"/>
</td>
<td class="col2">
<xsl:value-of select="."/>
</td>
</tr>
</xsl:template>
<xsl:template match="article/*">
<tr>
<td class="col1"><xsl:value-of select="@name"/></td>
<td class="col2"><xsl:value-of select="."/></td>
</tr>
</xsl:template>