diff options
Diffstat (limited to 'parameter/XmlFileIncluderElement.cpp')
-rw-r--r-- | parameter/XmlFileIncluderElement.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/parameter/XmlFileIncluderElement.cpp b/parameter/XmlFileIncluderElement.cpp index 4986758..06f64ff 100644 --- a/parameter/XmlFileIncluderElement.cpp +++ b/parameter/XmlFileIncluderElement.cpp @@ -27,6 +27,7 @@ #include "XmlMemoryDocSink.h" #include "XmlElementSerializingContext.h" #include "ElementLibrary.h" +#include "AutoLog.h" #include <assert.h> #define base CKindElement @@ -53,41 +54,45 @@ bool CXmlFileIncluderElement::fromXml(const CXmlElement& xmlElement, CXmlSeriali // Instantiate parser string strIncludedElementType = getIncludedElementType(); - // Use a doc source that load data from a file - CXmlFileDocSource fileDocSource(strPath, elementSerializingContext.getXmlSchemaPathFolder() + "/" + strIncludedElementType + ".xsd", strIncludedElementType); + { + // Open a log section titled with loading file path + CAutoLog autolog(this, "Loading " + strPath); - if (!fileDocSource.isParsable(elementSerializingContext)) { + // Use a doc source that load data from a file + CXmlFileDocSource fileDocSource(strPath, elementSerializingContext.getXmlSchemaPathFolder() + "/" + strIncludedElementType + ".xsd", strIncludedElementType); - return false; - } + if (!fileDocSource.isParsable(elementSerializingContext)) { - // Get top level element - CXmlElement childElement; + return false; + } - fileDocSource.getRootElement(childElement); + // Get top level element + CXmlElement childElement; - // Create child element - CElement* pChild = elementSerializingContext.getElementLibrary()->createElement(childElement); + fileDocSource.getRootElement(childElement); - if (pChild) { + // Create child element + CElement* pChild = elementSerializingContext.getElementLibrary()->createElement(childElement); - // Store created child! - getParent()->addChild(pChild); - } else { + if (pChild) { - elementSerializingContext.setError("Unable to create XML element " + childElement.getPath()); + // Store created child! + getParent()->addChild(pChild); + } else { - return false; - } + elementSerializingContext.setError("Unable to create XML element " + childElement.getPath()); - // Use a doc sink that instantiate the structure from the doc source - CXmlMemoryDocSink memorySink(pChild); + return false; + } - if (!memorySink.process(fileDocSource, elementSerializingContext)) { + // Use a doc sink that instantiate the structure from the doc source + CXmlMemoryDocSink memorySink(pChild); - return false; - } + if (!memorySink.process(fileDocSource, elementSerializingContext)) { + return false; + } + } // Detach from parent getParent()->removeChild(this); |