使用 xslt 将 xml 数据分为 2 列
我有一个 xslt 样式表,它根据是否存在图像将 xml 文件中的数据格式化为具有单列的表。由于数据量相当大,因此该列太长,我想尝试将当前列拆分为 2 个相等的列。知道我该怎么做吗?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="0" bordercolor="#606060" style="width:200px">
<tr bgcolor="white" width="200px">
</tr>
<xsl:for-each select="NewDataSet/Manufacturer">
<tr>
<xsl:choose>
<xsl:when test="Image = 'none'">
<td bgcolor="#dfdfdf">
<a href="Vehicles.aspx?Manufacturer={ManufacturerID}" style="text-decoration:none;" runat="server">
<xsl:value-of select="Manufacturer"/>
</a>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<a href="Vehicles.aspx?Manufacturer={ManufacturerID}" style="text-decoration:none;" runat="server">
<im alt="{Manufacturer}" src="Images/Manufacturers/{Image}" style="border-width: 0px; width: 50px; "/>
</a>
</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</xsl:template>
I have an xslt style sheet that formats the data from my xml file into a table with a single column based on whether there is an image present or not. There is a fair amount of data so the column is too long though and i want to try splitting the current column into 2 equal columns. And idea how i can do this?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="0" bordercolor="#606060" style="width:200px">
<tr bgcolor="white" width="200px">
</tr>
<xsl:for-each select="NewDataSet/Manufacturer">
<tr>
<xsl:choose>
<xsl:when test="Image = 'none'">
<td bgcolor="#dfdfdf">
<a href="Vehicles.aspx?Manufacturer={ManufacturerID}" style="text-decoration:none;" runat="server">
<xsl:value-of select="Manufacturer"/>
</a>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<a href="Vehicles.aspx?Manufacturer={ManufacturerID}" style="text-decoration:none;" runat="server">
<im alt="{Manufacturer}" src="Images/Manufacturers/{Image}" style="border-width: 0px; width: 50px; "/>
</a>
</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</xsl:template>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样,
我已经将示例中写入单元格内容的部分和
部分提取到另一个名为的xsl:template
do-cell-content
how about something like this
I've extracted the part that writes the content of the cells and the
<xsl:choose>
part from your example to anotherxsl:template
calleddo-cell-content