I'm using a transform stylesheet to convert xml doc A into xml doc B. This is what's part of doc A:
In doc B, I need to flip From information with To information:
My experience with xsl is very limited. What I'm doing right now is this:
and I'm doing a similar thing for 'To'.
I'm sure there's a simplier way (without specifying all those tags: PartnerName, PartnerIdentifier). Can anyone tell me how to write this code in a more efficient way?
Thank you!
Code:
<From>
<PartnerInformation>
<PartnerName>Company A</PartnerName>
<PartnerIdentifier Agency="ID">1</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>Company B</PartnerName>
<PartnerIdentifier Agency="ID">2</PartnerIdentifier>
</PartnerInformation>
</To>
In doc B, I need to flip From information with To information:
Code:
<From>
<PartnerInformation>
<PartnerName>Company B</PartnerName>
<PartnerIdentifier Agency="ID">2</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>Company A</PartnerName>
<PartnerIdentifier Agency="ID">1</PartnerIdentifier>
</PartnerInformation>
</To>
My experience with xsl is very limited. What I'm doing right now is this:
Code:
<xsl:when test="contains(local-name(),'From')">
<PartnerInformation>
<PartnerName>
<xsl:value-of select="/Header/To/PartnerInformation/PartnerName"/>
</PartnerName>
<PartnerIdentifier Agency="ID">
<xsl:value-of select="/Header/To/PartnerInformation/PartnerIdentifier"/>
</PartnerIdentifier>
</PartnerInformation>
</xsl:when>
I'm sure there's a simplier way (without specifying all those tags: PartnerName, PartnerIdentifier). Can anyone tell me how to write this code in a more efficient way?
Thank you!