1.show.xml代码如下:
<?xml version="1.0" encoding="GB2312"?> <?xml-stylesheet type="text/xsl" href="style.xsl"?> <label_out> <!-- 三条数据 --> <label_people> <name>张1三</name> <age>22</age> <country>中国</country> </label_people> <label_people> <name>李四</name> <age>19</age> <country>日本</country> </label_people> <label_people> <name>王五</name> <age>20</age> <country>朝鲜</country> </label_people> </label_out>
02.style.xsl如下:
<?xml version="1.0" encoding="GB2312"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="standard.xsl"/> <xsl:template match="/"> <html> <body> <h2>抬头内容</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>姓名</th> <th>年级</th> <th>国家</th> </tr> <xsl:apply-imports/> </table> </body> </html> </xsl:template> </xsl:stylesheet>
03.standard.xsl代码如下:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="label_out"> <xsl:for-each select="label_people"> <tr> <td> <xsl:value-of select="name"/> </td> <td bgcolor="#00ff66" > <xsl:value-of select="age"/> </td> <td> <xsl:value-of select="country"/> </td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet>
标签:13,代码,用法,import,如下,xsl From: https://www.cnblogs.com/tianpan2019/p/16954429.html