私は次のXMLを持っています
<ExternalAssessmentRequest >
<ApplicationData Lender="TEST">
<LiabilityList>
<RequestedLoan Identifier="New1" BaseAmount="250000">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
<Feature Code="SupaPackage"/>
</RequestedLoan>
<ExistingLoan Identifier="Existing1" Clearing="Yes" >
<Security RelatedIdentifier="Asset1"/>
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</ExistingLoan>
<OtherLiability Identifier="Liability1" CreditCard="Yes" >
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</OtherLiability>
<Expense Identifier="Expense1" Type="Transport" >
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Expense>
</LiabilityList>
<AssetList>
<Asset Identifier="Asset1" Security="Yes" >
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Asset>
<Fund Identifier="Fund1" Amount="1000" Description="Slush Fund"/>
</AssetList>
<IncomeList>
<Income Identifier="Income1" GrossAmount="80000" >
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Income>
</IncomeList>
<ApplicantList>
<Household Children="0" AdditionalAdults="0" Postcode="2000" Description="1 Test St, Sydney" Boarding="Yes">
<Person Identifier="Applicant1" Name="John Test" />
<Person Identifier="Applicant2" Name="Jane Test" />
</Household>
<Company Identifier="Company1" Name="Tardis">
<Director RelatedIdentifier="Applicant1"/>
</Company>
</ApplicantList>
<FeeList>
<Fee Identifier="Fee1" Amount="100" PaidAmount="0" />
</FeeList>
</ApplicationData>
<AdditionalAssessment Lender="TESTLender">
<RequestedLoan Product="Supa Variable" ProductID="ProductA"/>
</AdditionalAssessment>
<AdditionalAssessment Lender="TEST1">
<RequestedLoan Product="Supa Variable" ProductID="ProductB"/>
</AdditionalAssessment>
<AdditionalAssessment Lender="TEST2">
<RequestedLoan Product="Supa Variable" ProductID="ProductC"/>
</AdditionalAssessment>
<AdditionalAssessment Lender="TEST3">
<RequestedLoan Product="Supa Variable" ProductID="ProductD"/>
</AdditionalAssessment>
<AdditionalAssessment Lender="TEST4">
<RequestedLoan Product="Supa Variable" ProductID="ProductD"/>
</AdditionalAssessment>
</ExternalAssessmentRequest>
そして私はこのスタイルシートを持っています:
<?xml version="1.0" encoding="ascii"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output omit-xml-declaration="yes" method="xml" encoding="UTF-8"/>
<!--remember the location of the additional assessment information-->
<xsl:variable name="additional" select="/*/AdditionalAssessment"/>
<xsl:template match="ApplicationData">
<!--preserve original data-->
<xsl:copy-of select="."/>
<!--now make duplicate-->
<ApplicationData>
<!--preserve data attributes-->
<xsl:copy-of select="@*"/>
<!--override with additional attributes-->
<xsl:copy-of select="$additional/@*"/>
<!--process children looking for modifications to attributes-->
<xsl:apply-templates select="node()" mode="overrideAttributes"/>
</ApplicationData>
</xsl:template>
<!--copy the element and override attributes form the additional assessment-->
<xsl:template match="*" mode="overrideAttributes">
<xsl:copy>
<!--preserve data attributes-->
<xsl:copy-of select="@*"/>
<!--override with additional attributes-->
<xsl:copy-of select="$additional/*[name(.)=name(current())]/@*"/>
<!--manipulate the descendants-->
<xsl:apply-templates mode="overrideAttributes"/>
</xsl:copy>
</xsl:template>
<!--remove the original additional assessment-->
<xsl:template match="AdditionalAssessment"/>
<xsl:template match="@*|node()">
<!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/ExternalAssessmentRequest">
<xsl:element name="ApplicationDataBatch">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
次の出力が生成されます。
<ApplicationDataBatch>
<ApplicationData Lender="TEST">
<LiabilityList>
<RequestedLoan Identifier="New1" BaseAmount="250000">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
<Feature Code="SupaPackage"/>
</RequestedLoan>
<ExistingLoan Identifier="Existing1" Clearing="Yes">
<Security RelatedIdentifier="Asset1"/>
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</ExistingLoan>
<OtherLiability Identifier="Liability1" CreditCard="Yes">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</OtherLiability>
<Expense Identifier="Expense1" Type="Transport">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Expense>
</LiabilityList>
<AssetList>
<Asset Identifier="Asset1" Security="Yes">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Asset>
<Fund Identifier="Fund1" Amount="1000" Description="Slush Fund"/>
</AssetList>
<IncomeList>
<Income Identifier="Income1" GrossAmount="80000">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Income>
</IncomeList>
<ApplicantList>
<Household Children="0" AdditionalAdults="0" Postcode="2000" Description="1 Test St, Sydney" Boarding="Yes">
<Person Identifier="Applicant1" Name="John Test"/>
<Person Identifier="Applicant2" Name="Jane Test"/>
</Household>
<Company Identifier="Company1" Name="Tardis">
<Director RelatedIdentifier="Applicant1"/>
</Company>
</ApplicantList>
<FeeList>
<Fee Identifier="Fee1" Amount="100" PaidAmount="0"/>
</FeeList>
</ApplicationData>
<ApplicationData Lender="TEST4">
<LiabilityList>
<RequestedLoan Identifier="New1" BaseAmount="250000" Product="Supa Variable" ProductID="ProductD">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
<Feature Code="SupaPackage"/>
</RequestedLoan>
<ExistingLoan Identifier="Existing1" Clearing="Yes">
<Security RelatedIdentifier="Asset1"/>
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</ExistingLoan>
<OtherLiability Identifier="Liability1" CreditCard="Yes">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</OtherLiability>
<Expense Identifier="Expense1" Type="Transport">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Expense>
</LiabilityList>
<AssetList>
<Asset Identifier="Asset1" Security="Yes">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Asset>
<Fund Identifier="Fund1" Amount="1000" Description="Slush Fund"/>
</AssetList>
<IncomeList>
<Income Identifier="Income1" GrossAmount="80000">
<Applicant RelatedIdentifier="Applicant1" Percentage="0.5"/>
<Applicant RelatedIdentifier="Applicant2" Percentage="0.5"/>
</Income>
</IncomeList>
<ApplicantList>
<Household Children="0" AdditionalAdults="0" Postcode="2000" Description="1 Test St, Sydney" Boarding="Yes">
<Person Identifier="Applicant1" Name="John Test"/>
<Person Identifier="Applicant2" Name="Jane Test"/>
</Household>
<Company Identifier="Company1" Name="Tardis">
<Director RelatedIdentifier="Applicant1"/>
</Company>
</ApplicantList>
<FeeList>
<Fee Identifier="Fee1" Amount="100" PaidAmount="0"/>
</FeeList>
</ApplicationData>
</ApplicationDataBatch>
すべてが本来あるべき姿である 1 つだけ欠けているものがあります。AdditionalAssessment ノードごとに ApplicationData ノードを作成する必要があります。現在のスタイルシートは、5 (+1 元のアプリケーション データ) ではなく 1 つだけを作成します。スタイルシートでは、AdditionalAssessment ノードごとに ApplicationData ノードを作成する必要があり、各追加評価内で指定された要素を変更するだけです。