Xml XSL:如何避免表之间的合并?
我需要显示两个表: | Param1 | Param2 | -------+------+--------- | p1.1 | p1.2 | p2 | -------+------+--------- | a11 | a21 | b01 | | a12 | a22 | b02 | | Col1 | Col2 | -------+------+--------- | c1.1 | c1.2 | c2 | -------+------+--------- | x11 | x21 | y01 | | x12 | x22 | y02 | |参数1 |参数2| -------+------+--------- |p1.1 | p1.2 | p2| -------+------+--------- |a11 | a21 | b01| |a12 | a22 | b02| |Col1 | Col2| -------+------+--------- |c1.1 | c1.2 | c2| -------+------+--------- |x11 | x21 | y01| |x12 | x22 | y02| XML:Xml XSL:如何避免表之间的合并?,xml,xslt,Xml,Xslt,我需要显示两个表: | Param1 | Param2 | -------+------+--------- | p1.1 | p1.2 | p2 | -------+------+--------- | a11 | a21 | b01 | | a12 | a22 | b02 | | Col1 | Col2 | -------+------+--------- | c1.1 | c1.2 | c2 | -------+-----
a11
a21
a12
a22
b01
b02
x11
x21
x12
x22
y01
y02
XSL:
但我有两个表之间的合并,如下所示:
| Param1 | Param2 | Col1 | Col2 |
-------+------+--------+------+------+--------
| p1.1 | p1.2 | p2 | c1.1 | c1.2 | c2 |
-------+------+--------+------+------+--------
| a11 | a21 | b01 | x11 | x21 | y01 |
| a12 | a22 | b02 | x12 | x22 | y02 |
|Param1 | Param2 | Col1 | Col2|
-------+------+--------+------+------+--------
|p1.1 | p1.2 | p2 | c1.1 | c1.2 | c2|
-------+------+--------+------+------+--------
|a11 | a21 | b01 | x11 | x21 | y01|
|a12 | a22 | b02 | x12 | x22 | y02|
如何避免表之间的合并?您的输入XML无效。它应该有一个根元素。假设您将XML包装在一个名为“tables”的元素中: 在修改后的样本输入上运行时,结果为:
<div>
<table class="data_table" style="width: 100%; background:gray">
<thead>
<tr>
<th colspan="2">Param1</th>
<th>Param2</th>
</tr>
<tr>
<th>p1.1</th>
<th>p1.2</th>
<th>p2</th>
</tr>
</thead>
<tbody>
<tr>
<td>a11</td>
<td>a21</td>
<td>b01</td>
</tr>
<tr>
<td>a12</td>
<td>a22</td>
<td>b02</td>
</tr>
</tbody>
</table>
<table class="data_table" style="width: 100%; background:gray">
<thead>
<tr>
<th colspan="2">Col1</th>
<th>Col2</th>
</tr>
<tr>
<th>c1.1</th>
<th>c1.2</th>
<th>c2</th>
</tr>
</thead>
<tbody>
<tr>
<td>x11</td>
<td>x21</td>
<td>y01</td>
</tr>
<tr>
<td>x12</td>
<td>x22</td>
<td>y02</td>
</tr>
</tbody>
</table>
</div>
参数1
参数2
p1.1
p1.2
p2
a11
a21
b01
a12
a22
b02
可乐
可乐
c1.1
c1.2
c2
x11
x21
y01
x12
x22
y02
| Param1 | Param2 | Col1 | Col2 |
-------+------+--------+------+------+--------
| p1.1 | p1.2 | p2 | c1.1 | c1.2 | c2 |
-------+------+--------+------+------+--------
| a11 | a21 | b01 | x11 | x21 | y01 |
| a12 | a22 | b02 | x12 | x22 | y02 |
<tables>
<tb>
...
</tb>
<tb>
...
</tb>
</tables>
<xsl:template match="/*">
<div>
<xsl:apply-templates select="tb" />
</div>
</xsl:template>
<xsl:template match="tb"> <!-- Slash before tb removed -->
<table class="data_table" style="width: 100%; background:gray">
...
</table>
</xsl:template>
<div>
<table class="data_table" style="width: 100%; background:gray">
<thead>
<tr>
<th colspan="2">Param1</th>
<th>Param2</th>
</tr>
<tr>
<th>p1.1</th>
<th>p1.2</th>
<th>p2</th>
</tr>
</thead>
<tbody>
<tr>
<td>a11</td>
<td>a21</td>
<td>b01</td>
</tr>
<tr>
<td>a12</td>
<td>a22</td>
<td>b02</td>
</tr>
</tbody>
</table>
<table class="data_table" style="width: 100%; background:gray">
<thead>
<tr>
<th colspan="2">Col1</th>
<th>Col2</th>
</tr>
<tr>
<th>c1.1</th>
<th>c1.2</th>
<th>c2</th>
</tr>
</thead>
<tbody>
<tr>
<td>x11</td>
<td>x21</td>
<td>y01</td>
</tr>
<tr>
<td>x12</td>
<td>x22</td>
<td>y02</td>
</tr>
</tbody>
</table>
</div>