[virt-tools-list] [PATCH libosinfo 1/4] Add an RNG schema for the libosinfo XML documents
Daniel P. Berrange
berrange at redhat.com
Thu Feb 23 17:19:59 UTC 2012
From: "Daniel P. Berrange" <berrange at redhat.com>
Create an RNG schema that will be installed into
/usr/share/libosinfo/schemas/libosinfo.rng and can
be used to validate XML files
---
configure.ac | 1 +
data/Makefile.am | 2 +-
data/schemas/Makefile.am | 5 +
data/schemas/libosinfo.rng | 417 ++++++++++++++++++++++++++++++++++++++++++++
libosinfo.spec.in | 2 +
mingw32-libosinfo.spec.in | 4 +
6 files changed, 430 insertions(+), 1 deletions(-)
create mode 100644 data/schemas/Makefile.am
create mode 100644 data/schemas/libosinfo.rng
diff --git a/configure.ac b/configure.ac
index 1980fc1..359fc6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,6 +158,7 @@ AC_CONFIG_FILES([
data/devices/Makefile
data/hypervisors/Makefile
data/oses/Makefile
+ data/schemas/Makefile
tools/Makefile
scripts/Makefile
test/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 28dbf5a..b5547cf 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = devices oses hypervisors
+SUBDIRS = devices oses hypervisors schemas
EXTRA_DIST = usb.ids pci.ids 95-osinfo.rules.in
diff --git a/data/schemas/Makefile.am b/data/schemas/Makefile.am
new file mode 100644
index 0000000..b24852d
--- /dev/null
+++ b/data/schemas/Makefile.am
@@ -0,0 +1,5 @@
+
+schemadir = $(pkgdatadir)/schemas
+schema_DATA = libosinfo.rng
+
+EXTRA_DIST = $(schema_DATA)
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
new file mode 100644
index 0000000..c4ad08b
--- /dev/null
+++ b/data/schemas/libosinfo.rng
@@ -0,0 +1,417 @@
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <start>
+ <ref name='libosinfo'/>
+ </start>
+
+ <define name='libosinfo'>
+ <element name='libosinfo'>
+ <attribute name='version'>
+ <choice>
+ <value>0.0.1</value>
+ </choice>
+ </attribute>
+
+ <zeroOrMore>
+ <choice>
+ <ref name='device'/>
+ <ref name='os'/>
+ <ref name='platform'/>
+ <ref name='deployment'/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+
+ <define name='device'>
+ <element name='device'>
+ <attribute name='id'>
+ <ref name='url'/>
+ </attribute>
+ <interleave>
+ <element name='name'>
+ <text/>
+ </element>
+ <element name='bus-type'>
+ <choice>
+ <value>isa</value>
+ <value>pci</value>
+ <value>usb</value>
+ <value>xen</value>
+ <value>ps2</value>
+ </choice>
+ </element>
+ <optional>
+ <element name='class'>
+ <choice>
+ <value>audio</value>
+ <value>block</value>
+ <value>console</value>
+ <value>filesystem</value>
+ <value>input</value>
+ <value>memory.balloon</value>
+ <value>net</value>
+ <value>video</value>
+ <value>watchdog</value>
+ </choice>
+ </element>
+ </optional>
+ <optional>
+ <element name='vendor'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='vendor-id'>
+ <ref name='hexid'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='device'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='device-id'>
+ <ref name='hexid'/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name="product-attr">
+ <attribute name='id'>
+ <ref name='url'/>
+ </attribute>
+ </define>
+
+ <define name="product-content">
+ <interleave>
+ <element name='vendor'>
+ <text/>
+ </element>
+ <element name='name'>
+ <text/>
+ </element>
+ <element name='short-id'>
+ <text/>
+ </element>
+ <optional>
+ <element name='version'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='codename'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='family'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </define>
+
+ <define name="product-dates">
+ <interleave>
+ <optional>
+ <element name='release-date'>
+ <ref name='date'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='eol-date'>
+ <ref name='date'/>
+ </element>
+ </optional>
+ </interleave>
+ </define>
+
+ <define name="product-rel">
+ <interleave>
+ <optional>
+ <element name="upgrades">
+ <attribute name='id'>
+ <ref name="url"/>
+ </attribute>
+ </element>
+ </optional>
+ <optional>
+ <element name="derives-from">
+ <attribute name='id'>
+ <ref name="url"/>
+ </attribute>
+ </element>
+ </optional>
+ <optional>
+ <element name="clones">
+ <attribute name='id'>
+ <ref name="url"/>
+ </attribute>
+ </element>
+ </optional>
+ </interleave>
+ </define>
+
+ <define name='devices-rel'>
+ <element name='devices'>
+ <zeroOrMore>
+ <element name='device'>
+ <attribute name='id'>
+ <ref name='url'/>
+ </attribute>
+ </element>
+ </zeroOrMore>
+ </element>
+ </define>
+
+ <define name='resource-attr'>
+ <interleave>
+ <optional>
+ <element name='cpu'>
+ <ref name='num'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='n-cpus'>
+ <ref name='num'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='ram'>
+ <ref name='num'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='storage'>
+ <ref name='num'/>
+ </element>
+ </optional>
+ </interleave>
+ </define>
+
+ <define name='resources'>
+ <element name='resources'>
+ <attribute name='arch'>
+ <text/>
+ </attribute>
+ <interleave>
+ <optional>
+ <element name='minimum'>
+ <ref name='resource-attr'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='recommended'>
+ <ref name='resource-attr'/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='iso'>
+ <element name='iso'>
+ <interleave>
+ <optional>
+ <element name='volume-id'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='publisher-id'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='application-id'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='system-id'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='media'>
+ <element name='media'>
+ <attribute name='arch'>
+ <text/>
+ </attribute>
+ <optional>
+ <attribute name="live">
+ <ref name='bool'/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="installer">
+ <ref name='bool'/>
+ </attribute>
+ </optional>
+ <optional>
+ <element name='url'>
+ <ref name='url'/>
+ </element>
+ </optional>
+ <optional>
+ <ref name='iso'/>
+ </optional>
+ <interleave>
+ <optional>
+ <element name='initrd'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='kernel'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='treeinfo'>
+ <element name='treeinfo'>
+ <interleave>
+ <optional>
+ <element name='family'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='variant'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='version'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='arch'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='tree'>
+ <element name='tree'>
+ <attribute name='arch'>
+ <text/>
+ </attribute>
+ <optional>
+ <element name='url'>
+ <ref name='url'/>
+ </element>
+ </optional>
+ <optional>
+ <ref name='treeinfo'/>
+ </optional>
+ <interleave>
+ <optional>
+ <element name='initrd'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='kernel'>
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name='boot-iso'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='os'>
+ <element name='os'>
+ <ref name='product-attr'/>
+ <ref name='product-content'/>
+ <optional>
+ <element name='family'>
+ <text/>
+ </element>
+ </optional>
+ <interleave>
+ <ref name='product-dates'/>
+ <ref name='product-rel'/>
+ <optional>
+ <ref name='devices-rel'/>
+ </optional>
+ <zeroOrMore>
+ <ref name='resources'/>
+ </zeroOrMore>
+ <zeroOrMore>
+ <ref name='media'/>
+ </zeroOrMore>
+ <zeroOrMore>
+ <ref name='tree'/>
+ </zeroOrMore>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='platform'>
+ <element name='platform'>
+ <ref name='product-attr'/>
+ <ref name='product-content'/>
+ <interleave>
+ <ref name='product-dates'/>
+ <ref name='product-rel'/>
+ <optional>
+ <ref name='devices-rel'/>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
+ <define name='deployment'>
+ <element name='deployment'>
+ <empty/>
+ </element>
+ </define>
+
+ <define name='date'>
+ <data type="string">
+ <param name="pattern">[0-9]{4}-[0-9]{2}-[0-9]{2}</param>
+ </data>
+ </define>
+
+ <define name='hexid'>
+ <data type="string">
+ <param name="pattern">[0-9a-fA-F]+</param>
+ </data>
+ </define>
+
+ <define name='bool'>
+ <data type='string'>
+ <param name='pattern'>true|false</param>
+ </data>
+ </define>
+
+ <define name='num'>
+ <data type="string">
+ <param name="pattern">[0-9]+</param>
+ </data>
+ </define>
+
+ <define name='url'>
+ <data type="string">
+ <param name="pattern">\w+://.*</param>
+ </data>
+ </define>
+</grammar>
\ No newline at end of file
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 8b98be0..192b660 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -101,11 +101,13 @@ rm -fr %{buildroot}
%{_bindir}/osinfo-detect
%dir %{_datadir}/libosinfo/
%dir %{_datadir}/libosinfo/data/
+%dir %{_datadir}/libosinfo/schemas/
%{_datadir}/libosinfo/data/usb.ids
%{_datadir}/libosinfo/data/pci.ids
%{_datadir}/libosinfo/data/devices
%{_datadir}/libosinfo/data/oses
%{_datadir}/libosinfo/data/hypervisors
+%{_datadir}/libosinfo/schemas/libosinfo.rng
%{_libdir}/%{name}-1.0.so.*
/lib/udev/rules.d/95-osinfo.rules
%if %{with_gir}
diff --git a/mingw32-libosinfo.spec.in b/mingw32-libosinfo.spec.in
index 2a0379a..4287271 100644
--- a/mingw32-libosinfo.spec.in
+++ b/mingw32-libosinfo.spec.in
@@ -69,11 +69,15 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_mingw32_includedir}/libosinfo-1.0/
%dir %{_mingw32_includedir}/libosinfo-1.0/osinfo
%{_mingw32_includedir}/libosinfo-1.0/osinfo/*.h
+%dir %{_mingw32_datadir}/libosinfo
+%dir %{_mingw32_datadir}/libosinfo/data
+%dir %{_mingw32_datadir}/libosinfo/schemas
%{_mingw32_datadir}/libosinfo/data/usb.ids
%{_mingw32_datadir}/libosinfo/data/pci.ids
%{_mingw32_datadir}/libosinfo/data/devices
%{_mingw32_datadir}/libosinfo/data/oses
%{_mingw32_datadir}/libosinfo/data/hypervisors
+%{_mingw32_datadir}/libosinfo/schemas/libosinfo.rng
%changelog
--
1.7.7.6
More information about the virt-tools-list
mailing list