Hello all,
One of my client require a xml file with the following declaration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "
http://xml.cXML.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">
The first declaration is generated automatically when I run the xmlport I created but not the second one. Does anyone know how? Your help would be greatly appreciated.
Thank you very much.
April
Comments
Run you XMLPORT and export it to a stream. Load that to a MSXMLDOM and call a function that will add any additional Namespace or DOCTYPE
Here is implementation of this. In my example
XML is a blob field and I'm creating a stream that I'm loading into a MSXMLDOM
ChangeXMLFile is the function that will add namespace or DOCTYPE or any other structure that is not be done by xmlport
//MSDOM2 is passed by reference.
//XMLNode is of type 'Microsoft XML, v6.0'.IXMLDOMNode
//Separator is of type text
//Ch is of type char
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
So i came up with an other workaround.
Variables:
Not really a "nice" way to do it, but it worked for me.
greetings
( Using NAV2009 SP1 build 6.00.29626 Classic Client SQL Database)
Trying to work with ara3n's solution, but coming up with an error that the Automation has not been instantiated, that I have to create it or assign it. This occurs in the ChangeXMLFile function on the XMLNode assignment.
If I comment out the ChangeXMLFile function call. It creates the XML file as expected just without the <!DOCTYPE...> node.
I tried it with the "XMLNode := MSDOM.documentElement.firstChild;" first, and that created an error, so then I tried "XMLNode := MSDOM.documentElement();" which moved the error down to the "XMLNode.appendChild(XMLNode2);" line.
What is missing?
Thanks for your help.
http://www.interdynbmi.com
MSDOM..documentElement.firstChild;
MSDOM.SAVE('c:\test1.xml');
MSDOM2.SAVE('c:\test2.xml');
And make sure they have valid xml files.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I assume that this line is not working?
if I change this to a text instead, and stream it into a file, it creates an XML file, but I still can't open it to get the nodes and move them into the XML port generated one.
I am sure I am missing something small.
http://www.interdynbmi.com
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Apparently when using an external DTD, it can't validate when parsing because it isn't a whole definition.
Adding "MSDOM.validateOnParse(FALSE);" before the "MSDOM.loadXML(..." will allow it to actually load.
So I am able to get the file to save from the MSDOM with the "<!DOCTYPE" inserted. Still getting an error on the XMLNode though.
Current Code:
Once again, something small being overlooked...
http://www.interdynbmi.com
Basically have to copy all the child nodes into the DOM that is created with the corrected header.
You cannot move/append the <!DOCTYPE> node (it's read only :? ) which is why it was failing.
Here is the working code:
April, hopefully this works for you too and you can mark this as SOLVED.
Might not be a bad thing to add into the "How-to" Section.
Now to move the file from the services tier to the client... plenty of how-to's on that though.
http://www.interdynbmi.com
As you found out before , You end up with two files and various problems with the xml nodes within the function.
Where you able to resolve this or did you have to write something different?
I didn't notice your notification until today. I checked to see if you had posted after your call.
I did use this code and was successful making a XML file and changing the header. I only ended up with one useful file though. I run through the ChangeXMLFile procedure before saving.
What are you doing differently?
http://www.interdynbmi.com