ID/복사 패턴을 사용하여 아래의 세그먼트/세그먼트 부분 만 변환하고 나머지 구조는 유지하려고합니다. 템플릿은 어떻게 생겼을까요? 나는 xslt : for-each SegmentFares/Segments/Segment에 템플릿을 적용하기 위해 포럼에서 몇 가지 예제를 시도했지만 첫 번째 SegmentFare에 기본 요금을 넣는 방법을 알지 못하고 나머지 SegmentFare의 후속 항목을 0으로 설정하는 방법을 모르겠습니다. 세그먼트.XSLT를 사용하여 XML을 변환하는 데 도움이 필요합니다.
입력 XML :
<FareQuoteRS>
<PaxFareQuotes>
<item>
<PTC>ADT</PTC>
<TotalFare>
<Currency>INR</Currency>
<Fare>8403</Fare>
<TotalBaseFare>3620</TotalBaseFare>
</TotalFare>
<SegmentFares>
<SegmentFare>
<Currency>INR</Currency>
<BaseFare>3620</BaseFare>
<Segments>
<Segment>
<Origin>DEL</Origin>
<Destination>BOM</Destination>
<DeptrDate>2012-06-23</DeptrDate>
<DeptrTime>10:10</DeptrTime>
<ArrDate>2012-06-23</ArrDate>
<ArrTime>12:15</ArrTime>
<FareBasis>J</FareBasis>
<PromoCode></PromoCode>
<FltNum>109</FltNum>
<Airline>YY</Airline>
<BagAllow>20K</BagAllow>
</Segment>
<Segment>
<Origin>BOM</Origin>
<Destination>GOI</Destination>
<DeptrDate>2012-06-23</DeptrDate>
<DeptrTime>15:15</DeptrTime>
<ArrDate>2012-06-23</ArrDate>
<ArrTime>16:20</ArrTime>
<FareBasis>J</FareBasis>
<PromoCode></PromoCode>
<FltNum>248</FltNum>
<Airline>YY</Airline>
<BagAllow>20K</BagAllow>
</Segment>
</Segments>
</SegmentFare>
</SegmentFares>
<Taxes>
<Currency>INR</Currency>
<TotalTaxes>4783</TotalTaxes>
<item>
<TaxCode>YQ</TaxCode>
<TaxName>Fuel Surcharge</TaxName>
<Currency>INR</Currency>
<TaxAmount>3150</TaxAmount>
</item>
<item>
<TaxCode>WO</TaxCode>
<TaxName>PSF</TaxName>
<Currency>INR</Currency>
<TaxAmount>146</TaxAmount>
</item>
<item>
<TaxCode>IN</TaxCode>
<TaxName>UDF</TaxName>
<Currency>INR</Currency>
<TaxAmount>745</TaxAmount>
</item>
<item>
<TaxCode>JN</TaxCode>
<TaxName>Service Tax</TaxName>
<Currency>INR</Currency>
<TaxAmount>335</TaxAmount>
</item>
<item>
<TaxCode>TF</TaxCode>
<TaxName>Transaction Fee</TaxName>
<Currency>INR</Currency>
<TaxAmount>407</TaxAmount>
</item>
</Taxes>
</item>
</PaxFareQuotes>
<Status>Success</Status>
<StatusRemark/>
</FareQuoteRS>
출력 XML :
<FareQuoteRS>
<PaxFareQuotes>
<item>
<PTC>ADT</PTC>
<TotalFare>
<Currency>INR</Currency>
<Fare>8403</Fare>
<TotalBaseFare>3620</TotalBaseFare>
</TotalFare>
<SegmentFares>
<!-- There is now one SegmentFare for each Segment in the input -->
<!-- while the BaseFare is set to zero for the subsequent segments -->
<SegmentFare>
<Currency>INR</Currency>
<BaseFare>3620</BaseFare>
<Segments>
<Segment>
<Origin>DEL</Origin>
<Destination>BOM</Destination>
<DeptrDate>2012-06-23</DeptrDate>
<DeptrTime>10:10</DeptrTime>
<ArrDate>2012-06-23</ArrDate>
<ArrTime>12:15</ArrTime>
<FareBasis>J</FareBasis>
<PromoCode></PromoCode>
<FltNum>109</FltNum>
<Airline>YY</Airline>
<BagAllow>20K</BagAllow>
</Segment>
</Segments>
</SegmentFare>
<SegmentFare>
<Currency>INR</Currency>
<BaseFare>0</BaseFare>
<Segments>
<Segment>
<Origin>BOM</Origin>
<Destination>GOI</Destination>
<DeptrDate>2012-06-23</DeptrDate>
<DeptrTime>15:15</DeptrTime>
<ArrDate>2012-06-23</ArrDate>
<ArrTime>16:20</ArrTime>
<FareBasis>J</FareBasis>
<PromoCode></PromoCode>
<FltNum>248</FltNum>
<Airline>YY</Airline>
<BagAllow>20K</BagAllow>
</Segment>
</Segments>
</SegmentFare>
</SegmentFares>
<Taxes>
<Currency>INR</Currency>
<TotalTaxes>4783</TotalTaxes>
<item>
<TaxCode>YQ</TaxCode>
<TaxName>Fuel Surcharge</TaxName>
<Currency>INR</Currency>
<TaxAmount>3150</TaxAmount>
</item>
<item>
<TaxCode>WO</TaxCode>
<TaxName>PSF</TaxName>
<Currency>INR</Currency>
<TaxAmount>146</TaxAmount>
</item>
<item>
<TaxCode>IN</TaxCode>
<TaxName>UDF</TaxName>
<Currency>INR</Currency>
<TaxAmount>745</TaxAmount>
</item>
<item>
<TaxCode>JN</TaxCode>
<TaxName>Service Tax</TaxName>
<Currency>INR</Currency>
<TaxAmount>335</TaxAmount>
</item>
<item>
<TaxCode>TF</TaxCode>
<TaxName>Transaction Fee</TaxName>
<Currency>INR</Currency>
<TaxAmount>407</TaxAmount>
</item>
</Taxes>
</item>
</PaxFareQuotes>
<Status>Success</Status>
<StatusRemark/>
</FareQuoteRS>
멋진! 나는 항상 새로운 것을 배웁니다. 둘 다 대단히 감사합니다. 두 대답은 모두 놀랍습니다. 둘 다 올바른 것으로 표시 할 수는 없지만 하나를 표시하고 두 가지를 모두 유용하게 설정합니다. – Surge