web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Converting to text file after XSL transformation

(0) ShareShare
ReportReport
Posted on by 1,645

I managed to perform the XSLT transformation in an input XML file and generate the transformed output XML file. Now, the requirement I am getting is that the output file should be a text file instead of a XML file. Is there any standard functionality to generate the transformed text file instead of XML file in AX 2012?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Yes, that's fully supported by XSLT. For example, try this template with your message from the previous question:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:Message="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   <xsl:output method="text" encoding="utf-8"/>   <xsl:template match="Message:Envelope">     <xsl:value-of select="Message:Body"/>   </xsl:template> </xsl:stylesheet>

    Also, please consider closing your previous question as answered.

  • AlokShrestha Profile Picture
    1,645 on at

    I tried as you have mentioned and it just works perfect in visual studio but when I try the same thing in the AX 2012, it just produces the .xml file.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I tried a simple example and it works for me. Because you didn't tell us what you're doing, I have no idea what you're doing wrong.

  • AlokShrestha Profile Picture
    1,645 on at

    I am trying to implement the standard positive pay functionality that comes with cumulative updates 6 in AX 2012. The requirement is that I need to generate the .txt file instead of .xml file after xslt transformation. I thought I can just generate the .txt file by change the method attribute to "text" instead of "xml" in xslt file but AX 2012 keeps on storing .xml file only, not the .txt file. Did you generate the .txt file in AX 2012 only?

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I'm confused. Are you talking about transformation to plain text or saving a file with .txt extension?

  • AlokShrestha Profile Picture
    1,645 on at

    Sorry for the confusion. I am talking about the transformation to the plain text and the file should be saved with .txt extension. It should just be a simple .txt file with plain text in it.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    About transformation, you said it already worked for you in VS, you just have to find out what you have wrong in AX. I don't have enough information to reproduce the problem.

    About file extension, that's not supported. You would have to modify the standard file system adapter or create a custom one (it's defined in AifFileSystemSendAdapter.getNewOutFileName()).

  • Andrew Martin Profile Picture
    10 on at

    Martin - I came across this question as I am having the same difficulty implementing positive pay in 2012.  The issue is that the output of the xslt transformation is still continuing to be wrapped in an AIF Message:

    <?xml version="1.0" encoding="UTF-8"?><Envelope xmlns="schemas.microsoft.com/.../Message"><Header><MessageId>{AD130A63-D1FB-46AB-8844-00AC470066F4}</MessageId><Action>tempuri.org/.../Header><Body><MessageParts xmlns="schemas.microsoft.com/.../Message"><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.02" xmlns:xsi="www.w3.org/.../XMLSchema-instance">

    0003456700004000000000000000120110203ADDITIONAL DATA                Property Management                                         PAYEE 2                                                              

    0003456700000680000000000000220110203ADDITIONAL DATA                City Power & Light                                          PAYEE 2                                                              

    0003456700007800000000000000320110202ADDITIONAL DATA                City-wide Advertising                                       PAYEE 2                              

    The file specification that we are working on for positive is a straight text file so the XML Message block cannot be included.

    How do we get rid of that?  Do we have to apply a .Net assembly in the pipeline after the xslt transform?  The .Net assembly would be tasked with striping the XML out.  Something similar to what occurs when you import a CSV and need to convert to XML, just the reverse.  Thanks.

    Andrew

  • AlokShrestha Profile Picture
    1,645 on at

    Andrew,

                  As I started this thread, I am writing what I did to fix this issue.  I used .NET assembly directly in the AifFileSystemSendAdapter class with some conditions to achieve similar requirement. I just used .NET XSLCompiledTransform class along with XSL transformation as below to transfer the XML file to .txt file. 

    System.IO.TextWriter textwriter;

    System.Xml.Xsl.XslCompiledTransform managedTransform;

    xslFile=CustVendAifPaymTable.TextXSLT;
    managedTransform.Load(xslFile,xslt_settings,new System.Xml.XmlUrlResolver());

    textwriter= new System.IO.StreamWriter(ppFilePath,false,System.Text.Encoding::get_Default());

    managedTransform.Transform(xmlReader,null,textwriter);
    textwriter.Close();

    Thanks,

    Alok 

  • Andrew Martin Profile Picture
    10 on at

    Alok,

    I agree that your solution will work, but it seems like a fairly heavy handed solution that I'm sure Microsoft did not have in mind when they decided to use the AIF platform for positive pay.  I'll go down that path if I need to, but I'd like see if Martin has a comment on this.

    Thanks for posting your solution.

    Andrew

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans