我似乎無法根據他們的MaritalStatus來管理分組情侶。
我已經設法將所有處於關係中的人('DeFacto','已婚')分組,但無法弄清楚如何將他們分組到不同的家庭。XSLT 2,按屬性和元素分組多個
基本上,如果兩個人做一對夫婦,他們將創建一個家庭。家庭名稱將屬於家庭中的第一人稱姓氏,NumberOfAdults將被硬編碼爲'2',NumberOfDependants將被計算在內。
這對夫妻是基於鏈接的Party.Identifier和Party.MaritalStatus.RelatedEntityRef
我有什麼(簡體):
<PartySegment>
<Party Type="Guarantor" PrimaryApplicant="No">
<Identifier>b8b0f908b08e</Identifier>
<Person Sex="Female" FirstHomeBuyer="No" CustomerOfLender="No">
<PersonName>
<NameTitle Value="Lady"/>
<FirstName>Clemansa</FirstName>
<Surname>Sanchez</Surname>
</PersonName>
<MaritalStatus Status="DeFacto">
<RelatedEntityRef>ea384b0bf3f5</RelatedEntityRef>
</MaritalStatus>
<NumberOfDependents>1</NumberOfDependents>
</Person>
</Party>
<Party Type="Applicant" PrimaryApplicant="Yes" ExistingCustomerID="1231">
<Identifier>bd8c65a3ad80</Identifier>
<Person Sex="Female" FirstHomeBuyer="Yes" CustomerOfLender="Yes">
<PersonName>
<NameTitle Value="Mrs"/>
<FirstName>Cheryl</FirstName>
<Surname>Bonkers</Surname>
</PersonName>
<MaritalStatus Status="Married">
<RelatedEntityRef>ee84dc9e38ec</RelatedEntityRef>
</MaritalStatus>
<NumberOfDependents>2</NumberOfDependents>
</Person>
</Party>
<Party Type="Guarantor" PrimaryApplicant="No">
<Identifier>ea384b0bf3f5</Identifier>
<Person Sex="Male" FirstHomeBuyer="No" CustomerOfLender="No">
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>Greg</FirstName>
<OtherName>Morty</OtherName>
<Surname>Sanchez</Surname>
</PersonName>
<MaritalStatus Status="DeFacto">
<RelatedEntityRef>b8b0f908b08e</RelatedEntityRef>
</MaritalStatus>
<NumberOfDependents>0</NumberOfDependents>
</Person>
</Party>
<Party Type="Applicant" PrimaryApplicant="No">
<Identifier>ee84dc9e38ec</Identifier>
<Person Sex="Male" FirstHomeBuyer="No" CustomerOfLender="No">
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>Mark</FirstName>
<Surname>Bonkers</Surname>
</PersonName>
<MaritalStatus Status="Married">
<RelatedEntityRef>bd8c65a3ad80</RelatedEntityRef>
</MaritalStatus>
<NumberOfDependents>0</NumberOfDependents>
</Person>
</Party>
</PartySegment>
的願望輸出:
<Household UniqueID="b8b0f908b08e-Household"
Name="Sanchez Household"
NumberOfAdults="2"
NumberOfDependants="1"/>
<Household UniqueID="bd8c65a3ad80-Household"
Name="Bonkers Household"
NumberOfAdults="2"
NumberOfDependants="2"/>
我到目前爲止(簡化):這是一對夫婦工作,因爲沒有考慮到MaritalStatus.RelatedEntityRef信息
<xsl:template match="PartySegment" mode="Household_Couple">
<xsl:for-each-group select="Party[Person/MaritalStatus/@Status = ('DeFacto', 'Married')]" group-by="Person/MaritalStatus/@Status = ('DeFacto', 'Married')">
<xsl:variable name="owner_id" select="Identifier"/>
<Household UniqueID="{concat(Identifier, '-Household')}"
Name="{normalize-space(concat(Person/PersonName/Surname, ' Household'))}"
NumberOfAdults="{'2'}"
NumberOfDependants="{if(Person/Dependent) then count(current-group()/Person/Dependent) else if(Person/NumberOfDependents) then sum(current-group()/Person/NumberOfDependents) else '0'}">
<xsl:apply-templates select="current-group()/Person/Dependent"/>
</Household>
</xsl:for-each-group>
</xsl:template>
我不知道它是一個任務組,似乎很要遵循交叉參照的關鍵。是否有某種方法可以區分'Party'元素,處理所有的Party [@Type ='擔保人'和Person/MaritalStatus/@ Status =('DeFacto','Married')]'就足夠了,然後簡單地搜索引用其他具有'和'key'('ref',MaritalStatus/RelatedEntityRef)''的Party' –
黨元素只能是申請人或擔保人。有些合夥人處於一種關係中(DeFacto,已婚)和分擔費用(並且屬於一個家庭),有些是單身,離婚等費用,這創造了他們自己的家庭。 我已經實現了爲一個人創建一個家庭的人員的所有信息,但不適用於多個夫婦(正在爲一對夫婦工作) – DanielCSD