Pablo Castilla
Pablo Castilla

Reputation: 2741

Biztalk maps: Grouping different nodes into a list

Is there a way of achieve the following transformation in the BT mapper? if not, any smart idea?

<Person>
<Age>25</Age>
<Name>Paul</Name>
</Person>

to:

<Person>
<CustomProperties>
<CustomProperty>
<Name>Age</Name>
<Value>25</VAlue>
</CustomProperty>
<CustomProperty>
<Name>Name</Name>
<Value>Paul</VAlue>
</CustomProperty>
</CustomProperties>

I have to aggregate a few elements in a list of nodes.

Thanks in advance.

Upvotes: 3

Views: 1194

Answers (3)

Jay
Jay

Reputation: 14481

It looks like you have a straight forward mapping from input to output. When you do your mapping right click on the line drawn from the input to the output. Select "Properties". There are options to either copy the value of the input node or the name of the input node. You can use two mappings from each child node, one to extract the name and one for the value.

Upvotes: 0

BizTalkMama
BizTalkMama

Reputation: 308

You can also use the TableLooping / TableExtractor functoids in your map to build the destination nodes.

See this post for an example:

http://hestia.typepad.com/flatlander/2007/01/mapping_fixed_e.html

Upvotes: 3

Tomalak
Tomalak

Reputation: 338376

Don't know much about the BizTalk mapper, but the required XSLT would be fairly straight-forward:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="Person">
    <xsl:copy>
      <CustomProperties>
        <xsl:apply-templates select="*" />
      </CustomProperties>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="Person/*">
    <CustomProperty>
      <Name><xsl:value-of select="name()" /></Name>
      <Value><xsl:value-of select="." /></Value>
    </CustomProperty>
  </xsl:template>
</xsl:stylesheet>

Upvotes: 2

Related Questions