2

I'm going to be working the MS AX2010. When accessing data through an AX WCF service, the response is XML containing name / value pairs - known as a key data list. I'll be collecting this XML in BizTalk and needing to transform it to a canonical hierarchical schema. So for example, if I read a source Name element with "OrderNumber", then I would map the associated Value to an OrderNumber element in the destination schema. Has anyone discovered a nice way to do this using a BizTalk map?

Rob Bowman
  • 7,632
  • 22
  • 93
  • 200

1 Answers1

2

I acknowledge that you prefer to use the graphical functoids, but if you can accept an xslt route, it is pretty straightforward (See here for converting a visual map to an xslt). eg. the following XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ns0="inputxmlns"
                xmlns:ns1="outputxmlns"
                exclude-result-prefixes="ns0"
                >
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/ns0:Root">
        <ns1:Root>
            <ns1:Elements>
                <xsl:for-each select="ns0:Elements/ns0:Element">
                    <xsl:element name="ns1:{normalize-space(*[local-name()='Name']/text())}">
                        <xsl:value-of select="ns0:Value/text()"/>
                    </xsl:element>
                </xsl:for-each>
            </ns1:Elements>
        </ns1:Root>
</xsl:template>
</xsl:stylesheet>

Will transform a quasi EAV schema:

<?xml version="1.0" encoding="utf-8"?>
<Root xmlns="inputxmlns">
    <Elements>
        <Element>
            <Name>
                NameOfElement1
            </Name>
            <Value>
                ValueOfElement1
            </Value>
        </Element>
        <Element>
            <Name>
                NameOfElement2
            </Name>
            <Value>
                ValueOfElement2
            </Value>
        </Element>
    </Elements>
</Root>

To this:

<?xml version="1.0" encoding="utf-8"?>
<ns1:Root xmlns:ns1="outputxmlns">
  <ns1:Elements>
    <ns1:NameOfElement1>
                ValueOfElement1
            </ns1:NameOfElement1>
    <ns1:NameOfElement2>
                ValueOfElement2
            </ns1:NameOfElement2>
  </ns1:Elements>
</ns1:Root>
Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285