Remove namespace in xml nav 2013r2

Enes
Member Posts: 6
Hi,
I want remove namespace in following xml. Any tips will be helpfull.
Version : Nav2013r2 and upper
I applied following links solution but it didnt work.
https://rockwithnav.wordpress.com/tag/remove-namespace-web-service-response-automation-variable/
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="aktaes.xslt"?>
<Invoice xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:cctc="urn:un:unece:uncefact:documentation:2" xmlns:ubltr="urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>TR1.2</cbc:CustomizationID>
<cbc:ProfileID>TICARIFATURA</cbc:ProfileID>
<cbc:ID>EGT2016000000006</cbc:ID>
<cbc:CopyIndicator>false</cbc:CopyIndicator>
<cbc:UUID>afa0e38b-eb63-558a-e511-77c3a0473501</cbc:UUID>
<cbc:IssueDate>2016-01-25</cbc:IssueDate>
</Invoice>
I want remove namespace in following xml. Any tips will be helpfull.
Version : Nav2013r2 and upper
I applied following links solution but it didnt work.
https://rockwithnav.wordpress.com/tag/remove-namespace-web-service-response-automation-variable/
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="aktaes.xslt"?>
<Invoice xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:cctc="urn:un:unece:uncefact:documentation:2" xmlns:ubltr="urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>TR1.2</cbc:CustomizationID>
<cbc:ProfileID>TICARIFATURA</cbc:ProfileID>
<cbc:ID>EGT2016000000006</cbc:ID>
<cbc:CopyIndicator>false</cbc:CopyIndicator>
<cbc:UUID>afa0e38b-eb63-558a-e511-77c3a0473501</cbc:UUID>
<cbc:IssueDate>2016-01-25</cbc:IssueDate>
</Invoice>
0
Best Answer
-
I am using below method to remove namespaces and attributes from web service responses and get clean xml.
LOCAL [TryFunction] RemoveNameSpace(XMLSourceStream : InStream;VAR XMLDestinationStream : InStream) XSLTString := '<?xml version="1.0" encoding="UTF-8"?>'; XSLTString := XSLTString + '<xsl:stylesheet version="1.0" ' + 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >'; XSLTString := XSLTString + '<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>'; XSLTString := XSLTString + '<xsl:template match="/">'; XSLTString := XSLTString + '<xsl:copy>'; XSLTString := XSLTString + '<xsl:apply-templates />'; XSLTString := XSLTString + '</xsl:copy>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="soap:Header">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="*">'; XSLTString := XSLTString + '<xsl:element name="{local-name()}">'; XSLTString := XSLTString + '<xsl:apply-templates select="@* | node()" />'; XSLTString := XSLTString + '</xsl:element>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="@*">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="text() | processing-instruction() | comment()">'; XSLTString := XSLTString + '<xsl:copy />'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '</xsl:stylesheet>'; StringReader := StringReader.StringReader(XSLTString); XsltXMLReader := XsltXMLReader.Create(StringReader); XslCompiledTransform := XslCompiledTransform.XslCompiledTransform; XslCompiledTransform.Load(XsltXMLReader); XmlReaderSettings := XmlReaderSettings.XmlReaderSettings; SourceXMLReader := SourceXMLReader.Create(XMLSourceStream,XmlReaderSettings); DestinationXMLWriter := DestinationXMLWriter.Create(XMLDestinationStream); XslCompiledTransform.Transform(SourceXMLReader,DestinationXMLWriter);
XslCompiledTransform DotNet System.Xml.Xsl.XslCompiledTransform.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XsltXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XSLTString Text
SourceXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
DestinationXMLWriter DotNet System.Xml.XmlWriter.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
StringReader DotNet System.IO.StringReader.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlReaderSettings DotNet System.Xml.XmlReaderSettings.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'5
Answers
-
//DELETE ROOT NODE
RootNode := '<?xml version="1.0" encoding="utf-8" standalone="no"?>';
xml := DELSTR(xml,1, STRLEN(RootNode));0 -
Hi vnhack,
I tried but didnt work. Applied followink links.
Link : https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/
I get this error;
Cannot serialize an instance of the following .NET Framework object: assembly Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, type MSXML.DOMDocumentClass.0 -
I am using below method to remove namespaces and attributes from web service responses and get clean xml.
LOCAL [TryFunction] RemoveNameSpace(XMLSourceStream : InStream;VAR XMLDestinationStream : InStream) XSLTString := '<?xml version="1.0" encoding="UTF-8"?>'; XSLTString := XSLTString + '<xsl:stylesheet version="1.0" ' + 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >'; XSLTString := XSLTString + '<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>'; XSLTString := XSLTString + '<xsl:template match="/">'; XSLTString := XSLTString + '<xsl:copy>'; XSLTString := XSLTString + '<xsl:apply-templates />'; XSLTString := XSLTString + '</xsl:copy>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="soap:Header">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="*">'; XSLTString := XSLTString + '<xsl:element name="{local-name()}">'; XSLTString := XSLTString + '<xsl:apply-templates select="@* | node()" />'; XSLTString := XSLTString + '</xsl:element>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="@*">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="text() | processing-instruction() | comment()">'; XSLTString := XSLTString + '<xsl:copy />'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '</xsl:stylesheet>'; StringReader := StringReader.StringReader(XSLTString); XsltXMLReader := XsltXMLReader.Create(StringReader); XslCompiledTransform := XslCompiledTransform.XslCompiledTransform; XslCompiledTransform.Load(XsltXMLReader); XmlReaderSettings := XmlReaderSettings.XmlReaderSettings; SourceXMLReader := SourceXMLReader.Create(XMLSourceStream,XmlReaderSettings); DestinationXMLWriter := DestinationXMLWriter.Create(XMLDestinationStream); XslCompiledTransform.Transform(SourceXMLReader,DestinationXMLWriter);
XslCompiledTransform DotNet System.Xml.Xsl.XslCompiledTransform.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XsltXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XSLTString Text
SourceXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
DestinationXMLWriter DotNet System.Xml.XmlWriter.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
StringReader DotNet System.IO.StringReader.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlReaderSettings DotNet System.Xml.XmlReaderSettings.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'5 -
Hi Ayhan,
Thanks for your help.
I just want to remind that were 2 minor problems.
First I had to remove semicolons
second I added following line in order to preserve attributes
XSLTString := XSLTString + '<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>';
0 -
You may check out this link as well
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-automation-variable/
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/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