Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AIF XSLT sample request

15 views
Skip to first unread message

Klaas Deforche

unread,
Dec 15, 2009, 11:20:01 AM12/15/09
to
Hi everyone,

I'm trying to transform the AIF CustCustomer document with an *outbound*
pipeline using XSLT, but I can't seem to get my XSLT document right.

I have either no output at all, or there is only data without the tags
exported. (I'm using Visual Studio to test the xslt).
Does anyone have a sample XSLT document where I can base my transformation on?
Any help would be greatly appreciated.

Kind regards,
Klaas.
----------------
http://www.artofcreation.be

GregP

unread,
Dec 16, 2009, 8:49:01 AM12/16/09
to
I have knocked up a very quick example for the 'findListChartOfAccounts'
action (It's easily testable as you can just click on the 'send
electronically' button on the list of ledger accounts in GL.

Here is the example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:n="http://externalsystem.co.uk/externalSchema.xsd"

xmlns:n2="http://schemas.microsoft.com/dynamics/2006/02/documents/ChartOfAccounts"
xmlns="http://externalsystem.co.uk/externalSchema.xsd"
exclude-result-prefixes="n2 xsl">

<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default" />
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<n:Accounts>
<xsl:for-each select="n2:ChartOfAccounts/n2:LedgerTable">
<xsl:variable name="accountNumber" select="n2:AccountNum" />
<xsl:variable name="accountName" select="n2:AccountName" />
<n:Account>
<n:Number>
<xsl:value-of select="$accountNumber" />
</n:Number>
<n:Name>
<xsl:value-of select="$accountNumber" />
</n:Name>
</n:Account>
</xsl:for-each>
</n:Accounts>
</xsl:template>
</xsl:stylesheet>

--
http://gregondax.wordpress.com

Klaas Deforche

unread,
Dec 16, 2009, 9:24:01 AM12/16/09
to
Hi Greg,

Thank you for the example.
There were 2 things that I had trouble with:
- dealing with namespaces in xslt (something you demonstrated in you example)
- I didn't know only the "body"-section of the message was transformed

For everyone who is also looking for a sample, this one worked for me on
CustCustomerService:
<?xml version="1.0" encoding="utf-8"?>


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:cust="http://schemas.microsoft.com/dynamics/2008/01/documents/Customer" exclude-result-prefixes="cust">

<xsl:template match="/">
<xml>
<xsl:apply-templates select="cust:Customer" />
</xml>
</xsl:template>

<xsl:template match="cust:Customer">
<xsl:for-each select="cust:CustTable">
<Customer>
<xsl:attribute name="CustId">
<xsl:value-of select="cust:AccountNum" />
</xsl:attribute>
<Name>
<xsl:value-of select="cust:Name" />
</Name>
</Customer>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I will try your example as well.

The fact that the outbound pipeline only transforms the message section
bothers me.
I'll probably have to create a custom adapter and/or pipeline if I want to
transform the complete xml.

I'll share my findings :).

Thanks Greg.

Best regards,
Klaas.
----------------
http://www.artofcreation.be

Axel Kühn

unread,
Dec 16, 2009, 3:51:01 PM12/16/09
to
Hi Klaas,

only as additional information.

If you are working with pipeline components you can only get access to the
body of the message. Within a pipeline-component you can't get access to the
header.

If you will get access to the header you have to write your own adapter.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)

0 new messages