XSL(T) Transformation of XML Files in NAV 2018

MattH
Member Posts: 15
I’m currently trying to carry-out an XML transformation an XML file that a 3rd party sends, so that is converted into a human-readable format using a supplied XSL file. This resulting file is then opened in an internet browser for subsequent printing. I’ve tried the Transformation ‘by hand’ and it works perfectly.
I’ve three filestreams (XML-in, XSL-in and XML-out). I’ve tried using the functionality (TryTransformToXMLOutstream) contained in the codeunit XML DOM Management, but it claims it can’t find the XSL file in the system32 folder, even though I have ‘given’ the process the XSL file’s data through the filestream, so I don’t know why it has gone looking for it!
I tried taking elements of the TryTransformToXMLToOutstream functionality, cross-referencing it to C# examples found on the internet, but it complained about ‘null’ parameters. I’m almost of the opinion of getting something working in .NET/C# (because it seemingly gives better flexibility for this kind of functionality) and including this as a DLL into NAV.
Anyhow, my real question: has anybody undertaken the task of Transforming an XML file using an XSL in any of their projects?
I’ve three filestreams (XML-in, XSL-in and XML-out). I’ve tried using the functionality (TryTransformToXMLOutstream) contained in the codeunit XML DOM Management, but it claims it can’t find the XSL file in the system32 folder, even though I have ‘given’ the process the XSL file’s data through the filestream, so I don’t know why it has gone looking for it!
I tried taking elements of the TryTransformToXMLToOutstream functionality, cross-referencing it to C# examples found on the internet, but it complained about ‘null’ parameters. I’m almost of the opinion of getting something working in .NET/C# (because it seemingly gives better flexibility for this kind of functionality) and including this as a DLL into NAV.
Anyhow, my real question: has anybody undertaken the task of Transforming an XML file using an XSL in any of their projects?
0
Comments
-
Hi, xslt transformation has been made using .NET.
Below, I've put example.
Example:
Procedure ApplyXSLT(VAR XMLDocToApply : DotNet "System.Xml.XmlDocument";VAR XMLDoc : DotNet "System.Xml.XmlDocument")
VARS
Name DataType Subtype Length
StylesheetXML DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XslTransform DotNet System.Xml.Xsl.XslTransform.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlWriter DotNet System.IO.StringWriter.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
nullXsltArgumentList DotNet System.Xml.Xsl.XsltArgumentList.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
AppliedXMLDoc DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XslTransform := XslTransform.XslTransform;
StylesheetXML := StylesheetXML.XmlDocument;
StylesheetXML.InnerXml(XMLDocToApply.InnerXml); //xslt
XslTransform.Load(StylesheetXML);
XmlWriter := XmlWriter.StringWriter();
XslTransform.Transform(XMLDoc,nullXsltArgumentList,XmlWriter); // transform xmldoc wtih xslt
AppliedXMLDoc := AppliedXMLDoc.XmlDocument;
AppliedXMLDoc.InnerXml(XmlWriter.ToString());
XMLDoc := AppliedXMLDoc; // return transformed xml doc1 -
OK, thank you for the example. I shall try this as soon as I get some time on the project.0
-
Thanks. This lead me toward the final (working) result.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions