aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xxmlserializer/Android.mk11
-rw-r--r--xmlserializer/XmlDocSource.cpp44
-rw-r--r--xmlserializer/XmlDocSource.h28
-rw-r--r--xmlserializer/XmlFileDocSource.cpp12
-rw-r--r--xmlserializer/XmlFileDocSource.h8
-rw-r--r--xmlserializer/XmlMemoryDocSource.cpp12
-rw-r--r--xmlserializer/XmlMemoryDocSource.h7
-rw-r--r--xmlserializer/XmlStringDocSource.cpp12
-rw-r--r--xmlserializer/XmlStringDocSource.h4
9 files changed, 100 insertions, 38 deletions
diff --git a/xmlserializer/Android.mk b/xmlserializer/Android.mk
index fabbf84..a5ab4e1 100755
--- a/xmlserializer/Android.mk
+++ b/xmlserializer/Android.mk
@@ -60,8 +60,6 @@ common_c_includes := \
common_shared_libraries := libicuuc
common_static_libraries := libxml2
-common_ldlibs := -Lexternal/libxml2/lib
-
#############################
# Target build
@@ -82,8 +80,6 @@ LOCAL_C_INCLUDES += \
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries) libstlport
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
-LOCAL_LDLIBS += $(common_ldlibs)
-
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)
@@ -100,13 +96,10 @@ LOCAL_MODULE_TAGS := $(common_module_tags)
LOCAL_CFLAGS := $(common_cflags)
-LOCAL_C_INCLUDES += \
- $(common_c_includes)
+LOCAL_C_INCLUDES += $(common_c_includes)
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)-host
-LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
-
-LOCAL_LDLIBS += $(common_ldlibs)
+LOCAL_STATIC_LIBRARIES := libxml2-schemas
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
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
diff --git a/xmlserializer/XmlDocSource.h b/xmlserializer/XmlDocSource.h
index 9b780e5..fd9a693 100644
--- a/xmlserializer/XmlDocSource.h
+++ b/xmlserializer/XmlDocSource.h
@@ -52,8 +52,9 @@ public:
*
* @param[out] pDoc a pointer to the xml document that will be filled by the class
* @param[in] pRootNode a pointer to the root element of the document.
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
- CXmlDocSource(_xmlDoc* pDoc, _xmlNode* pRootNode = NULL);
+ CXmlDocSource(_xmlDoc* pDoc, _xmlNode* pRootNode = NULL, bool bValidateWithSchema = false);
/**
* Constructor
@@ -76,8 +77,26 @@ public:
* @param[out] pDoc a pointer to the xml document that will be filled by the class
* @param[in] strXmlSchemaFile a string containing the path to the schema file
* @param[in] strRootElementType a string containing the root element type
+ * @param[in] strRootElementName a string containing the root element name
+ * @param[in] strNameAttributeName a string containing the name of the root name attribute
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
- CXmlDocSource(_xmlDoc* pDoc, const string& strXmlSchemaFile, const string& strRootElementType);
+ CXmlDocSource(_xmlDoc* pDoc,
+ const string& strXmlSchemaFile,
+ const string& strRootElementType,
+ const string& strRootElementName,
+ const string& strNameAttrituteName,
+ bool bValidateWithSchema);
+
+ /**
+ * Constructor
+ *
+ * @param[out] pDoc a pointer to the xml document that will be filled by the class
+ * @param[in] strXmlSchemaFile a string containing the path to the schema file
+ * @param[in] strRootElementType a string containing the root element type
+ */
+ CXmlDocSource(_xmlDoc* pDoc, const string& strXmlSchemaFile, const string& strRootElementType,
+ bool bValidateWithSchema);
/**
* Destructor
@@ -197,4 +216,9 @@ private:
* Boolean that enables the root element name attribute check
*/
bool _bNameCheck;
+
+ /**
+ * Boolean that enables the validation via xsd files
+ */
+ bool _bValidateWithSchema;
};
diff --git a/xmlserializer/XmlFileDocSource.cpp b/xmlserializer/XmlFileDocSource.cpp
index 0fb3962..908c13b 100644
--- a/xmlserializer/XmlFileDocSource.cpp
+++ b/xmlserializer/XmlFileDocSource.cpp
@@ -38,22 +38,26 @@ CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile,
const string& strXmlSchemaFile,
const string& strRootElementType,
const string& strRootElementName,
- const string& strNameAttrituteName) :
+ const string& strNameAttrituteName,
+ bool bValidateWithSchema) :
base(readFile(strXmlInstanceFile),
strXmlSchemaFile,
strRootElementType,
strRootElementName,
- strNameAttrituteName),
+ strNameAttrituteName,
+ bValidateWithSchema),
_strXmlInstanceFile(strXmlInstanceFile)
{
}
CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile,
const string& strXmlSchemaFile,
- const string& strRootElementType) :
+ const string& strRootElementType,
+ bool bValidateWithSchema) :
base(readFile(strXmlInstanceFile),
strXmlSchemaFile,
- strRootElementType),
+ strRootElementType,
+ bValidateWithSchema),
_strXmlInstanceFile(strXmlInstanceFile)
{
}
diff --git a/xmlserializer/XmlFileDocSource.h b/xmlserializer/XmlFileDocSource.h
index 7a8bb8d..b8b0c6b 100644
--- a/xmlserializer/XmlFileDocSource.h
+++ b/xmlserializer/XmlFileDocSource.h
@@ -47,20 +47,24 @@ public:
* @param[in] strRootElementType a string containing the root element type
* @param[in] strRootElementName a string containing the root element name
* @param[in] strNameAttributeName a string containing the name of the root name attribute
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
CXmlFileDocSource(const string& strXmlInstanceFile,
const string& strXmlSchemaFile,
const string& strRootElementType,
const string& strRootElementName,
- const string& strNameAttrituteName);
+ const string& strNameAttrituteName,
+ bool bValidateWithSchema);
/**
* Constructor
*
* @param[in] strXmlInstanceFile a string containing the path to the xml file
* @param[in] strXmlSchemaFile a string containing the path to the schema file
* @param[in] strRootElementType a string containing the root element type
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
- CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType);
+ CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType,
+ bool bValidateWithSchema);
/**
* CXmlDocSource method implementation.
diff --git a/xmlserializer/XmlMemoryDocSource.cpp b/xmlserializer/XmlMemoryDocSource.cpp
index b60ee41..85abbfc 100644
--- a/xmlserializer/XmlMemoryDocSource.cpp
+++ b/xmlserializer/XmlMemoryDocSource.cpp
@@ -38,8 +38,10 @@ CXmlMemoryDocSource::CXmlMemoryDocSource(const IXmlSource* pXmlSource,
const string& strRootElementType,
const string& strXmlSchemaFile,
const string& strProduct,
- const string& strVersion):
- base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str())),
+ const string& strVersion,
+ bool bValidateWithSchema):
+ base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str()),
+ bValidateWithSchema),
_pXmlSource(pXmlSource), _strXmlSchemaFile(strXmlSchemaFile), _bWithHeader(true),
_strProduct(strProduct), _strVersion(strVersion)
{
@@ -47,8 +49,10 @@ CXmlMemoryDocSource::CXmlMemoryDocSource(const IXmlSource* pXmlSource,
}
CXmlMemoryDocSource::CXmlMemoryDocSource(const IXmlSource* pXmlSource,
- const string& strRootElementType):
- base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str())),
+ const string& strRootElementType,
+ bool bValidateWithSchema):
+ base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str()),
+ bValidateWithSchema),
_pXmlSource(pXmlSource), _bWithHeader(false)
{
init();
diff --git a/xmlserializer/XmlMemoryDocSource.h b/xmlserializer/XmlMemoryDocSource.h
index 1e549ff..072cb06 100644
--- a/xmlserializer/XmlMemoryDocSource.h
+++ b/xmlserializer/XmlMemoryDocSource.h
@@ -50,10 +50,12 @@ public:
* @param[in] strXmlSchemaFile a string containing the path to the schema file
* @param[in] strProduct a string containing the product name
* @param[in] strVersion a string containing the version number
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType,
const string& strXmlSchemaFile, const string& strProduct,
- const string& strVersion);
+ const string& strVersion,
+ bool bValidateWithSchema);
/**
* Constructor
@@ -61,8 +63,9 @@ public:
* @param[in] pXmlSource a pointer to a parameter-framework structure that can generate
* an xml description of itself
* @param[in] strRootElementType a string containing the root element type
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
- CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType);
+ CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType, bool bValidateWithSchema);
/**
* Implementation of CXmlDocSource::populate() method.
diff --git a/xmlserializer/XmlStringDocSource.cpp b/xmlserializer/XmlStringDocSource.cpp
index b360322..12307f2 100644
--- a/xmlserializer/XmlStringDocSource.cpp
+++ b/xmlserializer/XmlStringDocSource.cpp
@@ -37,12 +37,14 @@ CXmlStringDocSource::CXmlStringDocSource(const string& strXmlInput,
const string& strXmlSchemaFile,
const string& strRootElementType,
const string& strRootElementName,
- const string& strNameAttrituteName) :
+ const string& strNameAttrituteName,
+ bool bValidateWithSchema) :
base(xmlReadMemory(strXmlInput.c_str(), strXmlInput.size(), "", NULL, 0),
- strXmlSchemaFile,
- strRootElementType,
- strRootElementName,
- strNameAttrituteName)
+ strXmlSchemaFile,
+ strRootElementType,
+ strRootElementName,
+ strNameAttrituteName,
+ bValidateWithSchema)
{
}
diff --git a/xmlserializer/XmlStringDocSource.h b/xmlserializer/XmlStringDocSource.h
index 312d72b..d7cde9b 100644
--- a/xmlserializer/XmlStringDocSource.h
+++ b/xmlserializer/XmlStringDocSource.h
@@ -47,12 +47,14 @@ public:
* @param[in] strRootElementType a string containing the root element type
* @param[in] strRootElementName a string containing the root element name
* @param[in] strNameAttributeName a string containing the name of the root name attribute
+ * @param[in] bValidateWithSchema a boolean that toggles schema validation
*/
CXmlStringDocSource(const string& strXmlInput,
const string& strXmlSchemaFile,
const string& strRootElementType,
const string& strRootElementName,
- const string& strNameAttrituteName);
+ const string& strNameAttrituteName,
+ bool bValidateWithSchema);
/**
* CXmlDocSource method implementation.