If mapping Schema input has a Deriviation type.If you have compare the sibling element in sequence with Sibling elements in other similar record then best way is to go with XSLT Template. Here Electronic Email is Derivation Type With Sequence of Type Any and Sequence of Email Address.
Each EmailAddress is associated with ContactType (ex. Primary Email, secondary email etc).
Here we are comparing for example Primary E-mail address from Record 1 with Record 2. If Record 1 is present then assign it to output if not then assign it from Record2.
Here we used Inline XSLT call template compared Both values and the assigned it to Email-Add-1 to 3.
Inline XSLT is as follows:
xsl:template name="MyBarCodeXsltConcatTemplate1">
<xsl:param name="seqno1"/>
<xsl:choose>
<xsl:when test ="string-length(/*[local-name()='DetailedRecordWrapper' and namespace-uri()='uri1:1']/*[local-name()='DetailedRecord' and namespace-uri()='uri2:2']/*[local-name()='SingleRecords' and namespace-uri()='uri2:2']/*[local-name()='SingleRecord' and namespace-uri()='uri2:2'][$seqno1+0]/*[local-name()='UpdatedContacts' and namespace-uri()='uri2:2']/*[local-name()='Contact' and namespace-uri()='uri2:2']/*[local-name()='EmailAddress'][../*[local-name()='ContactType']/text( )='Primary E-mail']/text()) > 0" >
<xsl:element name="CUST-EMAIL-ADD-1"><xsl:value-of select = "/*[local-name()='DetailedRecordWrapper' and namespace-uri()='uri1:1']/*[local-name()='DetailedRecord' and namespace-uri()='uri2:2']/*[local-name()='SingleRecords' and namespace-uri()='uri2:2']/*[local-name()='SingleRecord' and namespace-uri()='uri2:2'][$seqno1+0]/*[local-name()='UpdatedContacts' and namespace-uri()='uri2:2']/*[local-name()='Contact' and namespace-uri()='uri2:2']/*[local-name()='EmailAddress'][../*[local-name()='ContactType']/text( )='Primary E-mail']/text()"/></xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="CUST-EMAIL-ADD-1">
<xsl:value-of select = "/*[local-name()='DetailedRecordWrapper' and namespace-uri()='uri1:1']/*[local-name()='DetailedRecord' and namespace-uri()='uri2:2']/*[local-name()='SingleRecords' and namespace-uri()='uri2:2']/*[local-name()='SingleRecord' and namespace-uri()='uri2:2'][$seqno1+0]/*[local-name()='Survey' and namespace-uri()='uri2:2']/*[local-name()='Unit' and namespace-uri()='uri2:2']/*[local-name()='Contacts' and namespace-uri()='uri2:2']/*[local-name()='Contact' and namespace-uri()='uri2:2']/*[local-name()='EmailAddress' and namespace-uri()='uri2:2'][../*[local-name()='ContactType']/text( )='Primary E-mail']/text()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
------------------
Important thing worth to mention is seqno+0 gives the correct result, though mathematically it seems absurd.
seqno- Looping Iteration
/*[local-name()='EmailAddress' and namespace-uri()='uri2:2'][../*[local-name()='ContactType']/text( )='Primary E-mail']/text()"
This one checks EmailAddress with the sibling record ContactType-"Primary E-mail"
No comments:
Post a Comment