0

素早い対応に感謝致します。私は両方の答えを試しました。思った通りに動作していません。以下の入力と期待される出力を見つけてください。前もって感謝します

入力: <Billing> <billSummary> <billTo> <accountNumber>130212192 </accountNumber> <MSISDN>1234567890 </MSISDN> </billTo> <tax> <amount>100.12</amount> <description></description> </tax> <charge> <typeCode>はONE_TIME </typeCode> <amount>100.12 </amount> <description>ONE_TIME_CHARGE</description> </charge> <charge> <typeCode>アクセス</typeCode> <amount>100.12 </amount> <description>ACCESS_CHARGE </description> </charge> <tax> <amount>100.12</amount> <description>税は</description> </tax> <charge> <typeCode>FEATURE </typeCode> <amount>100.12 </amount> <description>FEATURE_CHARGE </description> </charge> <deduction> <amount>100.12</amount> <description>調整</description> </deduction> <charge> <typeCode></typeCode> <amount>の放送</amount> <description>時間</description> </charge> <charge> <typeCode>100.12 AIRTIME_CHARGE </typeCode> <amount>LONG_DISTANCE </amount> <description>100.12 LONG_DISTANCE_CHARGE</description> </charge> <charge> <typeCode>ローミング</typeCode> <amount>100.12 </amount> <description>ROAMING_CHARGE </description> </charge> <deduction> <amount>100.12</amount> <description>調整</description> </deduction> </billSummary> <billSummary> <billTo> <accountNumber>を130212192 </accountNumber> <MSISDN>1234567890 </MSISDN> </billTo> <tax> <amount>100.12</amount> <description></description> </tax> <charge> <typeCode>はONE_TIME </typeCode> <amount>100.12 </amount> <description>ONE_TIME_CHARGE</description> </charge> <charge> <typeCode>アクセス</typeCode> <amount>100.12 </amount> <description>ACCESS_CHARGEを</description> </charge> <tax> <amount>100.12 </amount> <description>TAXES </description> </tax> <charge> <typeCode>FEATURE </typeCode> <amount>100.12 </amount> <description>FEATURE_CHARGE </description> </charge> <deduction> <amount>100.12 </amount> <description>ADJUSTMENTS </description> </deduction> <charge> <typeCode>AIRTIME </typeCode> <amount>100.12 </amount> <description>AIRTIME_CHARGE </description> </charge> <charge> <typeCode>LONG_DISTANCE </typeCode> <amount>100.12 </amount> <description>LONG_DISTANCE_CHARGE </description> </charge> <charge> <typeCode>ROAMING </typeCode> <amount>100.12 </amount> <description>ROAMING_CHARGE </description> </charge> <deduction> <amount>100.12 </amount> <description>ADJUSTMENTS</description> </deduction> </billSummary> </Billing>

予想される出力: <Billing> <billSummary> <billTo> <accountNumber>130212192 </accountNumber> <MSISDN>1234567890 </MSISDN> </billTo> <tax> <amount>100.12</amount> <description></description> </tax> <charge> <typeCode>はONE_TIME </typeCode> <amount>100.12 </amount> <description>ONE_TIME_CHARGE</description> </charge> <charge> <typeCode>アクセス</typeCode> <amount>100.12 </amount> <description>ACCESS_CHARGE </description> </charge> <tax> <amount>100.12</amount> <description>税は</description> </tax> <charge> <typeCode>FEATURE </typeCode> <amount>100.12 </amount> <description>FEATURE_CHARGE </description> </charge> <deduction> <amount>100.12</amount> <description>調整</description> </deduction> <charge> <typeCode></typeCode> <amount>の放送</amount> <description>時間</description> </charge> <charge> <typeCode>100.12 AIRTIME_CHARGE </typeCode> <amount>LONG_DISTANCE </amount> <description>100.12 LONG_DISTANCE_CHARGE</description> </charge> <charge> <typeCode>ローミング</typeCode> <amount>100.12 </amount> <description>ROAMING_CHARGE </description> </charge> <deduction> <amount>100.12</amount> <description>調整</description> </deduction> </billSummary> <billSummary> <billTo> <accountNumber>を130212192 </accountNumber> <MSISDN>1234567890 </MSISDN> </billTo> <tax> <amount>100.12</amount> <description></description> </tax> <charge> <typeCode>はONE_TIME </typeCode> <amount>100.12 </amount> <description>ONE_TIME_CHARGE</description> </charge> <charge> <typeCode>アクセス</typeCode> <amount>100.12 </amount> <description>ACCESS_CHARGEを</description> </charge> <tax> <amount>100.12 </amount> <description>TAXES </description> </tax> <charge> <typeCode>FEATURE </typeCode> <amount>100.12 </amount> <description>FEATURE_CHARGE </description> </charge> <deduction> <amount>100.12 </amount> <description>ADJUSTMENTS </description> </deduction> <charge> <typeCode>AIRTIME </typeCode> <amount>100.12 </amount> <description>AIRTIME_CHARGE </description> </charge> <charge> <typeCode>LONG_DISTANCE </typeCode> <amount>100.12 </amount> <description>LONG_DISTANCE_CHARGE </description> </charge> <charge> <typeCode>ROAMING </typeCode> <amount>100.12 </amount> <description>ROAMING_CHARGE </description> </charge> <deduction> <amount>100.12 </amount> <description>ADJUSTMENTS</description> </deduction> </billSummary> </Billing>

4

2 に答える 2

0

Order by node names:

<billSummary>
{
  for $i in /billSummary/*
  order by $i/name()
  return $i
}
</billSummary>

In case you want to group only items inside each bill, loop over all <billSummary/>-nodes:

for $bill in //billSummary
return
  <billSummary>
  {
    for $item in $bill/*
    order by $item/name()
    return $item
  }
  </billSummary>

If you need to wrap some node around your answer, you should be able to do it yourself; your question does not contain the information necessary.

于 2012-11-22T11:27:32.860 に答える
0

How about this:

doc("c:\temp\temp.xml")/
<billSummary>
  {
  for $e in billSummary/*
  order by local-name($e)
  return $e
  }
</billSummary>
于 2012-11-22T11:32:12.190 に答える