diff options
Diffstat (limited to 'parameter/XmlFileIncluderElement.cpp')
-rw-r--r-- | parameter/XmlFileIncluderElement.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/parameter/XmlFileIncluderElement.cpp b/parameter/XmlFileIncluderElement.cpp index 674a331..d20a624 100644 --- a/parameter/XmlFileIncluderElement.cpp +++ b/parameter/XmlFileIncluderElement.cpp @@ -28,12 +28,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "XmlFileIncluderElement.h" -#include "XmlFileDocSource.h" +#include "XmlDocSource.h" #include "XmlMemoryDocSink.h" #include "XmlElementSerializingContext.h" #include "ElementLibrary.h" #include "AutoLog.h" #include <assert.h> +#include <fstream> #define base CKindElement CXmlFileIncluderElement::CXmlFileIncluderElement(const std::string& strName, @@ -68,12 +69,20 @@ bool CXmlFileIncluderElement::fromXml(const CXmlElement& xmlElement, CXmlSeriali std::string strPathToXsdFile = elementSerializingContext.getXmlSchemaPathFolder() + "/" + strIncludedElementType + ".xsd"; - CXmlFileDocSource fileDocSource(strPath, - strPathToXsdFile, - strIncludedElementType, - _bValidateSchemasOnStart); + std::string xmlErrorMsg; + _xmlDoc *doc = CXmlDocSource::mkXmlDoc(strPath, true, true, xmlErrorMsg); + if (doc == NULL) { + elementSerializingContext.setError(xmlErrorMsg); + return false; + } + + CXmlDocSource docSource(doc, _bValidateSchemasOnStart, + strPathToXsdFile, + strIncludedElementType); + + if (!docSource.isParsable()) { - if (!fileDocSource.isParsable(elementSerializingContext)) { + elementSerializingContext.setError("Could not parse document \"" + strPath + "\""); return false; } @@ -81,7 +90,7 @@ bool CXmlFileIncluderElement::fromXml(const CXmlElement& xmlElement, CXmlSeriali // Get top level element CXmlElement childElement; - fileDocSource.getRootElement(childElement); + docSource.getRootElement(childElement); // Create child element CElement* pChild = elementSerializingContext.getElementLibrary()->createElement(childElement); @@ -100,7 +109,7 @@ bool CXmlFileIncluderElement::fromXml(const CXmlElement& xmlElement, CXmlSeriali // Use a doc sink that instantiate the structure from the doc source CXmlMemoryDocSink memorySink(pChild); - if (!memorySink.process(fileDocSource, elementSerializingContext)) { + if (!memorySink.process(docSource, elementSerializingContext)) { return false; } |