views:

140

answers:

2

Hello,

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.

+2  A: 

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"&gt;
  <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>
Tomalak
+3  A: 

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

BizTalkMama
That's exactly what I was looking for!
Pablo Castilla