0

xml の下でソートするための xslt を作成しました。出力は AccountNumber に基づいてソートされていないようです。何が私の間違いだったのかわからない。

<TXLife xmlns="http://ACORD.org/Standards/Life/2">
    <TXLifeRequest>
        <FundCode>LTRT00</FundCode>
        <AccountDescription>CWA – +U</AccountDescription>
        <CurrencyTypeCode>840</CurrencyTypeCode>
        <TransExeDate>2013-04-20</TransExeDate>
        <AccountNumber>34142</AccountNumber>
        <PaymentAmt>300.000000000</PaymentAmt>
        <ReversalInd>0</ReversalInd>
    </TXLifeRequest>
    <TXLifeRequest>
        <FundCode>LTRW00</FundCode>
        <AccountDescription>CWA – +U</AccountDescription>
        <CurrencyTypeCode>124</CurrencyTypeCode>
        <TransExeDate>2013-04-20</TransExeDate>
        <AccountNumber>14142</AccountNumber>
        <PaymentAmt>250.000000000</PaymentAmt>
        <ReversalInd>0</ReversalInd>
    </TXLifeRequest>   
</TXLife>

XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns="http://ACORD.org/Standards/Life/2">
    <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>


    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()" />
        </xsl:copy>
    </xsl:template>


    <xsl:template match="@ns:*">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="." />
        </xsl:attribute>
    </xsl:template>


    <xsl:template match="/">

           <xsl:for-each select="/ns:TXLife/ns:TXLifeRequest">

               <xsl:sort select="ns:AccountNumber" order="ascending" data-type="number"/>

           </xsl:for-each>
            <xsl:apply-templates select="*"></xsl:apply-templates> 

    </xsl:template>
</xsl:stylesheet>

出力 :

<?xml version="1.0" encoding="utf-8"?>
<TXLife xmlns="http://ACORD.org/Standards/Life/2">
   <TXLifeRequest>
      <FundCode>LTRT00</FundCode>
      <AccountDescription>CWA – +U</AccountDescription>
      <CurrencyTypeCode>840</CurrencyTypeCode>
      <TransExeDate>2013-04-20</TransExeDate>
      <AccountNumber>34142</AccountNumber>
      <PaymentAmt>300.000000000</PaymentAmt>
      <ReversalInd>0</ReversalInd>
   </TXLifeRequest>
   <TXLifeRequest>
      <FundCode>LTRW00</FundCode>
      <AccountDescription>CWA – +U</AccountDescription>
      <CurrencyTypeCode>124</CurrencyTypeCode>
      <TransExeDate>2013-04-20</TransExeDate>
      <AccountNumber>14142</AccountNumber>
      <PaymentAmt>250.000000000</PaymentAmt>
      <ReversalInd>0</ReversalInd>
   </TXLifeRequest>
</TXLife>

xslt に何が欠けているのかわかりません。data-type="text" で試しましたが、出力はまだソートされていません。

4

1 に答える 1

1

for-eachループで何も出力していません。
を に移動apply-templatesfor-eachます。次のようなことを行う必要があります。

<xsl:template match="/">
    <xsl:for-each select="/ns:TXLife/ns:TXLifeRequest">
        <xsl:sort select="ns:AccountNumber" order="ascending" data-type="number"/>
        <xsl:copy>
            <xsl:apply-templates select="*"></xsl:apply-templates>      
        </xsl:copy>
    </xsl:for-each>
</xsl:template>
于 2013-05-23T11:25:40.250 に答える