Link to home
Start Free TrialLog in
Avatar of nyfin paul
nyfin paul

asked on

How can we skip or delete doctype while transforming one xml into another xml

How can we skip or delete doctype while transforming one xml into another xml

the problem is while i loading xml with vba program that cant able to read xml sheet due to DTD. if i am disable dtd it is working fine. can you help me to understand what changes are required for vba to ignore DTD?

my xml sheet start like <?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE Pip3B12ShippingOrderRequest SYSTEM "3B12_MS_V01_02_ShippingOrderRequest.dtd" PUBLIC "SYSTEM">

My vba program to call source xml and xslt given below, Sub dummy() Call Transform("C:\Users\nypaul\Desktop\XMLTESTING\SOURCE\01_open_file_20180606_093719_1135.xml", "C:\Users\nypaul\Desktop\XMLTESTING\abc.xsl", "C:\Users\nypaul\Desktop\testing\out\01_open_file_180428_045209_10213.xml")

MsgBox "ok"

End Sub

Function Transform(sourceFile, styleSheetFile, resultFile) As Boolean

Dim Source As Object Dim StyleSheet As Object Dim Result As Object

Set Source = CreateObject("MSXML2.DOMDocument") Set StyleSheet = CreateObject("MSXML2.DOMDocument") Set Result = CreateObject("MSXML2.DOMDocument")

On Error GoTo TheEnd

Transform = True

' Load data. Source.async = False Source.Load sourceFile

' Load style sheet. StyleSheet.async = False StyleSheet.Load styleSheetFile

' Do the transformation Source.transformNodeToObject StyleSheet, Result Result.Save resultFile

' Transformation done, exit normally Exit Function TheEnd: ' If an error occured, return False Transform = False

End Function XSLT FORMAT LIKE <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <ENVELOPE >
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial