0

数日間、この問題に悩まされています。

ネストされた要素の属性を並べ替えながら、xml ファイルをコピーしようとしています。私が持っているものはうまくいくはずだと感じています

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:my="my:my">
<xsl:output method="xml" indent="yes" /> 
  <xsl:template match="node() | @*">
     <xsl:copy>
        <xsl:apply-templates select="node() | @*"/>
     </xsl:copy>      
</xsl:template>        
  <xsl:template match="PrProduct">
     <xsl:copy>
            <xsl:apply-templates select="node()|@* " >
            <xsl:sort select="@TEC"  order="descending" />
        </xsl:apply-templates>             
     </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

ここにxmlがあります

<body>
<issueobject>
<page>
</page>
<prproduct TEC="TOR">
</prproduct>
<prproduct TEC="UVA">
<partPage>
</partPage>
</issueobject>
</body>

問題は、並べ替えている要素の両側に同じレベルの要素があることにあると思います。遊んでいると、データを並べ替えることができますが、後/前にデータが失われてしまいます。

ありがとう

4

2 に答える 2