Load XML files from BLOB field with DTD via stream

einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
Hello everybody,

I want to load a xml file form a BLOB field via stream. The problem is that the xml file contains a document type definition. Everytime I want load the file with XML DOM Document I get an error message that the specified DTD file couldn't be found.
CALCFIELDS("Data (received)");
IF "Data (received)".HASVALUE THEN BEGIN
  IF NOT ISCLEAR(XMLDocument) THEN
    CLEAR(XMLDocument);
  CREATE(XMLDocument);
  "Data (received)".CREATEINSTREAM(InS);
  XMLDocument.load(InS);
END;
I got the DTD file, so it would be possible to save it into a specific folder, save the xml file into the same folder and load it from there. But I don't want to generate so much HD traffic and the user will probably work on a terminal server. User rights, file management, device capacity,... that wouldn't be a good solution.

Does anyone have a better suggestion? Or maybe a way to tell the load function where the DTD file could be found?
"Money is likewise the greatest chance and the greatest scourge of mankind."

Answers

  • niscoxniscox Member Posts: 15
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Very good link. I was using v4, but anyway this helped me to understand a little bit more. As mentioned here (below Remarks) I have to set
    XMLDocument.resolveExternals(FALSE);
    
    or in v6 it is FALSE by default.

    But now I have another problem. I get the following error message:
    A document must contain exactly one root element.
    Line Number = 1 Column Number = 0
    But if I understand correctly there is only one root element:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE myRootElement SYSTEM "myDTD.dtd">
    <!--  @version: -->
    <myRootElement arg01="4711" arg2="0815">
    </myRootElement>
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • ta5ta5 Member Posts: 1,164
    Try this.
    xmlDocument.async := true;
    xmlDocument.validateOnParse := false;
    

    Hope this helps
    Thomas
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Oh, forget it. It was my fault.
    XMLDocument.validateOnParse(FALSE);
    
    is the only thing you have to do.

    In DOMDocument v6 you have to set also
    XMLDocument.setProperty('ProhibitDTD',FALSE);
    
    In DOMDocument below v6 you have to set also
    XMLDocument.resolveExternals(FALSE);
    
    So, XMLDocument.load is working then. The error message is generated by a subsequent process.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.