我开始学习 xslt 来操作 xml 并尝试扁平化具有许多不同子节点和孙节点的 xml。是否有任何简单的 xslt 可以将输入 xml 转换为 output.xml。
输入.xml:
<Addresses>
<Address__c>
<Id>a0H20000002uhsyEAA</Id>
<R00N20000001XA10EAG>
<Customer_Installation_Address__c>
<Id>a0L2000000DDpOCEA1</Id>
</Customer_Installation_Address__c>
<Customer_Installation_Address__c>
<Id>a0L2000000DDpOCEB2</Id>
</Customer_Installation_Address__c>
</R00N20000001XA10EAG>
<Customers__r>
<Account>
<Id>001M000000FOEiHIAX</Id>
</Account>
<Account>
<Id>001M000000FOAAbIAP</Id>
</Account>
</Customers__r>
<Cases__r>
<Case>
<Id>500D000000G7drpIAB</Id>
</Case>
</Cases__r>
</Address__c>
<Address__c>
<Id>a0H20000003JjyzEAC</Id>
<Cases__r>
<Case>
<Id>500D000000G7drpIAB</Id>
</Case>
</Cases__r>
</Address__c>
<Address__c>
<Id>a0HD0000007wQ0EMAU</Id>
<Customers__r>
<Account>
<Id>001M000000FOEiHIAX</Id>
</Account>
<Account>
<Id>001M000000FOAAbIAP</Id>
</Account>
</Customers__r>
</Address__c>
</Addresses>
并希望产生以下 xml 输出。
输出.xml
<Addresses>
<Address__c>
<AddrId>a0H20000002uhsyEAA</AddrId>
<CIAddressId>a0L2000000DDpOCEA1</CIAddressId>
<CIAddressId>a0L2000000DDpOCEB2</CIAddressId>
<AccountId>001M000000FOEiHIAX</AccountId>
<AccountId>001M000000FOAAbIAP</AccountId>
<CaseId>500D000000G7drpIAB</CaseId>
</Address__c>
<Address__c>
<AddrId>a0H20000003JjyzEAC</AddrId>
<CaseId>500D000000G7drpIAB</CaseId>
</Address__c>
<Address__c>
<AddrId>a0HD0000007wQ0EMAU</AddrId>
<AccountId>001M000000FOEiHIAX</AccountId>
<AccountId>001M000000FOAAbIAP</AccountId>
</Address__c>
</Addresses>