[Libosinfo] [PATCHv2 1/4] rng: Allow template inclusion in install scripts
Zeeshan Ali (Khattak)
zeeshanak at gnome.org
Wed Feb 27 14:20:33 UTC 2013
From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
Sometimes we'll have a lot in common between rather long templates of
different OSs. To be able to share the templates, we need a way to
include templates from one XML file to another.
XInclude[1] is the way we achieve that.
http://www.w3.org/TR/xinclude/
---
data/schemas/libosinfo.rng | 27 ++++++++++++++++++---------
osinfo/osinfo_loader.c | 9 +++++++++
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index bfa0ddb..8f1f13e 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -579,15 +579,24 @@
<ref name='bool'/>
</element>
</optional>
- <element name='template'>
- <choice>
- <group>
- <attribute name="uri"/>
- <empty/>
- </group>
- <ref name="customElement"/>
- </choice>
- </element>
+ <choice>
+ <element name='template'>
+ <choice>
+ <group>
+ <attribute name="uri"/>
+ <empty/>
+ </group>
+ <ref name="customElement"/>
+ </choice>
+ </element>
+ <element name='xi:include' xmlns:xi="http://www.w3.org/2001/XInclude">
+ <interleave>
+ <attribute name="href"/>
+ <attribute name="parse"/>
+ <attribute name="xpointer"/>
+ </interleave>
+ </element>
+ </choice>
<ref name='product-attr'/>
<ref name='product-rel'/>
</interleave>
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 76e9bc2..bfe118a 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -34,6 +34,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xmlreader.h>
+#include <libxml/xinclude.h>
#include "ignore-value.h"
#include "osinfo_install_script_private.h"
#include "osinfo_device_driver_private.h"
@@ -1391,6 +1392,14 @@ static void osinfo_loader_process_xml(OsinfoLoader *loader,
*/
g_clear_error(err);
+ if (xmlXIncludeProcessFlags(xml,
+ XML_PARSE_NOENT |
+ XML_PARSE_NONET |
+ XML_PARSE_NOWARNING) < 0) {
+ OSINFO_ERROR(err, _("Processing of 'xi:include' nodes failed"));
+ goto cleanup;
+ }
+
root = xmlDocGetRootElement(xml);
if (!root) {
--
1.8.1.2
More information about the Libosinfo
mailing list