Java 如何使用XSL排列数据

Java 如何使用XSL排列数据,java,xml,xslt,Java,Xml,Xslt,但我需要像下面这样的 X : P Y : R X : Q Y : R 听起来像是一个分组问题,您可以使用 感谢您的ans@Martin,您能否使用介于xsl之间的if test=position条件为我提供此解决方案。谢谢 X : P Y : R X : Q Y : R X : P Q Y : R <xsl:template match="root"> <xsl:for-each-group select="A/*" group-b

但我需要像下面这样的

X : P
Y : R
X : Q
Y : R

听起来像是一个分组问题,您可以使用





感谢您的ans@Martin,您能否使用介于xsl之间的if test=position条件为我提供此解决方案。谢谢
X : P
Y : R
X : Q
Y : R
X : P
    Q
Y : R
  <xsl:template match="root">
      <xsl:for-each-group select="A/*" group-by="node-name()">
          <xsl:value-of select="current-grouping-key() || ' : '"/>
          <xsl:for-each-group select="current-group()" group-by=".">
              <xsl:value-of select="."/>
              <xsl:text>&#10;</xsl:text>
          </xsl:for-each-group>
      </xsl:for-each-group>
  </xsl:template>