summaryrefslogtreecommitdiffstats
path: root/xmlserializer
diff options
context:
space:
mode:
authorGuillaume Denneulin <guillaume.denneulin@intel.com>2014-01-31 15:09:42 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-13 16:08:59 +0100
commit3ba083ee0b0ff7e01caeb3bc7395377071e20fe6 (patch)
treed639c767d5308ee2658db9d1fc0f946067a74c94 /xmlserializer
parent7613e74a97d67c392a241ad3a62c6533b31f48ab (diff)
downloadexternal_parameter-framework-3ba083ee0b0ff7e01caeb3bc7395377071e20fe6.zip
external_parameter-framework-3ba083ee0b0ff7e01caeb3bc7395377071e20fe6.tar.gz
external_parameter-framework-3ba083ee0b0ff7e01caeb3bc7395377071e20fe6.tar.bz2
In structure XML files, implement component library files inclusion
BZ: 168727 In the PFW structure file, it is not possible to include a component library from another XML file. Implement the possibility to import component from another XML file that would be included in a structure XML file and that would describe a component library. Change-Id: Id6125140de1c8e9882375d01199f695b929f45e2 Signed-off-by: Guillaume Denneulin <guillaume.denneulin@intel.com>
Diffstat (limited to 'xmlserializer')
-rw-r--r--xmlserializer/XmlFileDocSource.cpp27
-rw-r--r--xmlserializer/XmlFileDocSource.h11
2 files changed, 35 insertions, 3 deletions
diff --git a/xmlserializer/XmlFileDocSource.cpp b/xmlserializer/XmlFileDocSource.cpp
index 4df2ad1..53e7c86 100644
--- a/xmlserializer/XmlFileDocSource.cpp
+++ b/xmlserializer/XmlFileDocSource.cpp
@@ -24,6 +24,7 @@
#include "XmlFileDocSource.h"
#include <libxml/parser.h>
+#include <libxml/xinclude.h>
#define base CXmlDocSource
@@ -32,7 +33,7 @@ CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile,
const string& strRootElementType,
const string& strRootElementName,
const string& strNameAttrituteName) :
- base(xmlReadFile(strXmlInstanceFile.c_str(),NULL, 0),
+ base(readFile(strXmlInstanceFile),
strXmlSchemaFile,
strRootElementType,
strRootElementName,
@@ -44,7 +45,7 @@ CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile,
CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile,
const string& strXmlSchemaFile,
const string& strRootElementType) :
- base(xmlReadFile(strXmlInstanceFile.c_str(), NULL, 0),
+ base(readFile(strXmlInstanceFile),
strXmlSchemaFile,
strRootElementType),
_strXmlInstanceFile(strXmlInstanceFile)
@@ -66,7 +67,7 @@ bool CXmlFileDocSource::isParsable(CXmlSerializingContext& serializingContext) c
bool CXmlFileDocSource::populate(CXmlSerializingContext& serializingContext)
{
- if (!base::validate(serializingContext)) {
+ if (!validate(serializingContext)) {
// Add the file's name in the error message
serializingContext.appendLineToError("File : " + _strXmlInstanceFile);
@@ -76,3 +77,23 @@ bool CXmlFileDocSource::populate(CXmlSerializingContext& serializingContext)
return true;
}
+
+_xmlDoc* CXmlFileDocSource::readFile(const string& strFileName)
+{
+ // Read xml file
+ xmlDocPtr pDoc = xmlReadFile(strFileName.c_str(), NULL, 0);
+
+ if (!pDoc) {
+
+ return NULL;
+ }
+ // Process file inclusion
+ // WARNING: this symbol is available if libxml2 has been compiled with LIBXML_XINCLUDE_ENABLED
+ if (xmlXIncludeProcess(pDoc) < 0) {
+
+ xmlFreeDoc(pDoc);
+ return NULL;
+ }
+
+ return pDoc;
+}
diff --git a/xmlserializer/XmlFileDocSource.h b/xmlserializer/XmlFileDocSource.h
index 98ba6e3..1efafe2 100644
--- a/xmlserializer/XmlFileDocSource.h
+++ b/xmlserializer/XmlFileDocSource.h
@@ -73,6 +73,17 @@ public:
virtual bool isParsable(CXmlSerializingContext& serializingContext) const;
private:
+ /**
+ * Read xml file
+ *
+ * This function reads an xml file and processes eventual included files
+ * WARNING: to compile this function, libxml2 has to be compiled with LIBXML_XINCLUDE_ENABLED
+ *
+ * @param[in] strFileName the file name
+ *
+ * @return a pointer to generated xml document object
+ */
+ static _xmlDoc* readFile(const string& strFileName);
/**
* Instance file