我有以下的XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<object>Clutch</object>
<object>Gearbox</object>
<object>Cylinder head</object>
<object>Starter</object>
<object>Airbox</object>
<object>Inlet manifold</object>
</objects>
以下是XSLT文档:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="objects">
<parts>
<xsl:apply-templates>
<xsl:sort select="object"/>
</xsl:apply-templates>
</parts>
</xsl:template>
<xsl:template match="object">
<part>
<xsl:apply-templates/>
</part>
</xsl:template>
</xsl:stylesheet>
应用后,我得到了预期的输出,但是它没有被排序:
<?xml version="1.0" encoding="UTF-8"?>
<parts>
<part>Clutch</part>
<part>Gearbox</part>
<part>Cylinder head</part>
<part>Starter</part>
<part>Airbox</part>
<part>Inlet manifold</part>
</parts>
为什么
<xsl:sort select="object"/>
没有生效?