I need to map 2 fields from a large schema to a small schema (below), to produce a message to be sent to make a web service call.
<xs:element name="ds">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string"></xs:element>
<xs:element name="d1" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
The same web method is used to update many different items, so contains 2 parameters: ID and another general update field which will take the text value of the update.
The ID parameter is always called ID, but depending on the type of item I have to update, the second parameter will change it's name.
So, in the BizTalk map (which I'm guessing should be XSLT): The first field mapped across is an ID field, going from TargetID in source to ID in destination. This is a direct mapping. The second field will always be mapped to a field called 'd1'. Based on an xsl:if, the node name of d1 will change. eg:
if changeType in large schema = 'forename', d1 will become d_forename
if changeType in large schema = 'surname', d1 will become d_surname and so on.
There are going to be around 20 possible changeTypes, so I guess my question is, if I use an xsl:choose to evaluate the changeType (which will give me my ID and update value) how can I at the same time return the new name for the <d1>
node? I know it will be a called template but unsure where to start with this.
What you are looking for is presumable the possibilities around element naming.
What happens most of the time is the following:
<d_someOtherNode>
<xsl:value-of select="/root/someOtherNode/text()" />
</d_someOtherNode>
However, what you can also do is:
<xs:element name="{concat('d_', name(/root/someOtherNode))}">
<xsl:value-of select="/root/someOtherNode/text()" />
</xs:element>
The latter allows you to name the element as you please, in this case, concatenating the d_
and name of the element you need (someOtherNode
).
Put this in the "if" structure or choose/when structure as you please, depending on your solution.