按值对两个节点进行分组

Group two nodes by value

    <Item>
        <Description>Dog</Description>
    </Item>
    <Item>
        <Description>Cat</Description>
    </Item>
    <Item>
        <Description>Turtle</Description>
    </Item>
    <Item>
        <Description>Hedgehog</Description>
    </Item>

没有排序,但我需要 Hedgehog 总是在 Dog 下

这可以使用 xsl 吗?

不确定您真正想要的输出是什么,但这总是将 Item 节点置于 Dog、Hedgehog 和其他顺序中。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="2.0">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="Items">
    <xsl:copy>
        <xsl:apply-templates select="Item[Description='Dog']"/>
        <xsl:apply-templates select="Item[Description='Hedgehog']"/>
        <xsl:apply-templates select="Item[Description!='Hedgehog' and Description!='Dog']"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="Item">
      <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>

您可以在这里尝试:https://xsltfiddle.liberty-development.net/gWEamLr