For example, the following XML document is created for a customer sales invoice.
<?xmlversion=“1.0“encoding=“UTF-8“?>
<Envelopexmlns=“http://schemas.microsoft.com/dynamics/2011/01/documents/Message“>
<Header>
<MessageId>{7F99293C-0469-4D50-8489-0C5E5CF2741C}</MessageId>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read</Action>
</Header>
<Body>
<MessagePartsxmlns=http://schemas.microsoft.com/dynamics/2011/01/documents/Message>
<SalesInvoicexmlns=http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice>
<CustInvoiceJourclass=“entity“>
<CurrencyCode>USD</CurrencyCode>
<CustGroup>10</CustGroup>
<InvoiceAccount>1104</InvoiceAccount>
<InvoiceDate>2008-06-27</InvoiceDate>
<LanguageId>en-us</LanguageId>
<OrderAccount>1104</OrderAccount>
<CustInvoiceTransclass=“entity“>
<InvoiceDate>2008-06-27</InvoiceDate>
<InvoiceId>101076</InvoiceId>
</CustInvoiceTrans>
<FormLetterRemarksclass=“entity“>
<FormLetter>SalesInvoice</FormLetter>
<LanguageId>en-us</LanguageId>
</FormLetterRemarks>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
And you add the following XSL transform on the outbound port:
<?xmlversion=“1.0“encoding=“utf-8“?>
<xsl:stylesheetversion=“1.0“xmlns:xsl=“http://www.w3.org/1999/XSL/Transform“>
<xsl:outputmethod=“xml“indent=“yes“encoding=“utf-8“omit-xml-declaration=“no“/>
<xsl:templatematch=“/“>
<Test>
<Header>
<records>
<record>
<xsl:apply-templates/>
</record>
</records>
</Header>
</Test>
</xsl:template>
<xsl:templatematch = “CustInvoiceJour“>
<xsl:value-ofselect=“CustGroup“/>
</xsl:template>
</xsl:stylesheet>
It produces the following result:
<Test>
<Header>
<records>
<record>{F12B1037-B6DC-4BB9-BAD3-B4236422839E}http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/readUSD1011042008-06-27en-us11042008-06-27101076SalesInvoiceen-us</record>
</records>
</Header>
</Test>
You would expect the following result:
<Test>
<Header>
<records>
<record>10</record>
</records>
</Header>
</Test>
Resolution:
The attached XSL was not taking into account the namespaces within the XML schema. The following XSL is correct. Please use this as a reference for building XSL transforms for our Dynamics AX 2012 documents. There is no product issue here.
<?xmlversion=“1.0“encoding=“utf-8“?>
<xsl:stylesheetversion=“1.0“
xmlns:Message=“http:“//schemas.microsoft.com/dynamics/2011/01/documents/Message
xmlns:SalesInvoice=http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice
xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
<xsl:outputmethod=“xml“indent=“yes“encoding=“utf-8“omit-xml-declaration=“no“/>
<xsl:templatematch=“Message:Envelope“>
<Test>
<Header>
<records>
<record>
<xsl:value-ofselect=“Message:Body/Message:MessageParts/SalesInvoice:SalesInvoice/SalesInvoice:CustInvoiceJour/SalesInvoice:CustGroup“/>
</record>
</records>
</Header>
</Test>
</xsl:template>
</xsl:stylesheet>