我想要改造这个XMLXSLT转换每个复杂条件
XML:
<Page>
<Sections>
<Section id="parent_hdr_sec" rows="2" columns="1">
<Sections>
<Section id="plan_hdr" rows="0" columns="0" />
<Section id="plan_hdr_dtl" rows="0" columns="0" />
</Sections>
</Section>
<Section id="splitter_sec" rows="1" columns="2">
<Sections>
<Section id="parent_left_sec" rows="4" columns="1">
</Section>
<Section id="parent_right_sec" rows="7" columns="1">
</Section>
</Sections>
</Section>
</Sections>
</Page>
XSLT:
<xsl:template match="/">
<html>
<body>
<table>
<xsl:for-each select="Page/Sections/Section">
<tr>
<td>
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<table>
<xsl:variable name="Rows" select="@rows"/>
<xsl:variable name="Columns" select="@columns"/>
<xsl:for-each select="(//Section/Sections/Section)[$Rows >= position()]">
<tr>
<xsl:for-each select="(//Section/Sections/Section)[$Columns >= position()]">
<td>
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
我的输出:
<html>
<body>
<table>
<tr>
<td id="parent_hdr_sec">
<table>
<tr>
<td id="plan_hdr"></td>
</tr>
<tr>
<td id="plan_hdr"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="splitter_sec">
<table>
<tr>
<td id="plan_hdr"></td>
<td id="plan_hdr_dtl"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
正确的输出:
'ID' 变量值在我的输出错误更新。
我需要输出这样的下面,
<html>
<body>
<table>
<tr>
<td id="parent_hdr_sec">
<table>
<tr>
<td id="plan_hdr"></td>
</tr>
<tr>
<td id="plan_hdr_dtl"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="splitter_sec">
<table>
<tr>
<td id="parent_left_sec"></td>
<td id="parent_right_sec"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
我想XSLT每个条件得到上面的输出。
谁能帮我解决这个问题..
感谢您的回复。我正在输出这样,如果使用上述的一个 – Hari
@Hari请不要张贴在评论的代码,它是相当难以理解。 –