2012-02-01 24 views
0

私のXML構造XSL - 他のXMLに基づく表示 - 条件付き

<AccountDetails> 
<AdditionalPvtDetails seq="1" id="110095115"> 
<PvtClientFullname>YYYY</PvtClientFullname> 
<PvtGender>FEMALE</PvtGender> 
<PvtIdentification> 
<PvtVoterID>KXF1067981</PvtVoterID> 
</PvtIdentification> 
<PvtAddress> 
<AdditionalAddressDetails seq="1"> 
<Addressline>ST2</Addressline> 
<State>OH</State> 
<PIN>56708</PIN> 
</AdditionalAddressDetails> 
</PvtAddress> 
</AdditionalPvtDetails> 
<AdditionalPvtDetails seq="2" id="110095163"> 
<PvtClientFullname>YYYY </PvtClientFullname> 
<PvtGender>FEMALE</PvtGender> 
<PvtIdentification/> 
<PvtAddress> 
<AdditionalAddressDetails seq="1"> 
<Addressline>ST2</Addressline> 
<State>OH</State> 
<PIN>56708</PIN> 
</AdditionalAddressDetails> 
</PvtAddress> 
</AdditionalPvtDetails> 
<AdditionalPvtDetails seq="3" id="110095180"> 
<PvtClientFullname>YYYY</PvtClientFullname> 
<PvtGender>FEMALE</PvtGender> 
<PvtIdentification/> 
<PvtAddress> 
<AdditionalAddressDetails seq="1"> 
<Addressline>ST1</Addressline> 
<State>OH</State> 
<PIN>56708</PIN> 
</AdditionalAddressDetails> 
</PvtAddress> 
</AdditionalPvtDetails> 
<Account seq="1" id="110095115" ReportedDate="2011-07-11"> 
<AccountNumber> 8601N70201</AccountNumber> 
<CurrentBalance>0</CurrentBalance> 
<Institution>Pvt Limited</Institution> 
<DisbursedAmount>12000</DisbursedAmount> 
<LoanPurpose>510</LoanPurpose> 
<SanctionAmount>12000</SanctionAmount> 
<DateReported>2011-07-11</DateReported> 
<DateOpened>2009-09-24</DateOpened> 
<DateClosed>2010-09-09</DateClosed> 
<LoanCycleID>01</LoanCycleID> 
<DateSanctioned>2009-09-18</DateSanctioned> 
<DateApplied>2009-09-17</DateApplied> 
<AppliedAmount>12000</AppliedAmount> 
<NoOfInstallments>50</NoOfInstallments> 
<RepaymentTenure>Weekly</RepaymentTenure> 
<InstallmentAmount>276</InstallmentAmount> 
<KeyPerson> 
<Name>XXX</Name> 
<RelationType>Husband</RelationType> 
</KeyPerson> 
<Nominee> 
<Name/> 
<RelationType/> 
</Nominee> 
<AccountStatus>Closed Account</AccountStatus> 
</Account> 
<Account seq="2" id="110095163" ReportedDate="2011-07-11"> 
<AccountNumber> 8601N70202</AccountNumber> 
<CurrentBalance>4400</CurrentBalance> 
<Institution>Pvt Limited</Institution> 
<DisbursedAmount>20000</DisbursedAmount> 
<LoanPurpose>302</LoanPurpose> 
<SanctionAmount>20000</SanctionAmount> 
<DateReported>2011-07-11</DateReported> 
<DateOpened>2010-09-30</DateOpened> 
<LoanCycleID>02</LoanCycleID> 
<DateSanctioned>2010-09-24</DateSanctioned> 
<DateApplied>2010-09-23</DateApplied> 
<AppliedAmount>20000</AppliedAmount> 
<NoOfInstallments>50</NoOfInstallments> 
<RepaymentTenure>Weekly</RepaymentTenure> 
<InstallmentAmount>460</InstallmentAmount> 
<KeyPerson> 
<Name>XXX</Name> 
<RelationType>Husband</RelationType> 
</KeyPerson> 
<Nominee> 
<Name/> 
<RelationType/> 
</Nominee> 
<AccountStatus>Current Account</AccountStatus> 

</Account> 
<Account seq="3" id="110095180" ReportedDate="2011-07-11"> 
<AccountNumber> 8601N7201</AccountNumber> 
<CurrentBalance>0</CurrentBalance> 
<Institution>Pvt Limited</Institution> 
<DisbursedAmount>4000</DisbursedAmount> 
<LoanPurpose>510</LoanPurpose> 
<SanctionAmount>4000</SanctionAmount> 
<DateReported>2011-07-11</DateReported> 
<DateOpened>2010-03-04</DateOpened> 
<DateClosed>2011-02-17</DateClosed> 
<LoanCycleID>01</LoanCycleID> 
<DateSanctioned>2010-02-19</DateSanctioned> 
<DateApplied>2010-02-18</DateApplied> 
<AppliedAmount>4000</AppliedAmount> 
<NoOfInstallments>50</NoOfInstallments> 
<RepaymentTenure>Weekly</RepaymentTenure> 
<InstallmentAmount>92</InstallmentAmount> 
<KeyPerson> 
<Name>XXX</Name> 
<RelationType>Husband</RelationType> 
</KeyPerson> 
<Nominee> 
<Name/> 
<RelationType/> 
</Nominee> 
<AccountStatus>Closed Account</AccountStatus> 
</Account> 
</AccountDetails> 

を下回っていると私は私が「AdditionalPvtDetailsを一致させることができます方法を知りたい

ID:110095115 Name :YYYY  Account number : 8601N70201 Status : Closed Account No.Of Install:50 
ID:110095163 Name :YYYY  Account number : 8601N70202 Status : Current Account No.Of Install:50 

以下のような出力を探しています"名前のような項目、Geneder、各"アカウント "情報の識別と上記のように出力をフォーマットします。" AdditinalPvtDetails "と" account "は" Id "によって結合されなければなりません...

答えて

2

私は信じていますこれは、ルックアップをするために使用することができ追加というキーを作成し

<xsl:key name="additional" match="AdditionalPvtDetails" use="@id" /> 

アカウント上に位置しながら、AdditionalPvtDetails要素をルックアップするために、ここで重要な要素を :あなたはXSLの使用を作ることができますAdditionalPvtDetailsid属性を使用します。たとえば、次のようにアカウント要素の上に配置したと仮定すると、そのアカウントの性別を調べることができます:

<xsl:value-of select="key('additional', @id)/PvtGender" /> 

を簡単な例として、考えるこのXSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="text" indent="yes"/> 
    <xsl:key name="additional" match="AdditionalPvtDetails" use="@id" /> 

    <xsl:template match="/"> 
     <xsl:apply-templates select="AccountDetails/Account" /> 
    </xsl:template> 

    <xsl:template match="Account"> 
     <xsl:value-of select="concat('AccountID: ', @id, ' ')" /> 
     <xsl:value-of select="concat('Gender: ', key('additional', @id)/PvtGender, '&#13;')" /> 
    </xsl:template> 
</xsl:stylesheet> 

を適用した場合サンプルのXMLには、以下が返されます。

AccountID: 110095115 Gender: FEMALE 
AccountID: 110095163 Gender: FEMALE 
AccountID: 110095180 Gender: FEMALE 
関連する問題