Thursday, August 22, 2013

Modify XML using XSL outbound transform AX 2012



Once I got a client requirement to make changes into the outbound XML generation of electronic VendPayment. Since their bank was not able to accept the current format of the XML generated from AX.
The XML includes Envelope and Header tags with output XML which sometimes needs to be truncated so that the third party applications can read the output XML.
To resolve this I started fresh by configuring the VendPayment using AIF outbound port setup using following Link.
The only change in the above configuration I did is I included the XSL file generated from the resources to outbound pipeline, no changes here,
I created a second XSL and added it into the outbound transformation(see below)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:wt="schemas.microsoft.com/.../Message" xmlns:xsl="www.w3.org/.../Transform">
            <xsl:output version="1.0" omit-xml-declaration="no" indent="yes" encoding="UTF-8" method="xml"/>
           
<!--Copy all nodes from source-->
-<xsl:template match="@*|node()">-<xsl:copy>
                                    <xsl:apply-templates select="@* | node()"/>
                        </xsl:copy>
            </xsl:template>
           
            <!--Remove header, message parts, body and envelope tags-->
            <xsl:template match="wt:Envelope/wt:Header"/>-<xsl:template match="wt:Envelope/wt:Body/wt:MessageParts">
                        <xsl:apply-templates/>
            </xsl:template>-<xsl:template match="wt:Envelope/wt:Body">
                        <xsl:apply-templates/>
            </xsl:template>-<xsl:template match="wt:Envelope">
                        <xsl:apply-templates/>
            </xsl:template>
</xsl:stylesheet>

This gave me XML document without Envelope, Message part, Body and Header

Reference: http://community.dynamics.com/ax/f/33/t/102465.aspx#.Uhb2Uz_66qk


4 comments:

  1. Hi,

    After the transformation I lose the "xml" tag despite omit-xml-declaration is "no"

    Did you have the same problem? Thanks

    ReplyDelete
  2. Hi Pedro,

    We are getting similar issue. Are you able to resolve this problem?

    Please provide some suggestion.

    Angna

    ReplyDelete
    Replies
    1. Hi guys, I had the similar issue with my XML, however I tested it by sending to the client's bank and the bank accepted the resulting XML. Also when I try to open the file in Internet Explorer I was able to see the XML tag. I hope this helps :)

      Delete
  3. This comment has been removed by the author.

    ReplyDelete