0
아래의 XSLT 문서에있는 모든 hrow 태그가 맨 아래에 있으며, 나타나는 순서를 유지하고 싶습니다. 어떻게해야합니까? 간단하게 할XSLT는 XML 문서를 형식화 할 때 태그 순서를 유지합니다.
<log>
<hrow time="45:43:2343">A heading</hrow>
<row type="e">An error</row>
<row type="w">An warn</row>
<row type="i">An info</row>
<row type="d">An debug</row>
<row type="t">unknown</row>
<hrow time="45:43:2343">Another heading</hrow>
<row type="t">more rows</row>
</log>
게시 된 XML 문서와 XSLT의 문서
<?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 width="100%">
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="log">
<xsl:apply-templates select="row" />
<xsl:apply-templates select="hrow" />
</xsl:template>
<xsl:template match="row">
<xsl:variable name="type" select="@type" />
<xsl:choose>
<xsl:when test="$type = 'd'">
<tr>
<td style="background-color:#C6F98B">
<xsl:value-of select="." />
</td>
</tr>
</xsl:when>
<xsl:when test="$type = 'i'">
<tr>
<td style="background-color:#8B8BF9">
<xsl:value-of select="." />
</td>
</tr>
</xsl:when>
<xsl:when test="$type = 'e'">
<tr>
<td style="background-color:#F9555D">
<xsl:value-of select="." />
</td>
</tr>
</xsl:when>
<xsl:when test="$type = 'w'">
<tr>
<td style="background-color:#F8F781">
<xsl:value-of select="." />
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr>
<td style="background-color:#E4E4E4">
<xsl:value-of select="." />
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="hrow">
<tr>
<td style="background-color:#DBC5FF;font-size: 16px;">
<xsl:value-of select="." />
[
<xsl:value-of select="@time" />
]
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
+1 좋은 답변입니다. 또한 푸시 스타일 처리가 필요한 경우'select = "row | hrow"를 선택하십시오. –