-- 作者:jx27
-- 发布时间:7/2/2005 9:23:00 AM
--
不好意思,本事没到家,把你的XML稍微改了一下。 1)中文我改成英文了 2)我加了一个MODE,因为你的NODES有2种不同的意思。 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="xue.xsl"?> <nodes name="Beijing"> <nodes name="Shangdi" mode="sub"> <node name="wujie"> <param name="Temp" /> <param name="Pressure" /> </node> <node name="Qijie"> <param name="Temp" /> <param name="Pressure" /> </node> </nodes> <nodes name="Xisanqi" mode="sub"> <node name="yuxin"> <param name="Temp" /> <param name="Pressure" /> </node> <node name="Huangtudi"> <param name="Temp" /> <param name="Pressure" /> </node> </nodes> </nodes> /=====================================below is my xslt <?xml version="1.0" encoding="utf-8"?> <!-- Author Name: Xue Jun (0226318) Contact: jx27@waikato.ac.nz Copyright: Waikato Uni Version:1.0(updated @ 02/07/2005) Last Updated: 02 July 2005 --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="xhtml" version="1.0" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="*"/> </xsl:template> <!-- The following template is applied to the root element of the nodes and generates the basic xhtml document structure. --> <xsl:template match="nodes"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TABLE</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="author" content="XUE JUN"/> </head> <body xml:lang="en"> <h1>TABLE</h1> <hr/> <!-- Seperate Line--> <table border="1" width="100%" align="center"> <tr> <!--Show 1st row--> <th align="center" width="100%" colspan="8"> <xsl:value-of select="@name"/> </th> </tr> <tr> <!--2nd row--> <xsl:apply-templates select="nodes" mode="sub"/> </tr> <tr> <!--3rd row--> <xsl:apply-templates select="//node"/> </tr> <tr> <!--4th row--> <xsl:apply-templates select="//param"/> </tr> </table> </body> </html> </xsl:template> <!--&&&&&&&&&&&&&&&&&&&&&&&& nodes &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&--> <xsl:template match="nodes" mode="sub"> <th align="center" width="50%" colspan="4"> <xsl:value-of select="@name"/> </th> </xsl:template> <!--&&&&&&&&&&&&&&&&&&&&&&&& node &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&--> <xsl:template match="node"> <th align="center" width="25%" colspan="2"> <xsl:value-of select="@name"/> </th> </xsl:template> <!--&&&&&&&&&&&&&&&&&&&&&&&& param &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&--> <xsl:template match="param"> <th align="center" width="13%"> <xsl:value-of select="@name"/> </th> </xsl:template> </xsl:stylesheet> /=======================
此主题相关图片如下:
 [此贴子已经被作者于2005-7-2 9:48:03编辑过]
|