我正在尝试使用身份/复制模式来仅转换下面的 Segments/Segment 部分并保留结构的其余部分。模板会是什么样子?我尝试了论坛中的一些示例以在 xslt:for-each SegmentFares/Segments/Segment 中应用模板,但我不知道如何将基本票价放在第一个 SegmentFare 中,并将其设置为零在剩余的后续部分中段。
输入 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>