xslt,想显示两列数据
xslt,想显示两列数据。
xml:
<?xml version="1.0" standalone="yes" ?>
- <NewDataSet>
- <Table>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>
<b PreferredName="吴妙" Birthday="07-20"/>
<b PreferredName="蒋大宏" Birthday="07-22"/>
<b PreferredName="林妙可" Birthday="07-01"/>
<b PreferredName="程昱" Birthday="07-14"/>
<b PreferredName="王志" Birthday="07-03"/>
<b PreferredName="吴国桢" Birthday="07-31"/>
<b PreferredName="李文" Birthday="07-25"/>
<b PreferredName="株距" Birthday="07-20"/>
<b PreferredName="张路" Birthday="07-07"/>
</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Table>
</NewDataSet>
xslt:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<table border="0">
<xsl:for-each select="NewDataSet/Table">
<tr>
<td>
<xsl:value-of select="PreferredName"/>
<xsl:value-of select="Birthday"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
现在显示的是
吴妙 07-20
蒋大宏 07-22
林妙可 07-01
程昱 07-14
…… ……
…… ……
我想要的是
吴妙 07-20 蒋大宏 07-22
林妙可 07-01 程昱 07-14
…… ……
…… ……
就是开始显示的是一列,我想有两列显示。我接触xslt时间不长。就大侠帮忙。谢谢
[解决办法]
- XML code
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/> <xsl:template match="/"> <html> <body> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match="Table"> <table border="0"> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="b"> <tr> <td><xsl:value-of select="@PreferredName"/></td> <td><xsl:value-of select="@Birthday"/></td> </tr> </xsl:template></xsl:stylesheet>
[解决办法]
用XSL把XML的数据转换成完美的多列表格形式