diff options
author | Mattijs Korpershoek <mattijsx.korpershoek@intel.com> | 2014-04-08 14:05:21 +0200 |
---|---|---|
committer | Mattijs Korpershoek <mattijsx.korpershoek@intel.com> | 2014-06-25 10:52:20 +0200 |
commit | 3141891778a0564887d25b8b06b898daf3c1c9b5 (patch) | |
tree | 8774f6d48211002dc50ec654520b9d98aacf89a2 /xmlserializer/XmlDocSource.cpp | |
parent | f394b389ff6202e94d42266ba39144bdcdefe3ba (diff) | |
download | external_parameter-framework-3141891778a0564887d25b8b06b898daf3c1c9b5.zip external_parameter-framework-3141891778a0564887d25b8b06b898daf3c1c9b5.tar.gz external_parameter-framework-3141891778a0564887d25b8b06b898daf3c1c9b5.tar.bz2 |
Added possibility to toggle xml validation
BZ: 184054
It was not possible to enable/disable xml file validation.
The parameter framework only relied on the LIBXML_SCHEMAS flag.
This patchs implements a new constructor for XmlFiles
which allows enabling/disabling xml/xsd check.
Change-Id: I32d220a42bb27f4ce685f07cb194e78e76f44a5d
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Diffstat (limited to 'xmlserializer/XmlDocSource.cpp')
-rw-r--r-- | xmlserializer/XmlDocSource.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/xmlserializer/XmlDocSource.cpp b/xmlserializer/XmlDocSource.cpp index 476e415..5e53a81 100644 --- a/xmlserializer/XmlDocSource.cpp +++ b/xmlserializer/XmlDocSource.cpp @@ -36,14 +36,16 @@ // Schedule for libxml2 library bool CXmlDocSource::_bLibXml2CleanupScheduled; -CXmlDocSource::CXmlDocSource(_xmlDoc *pDoc, _xmlNode *pRootNode): +CXmlDocSource::CXmlDocSource(_xmlDoc *pDoc, _xmlNode *pRootNode, + bool bValidateWithSchema) : _pDoc(pDoc), _pRootNode(pRootNode), _strXmlSchemaFile(""), _strRootElementType(""), _strRootElementName(""), _strNameAttrituteName(""), - _bNameCheck(false) + _bNameCheck(false), + _bValidateWithSchema(bValidateWithSchema) { init(); } @@ -59,20 +61,41 @@ CXmlDocSource::CXmlDocSource(_xmlDoc *pDoc, _strRootElementType(strRootElementType), _strRootElementName(strRootElementName), _strNameAttrituteName(strNameAttrituteName), - _bNameCheck(true) + _bNameCheck(true), + _bValidateWithSchema(false) { init(); } CXmlDocSource::CXmlDocSource(_xmlDoc* pDoc, const string& strXmlSchemaFile, - const string& strRootElementType) : + const string& strRootElementType, + bool bValidateWithSchema) : _pDoc(pDoc), _pRootNode(NULL), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _strRootElementName(""), _strNameAttrituteName(""), - _bNameCheck(false) + _bNameCheck(false), + _bValidateWithSchema(bValidateWithSchema) +{ + init(); +} + +CXmlDocSource::CXmlDocSource(_xmlDoc *pDoc, + const string& strXmlSchemaFile, + const string& strRootElementType, + const string& strRootElementName, + const string& strNameAttrituteName, + bool bValidateWithSchema) : + _pDoc(pDoc), + _pRootNode(NULL), + _strXmlSchemaFile(strXmlSchemaFile), + _strRootElementType(strRootElementType), + _strRootElementName(strRootElementName), + _strNameAttrituteName(strNameAttrituteName), + _bNameCheck(true), + _bValidateWithSchema(bValidateWithSchema) { init(); } @@ -118,12 +141,15 @@ bool CXmlDocSource::validate(CXmlSerializingContext& serializingContext) return false; } - // Validate - if (!isInstanceDocumentValid()) { + // Validate if necessary + if (_bValidateWithSchema) + { + if (!isInstanceDocumentValid()) { - serializingContext.setError("Document is not valid"); + serializingContext.setError("Document is not valid"); - return false; + return false; + } } // Check Root element type |