MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / loadDocument

Method loadDocument

src/App/ProjectFile.cpp:320–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320bool ProjectFile::loadDocument()
321{
322 if (xmlDocument) {
323 return true; // already loaded
324 }
325
326 auto project = ZipTools::open(stdFile);
327 if (!project) {
328 return false;
329 }
330
331 std::unique_ptr<std::istream> str(project->getInputStream("Document.xml"));
332 if (str) {
333 std::unique_ptr<XercesDOMParser> parser(new XercesDOMParser);
334 parser->setValidationScheme(XercesDOMParser::Val_Auto);
335 parser->setDoNamespaces(false);
336 parser->setDoSchema(false);
337 parser->setValidationSchemaFullChecking(false);
338 parser->setCreateEntityReferenceNodes(false);
339
340 try {
341 Base::StdInputSource inputSource(*str, stdFile.c_str());
342
343 parser->parse(inputSource);
344 if (parser->getErrorCount() > 0) {
345 return false;
346 }
347 xmlDocument = parser->adoptDocument();
348 return true;
349 }
350 catch (const XMLException&) {
351 return false;
352 }
353 catch (const DOMException&) {
354 return false;
355 }
356 }
357
358 return false;
359}
360
361ProjectFile::Metadata ProjectFile::parseMetadata() const
362{

Callers 2

isValidProjectMethod · 0.80
TEST_FFunction · 0.80

Calls 4

openFunction · 0.50
getInputStreamMethod · 0.45
c_strMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected