I have a problem when generating a file xml.
The problem is the following one: I need to put schema in the document xml and this I do adding it to him an attribute and this it is a node father. After I create a son of this node father and then the node son inherits the label xmlns = "". I could need that this node son did not inherit east attribute to me. Not if the programming with that I generate the attribute is the correct one, with which could need that somebody supervised this. The code to generate the file xml is the following one:
IF "Hist. Alb".FIND('-') THEN
REPEAT;
Lineas.RESET;
Lineas.SETRANGE(Lineas."Document No.","Hist. Alb"."No.");
//** Make a xml doc and the main structure
CLEAR(XMLDocOut);
CREATE(XMLDocOut);
XMLDOMManagement.SetNormalCase;
XMLProccesingInst := XMLDocOut.createProcessingInstruction('xml','version=''1.0'' encoding=''windows-1252''');
XMLCurrNode := XMLDocOut.appendChild(XMLProccesingInst);
CLEAR(XMLCurrNode);
{***********Here is where i put the atribute and node son inherit**********************************************************}
//** Main node OpenShipments with his schema
XMLCurrNode := XMLDocOut.createElement('OpenShipments');
XMLCurrNode := XMLDocOut.appendChild(XMLCurrNode);
IF XMLDOMManagement.AddAttribute(XMLCurrNode,'xmlns',
'x-schema:c:\OpenShipments.xdr') > 0 THEN EXIT;
{************** I prove to generate with xmlschema but i haver errors
******************************}
{
XMLSchema := XMLCurrNode;
XMLSchema.add('xmlns="x-schema:c:\OpenShipments.xdr"','OpenShipments');
XMLCurrNode := XMLDocOut.appendChild(XMLCurrNode);
CLEAR(XMLCurrNode);
}
//** OpenShipment node
XMLDOMManagement.AddElement(XMLCurrNode,'OpenShipment','','',XMLCurrNode);
IF XMLDOMManagement.AddAttribute(XMLCurrNode,'ProcessStatus','') > 0 THEN EXIT;
//** Receiver's node
IF XMLDOMManagement.AddElement(XMLCurrNode,'Receiver','','',XMLCurrNode2) > 0 THEN EXIT;
//** receptor's information
IF XMLDOMManagement.AddElement(XMLCurrNode2,'CompanyName',
"Hist. Alb"."Ship-to Name" + "Hist. Alb"."Ship-to Name 2",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'ContactPerson',
"Hist. Alb"."Ship-to Contact",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'AddressLine1',
"Hist. Alb"."Ship-to Address",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'AddressLine2',
"Hist. Alb"."Ship-to Address 2",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'AddressLine3',
"Hist. Alb"."Ship-to County",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'City',
"Hist. Alb"."Ship-to City",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'CountryCode',
'ES','',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'PostalCode',
"Hist. Alb"."Ship-to Post Code",'',XMLNewChild) > 0 THEN EXIT;
//** emitter's node
IF XMLDOMManagement.AddElement(XMLCurrNode,'Shipment','','',XMLCurrNode2) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'ServiceLevel',
"Hist. Alb"."Shipment Method Code",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'NumberOfPackages',
FORMAT("Hist. Alb"."Nºbultos"),'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'ShipmentActualWeight',
FORMAT("Hist. Alb"."Peso bruto"),'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'Reference1',
"Hist. Alb"."No.",'',XMLNewChild) > 0 THEN EXIT;
IF XMLDOMManagement.AddElement(XMLCurrNode2,'BillingOption',
'PP','',XMLNewChild) > 0 THEN EXIT;
XMLDocOut.save('c:\'+ "Hist. Alb"."No." + '.xml');
UNTIL "Hist. Alb".NEXT = 0;
0
Comments
I've got no idea what you are talking about. But please take a look at this:
Maybe it's something usefull
If it was hard to write, it should be hard to understand."
You have to look at the schema-type you are using to decide which way does correspond to your problem...
when using DTD you may use the following example while the MSXML-Parser is not designed for adding DOCTYPE-declarations:
RootNode := XMLDOM.createElement('TEST');
XMLDOM.appendChild(RootNode);
XMLDOM.loadXML('<?xml version="1.0" encoding="UTF-8"?>' +
'<!DOCTYPE TEST SYSTEM "' + + '">' XMLDOM.xml);
when using XDR try this example:
NamespaceURI := 'x-schema:' + ;
PI := XMLDOM.createProcessingInstruction('xml','version="1.0" encoding="UTF-8"');
XMLDOM.appendChild(PI);
RootNode := XMLDOM.createNode(1,'TEST',NamespaceURI);
when using XSDs try this:
NamespaceURI := ;
PI := XMLDOM.createProcessingInstruction('xml','version="1.0" encoding="UTF-8"');
XMLDOM.appendChild(PI);
RootNode := XMLDOM.createNode(1,'TEST',NamespaceURI);
RootNode.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
IF NamespaceURI = '' THEN BEGIN
RootNode.setAttribute('xsi:noNamespaceSchemaLocation', );
END ELSE
RootNode.setAttribute('xsi:schemaLocation',NamespaceURI + ' ' + );
I hope that this little code example helps you fixing your problem.
You may use the kind of encoding you like.
Please feel free to response in order to awake a kind of discussing group for themes "XML and Navision", "XML and NAS" and so on... ???
Stefan
I have tried your code to give a dtd to my xml but i need not a file path. I need the full text of the dtd in my xml because the communikation server need this.
So I have saved the text on my volume an make an instream. So this is a workaround.
I would like to find another way to save the dtd in my xml file.
May be you have an idea.
Christian
I seem to have the same problem...I need to "save" a file (.pdf, .tiff etc) in a XML document created by MSDom. Could you tell how to make the instream??
And by the way: What is a "dtd"??
Jens