【发布时间】:2020-11-03 19:26:16
【问题描述】:
我是 xslt 的新手,我一直在努力寻找解决方案,我需要创建一个表格,其中我的 xml 文档按属性“级别”(此处为 niveau)排序,然后按字母顺序排列
这是 xml 文档(如果您想知道的话,它是法语)
<dico
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='dico.xsd'>
<mot niveau="2">arbre</mot>
<mot niveau="2">jeu</mot>
<mot niveau="3">essence</mot>
<mot niveau="5">convalescence</mot>
<mot niveau="5">mot-valise</mot>
<mot niveau="1">pain</mot>
<mot niveau="4">maintenance</mot>
</dico>
这是我的 xslt
<xsl:template match="/">
<html>
<head>
<title>Dictionnaire</title>
</head>
<body>
<xsl:apply-templates select="dico/mot">
<xsl:sort select="@niveau"/>
<xsl:sort select="."/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="mot">
<table border="4" cellspacing="4" cellpadding="2" width="80%">
<tr>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<td>
le mot est : <xsl:value-of select="."/>
</td>
<td>
niveau : <xsl:value-of select="@niveau"/>
</td>
</tr>
</table>
</xsl:template>`
【问题讨论】:
-
请将预期结果添加到您的问题中。
标签: xml xslt xslt-1.0 xslt-2.0