Removing XML Namespaces

NAVupNorth
Member Posts: 14
I'm working on an upgrade from v4 to 2018 and using extensions as much as possible. There's a bespoke function in the v4 database to remove namespaces from some XML being imported from a Magento website. It uses automations (Microsoft XML, v6.0) so I can't use it as-is in an extension.
I'm not sure how to replicate it other than as a function in a standard codeunit called from the extension. Does anybody have any ideas?
The original code was from a page on Partnersource which doesn't seem to exist anymore.
Thanks in advance.
I'm not sure how to replicate it other than as a function in a standard codeunit called from the extension. Does anybody have any ideas?
The original code was from a page on Partnersource which doesn't seem to exist anymore.
Thanks in advance.
//from https://mbs.microsoft.com/partnersource/documentation/howtoarticles/xmlportswebservices.htm?printpage=false TempBlob.Blob.CREATEOUTSTREAM(OutStreamStylesheet); TempBlob.Blob.CREATEINSTREAM(InStreamStylesheet); OutStreamStylesheet.WRITETEXT('<?xml version="1.0" encoding="UTF-8"?>'); OutStreamStylesheet.WRITETEXT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'); OutStreamStylesheet.WRITETEXT('<xsl:output method="xml" encoding="UTF-8" />'); OutStreamStylesheet.WRITETEXT('<xsl:template match="/">'); OutStreamStylesheet.WRITETEXT('<xsl:copy>'); OutStreamStylesheet.WRITETEXT('<xsl:apply-templates />'); OutStreamStylesheet.WRITETEXT('</xsl:copy>'); OutStreamStylesheet.WRITETEXT('</xsl:template>'); OutStreamStylesheet.WRITETEXT('<xsl:template match="*">'); OutStreamStylesheet.WRITETEXT('<xsl:element name="{local-name()}">'); OutStreamStylesheet.WRITETEXT('<xsl:apply-templates select="@* | node()" />'); OutStreamStylesheet.WRITETEXT('</xsl:element>'); OutStreamStylesheet.WRITETEXT('</xsl:template>'); OutStreamStylesheet.WRITETEXT('<xsl:template match="@*">'); OutStreamStylesheet.WRITETEXT('<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>'); OutStreamStylesheet.WRITETEXT('</xsl:template>'); OutStreamStylesheet.WRITETEXT('<xsl:template match="text() | processing-instruction() | comment()">'); OutStreamStylesheet.WRITETEXT('<xsl:copy />'); OutStreamStylesheet.WRITETEXT('</xsl:template>'); //-001 OutStreamStylesheet.WRITETEXT('<xsl:template match="*[normalize-space() = '''']" />'); //+001 OutStreamStylesheet.WRITETEXT('</xsl:stylesheet>'); IF ISCLEAR(XMLStyleSheet) THEN CREATE(XMLStyleSheet); XMLStyleSheet.load(InStreamStylesheet); IF ISCLEAR(XMLDestinationDocument) THEN CREATE(XMLDestinationDocument); XMLSourceDocument.transformNodeToObject(XMLStyleSheet,XMLDestinationDocument);
0
Best Answer
-
May be this can help you -
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-automation-variable/Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/5
Answers
-
May be this can help you -
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-automation-variable/Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/5 -
Superb - I'll go with that and move it to an extension once .net support is released. Thanks!0
-
Updating this just in case it helps anyone else in future. Codeunit 6224 XML DOM Management has got an external function RemoveNamespaces which does this for you.1
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