| 318 | } |
| 319 | |
| 320 | bool 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 | |
| 361 | ProjectFile::Metadata ProjectFile::parseMetadata() const |
| 362 | { |
no test coverage detected