Hello,

I am using Xerces-C++ 3.2.0 with Visual Studio 2017 Community Edition on Windows 10 but when trying to re-validate an altered XML document I am encountering a Fatal error saying “unexpected end of input”.

But what is causing this error escapes me so I would appreciate your input. I get the XML in question from a SOAP service and pass it through a DOMParser to validate it using the Schema cited in the XML, and in most cases this works as intended, but there are instances where the Schema to be used is not provided in the XML so evidently the parser fails.

When the parse fails I read a known element within the XML document and from it I can elicit enough information to know which XSD I need to validate against so, I add both an xmlns:xs=http://www.w3.org/2001/XMLSchema-instance attribute pair and an xs:noNamespaceSchemaLocation=“XX.xsd” attribute pair to the XML.

With this done I now want to re-validate my modified XML so using this code :

XMLCh * pLS = XMLString::transcode("LS");
DOMImplementation * pImpl = DOMImplementationRegistry::getDOMImplementation(pLS); DOMLSSerializer * pSerialiser = ((DOMImplementationLS*)pImpl)->createLSSerializer();
        DOMConfiguration * pDomConfiguration = pSerialiser->getDomConfig();
        pDomConfiguration->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, 
true);
        XMLCh * pXML = pSerialiser->writeToString((DOMNode *)getDocument());
xercesc::MemBufInputSource mbis((const XMLByte*) pXML, XMLString::stringLen(pXML), "in-memory", false);;

…
domParser->parse(mbis)

It is during this ‘re-validation’ that I encounter the aforementioned error. However, on inspection the size of pXML is that of the modified XML when it is saved to disk and the file shows the changes and correctly validates when loaded in to Oxygen XML Developer. I have been scratching my head over this for sometime now but making no progress. Some of the files are quite large 20+MB but equally some files of these sizes can validate on first pass.

I would appreciate your thoughts on this as I’m at a total loss.

--
Regards,

Bill

Reply via email to