[buoh/comic-validation: 32/32] Validate comics.xml



commit 183709ebd44e31af85688d4c26a3ceea3f29d837
Author: Jan Tojnar <jtojnar gmail com>
Date:   Fri Sep 21 00:30:30 2018 +0200

    Validate comics.xml

 data/comic_list.xsd | 30 ++++++++++++++++++++++++++++++
 data/meson.build    | 11 ++++++++++-
 meson.build         |  1 +
 3 files changed, 41 insertions(+), 1 deletion(-)
---
diff --git a/data/comic_list.xsd b/data/comic_list.xsd
new file mode 100644
index 0000000..adf55ac
--- /dev/null
+++ b/data/comic_list.xsd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
+  <xs:element name="comic_list">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element maxOccurs="unbounded" name="comic">
+          <xs:complexType>
+            <xs:sequence>
+              <xs:element maxOccurs="7" minOccurs="0" name="restrict" type="xs:int"/>
+            </xs:sequence>
+            <xs:attribute name="author" type="xs:string"/>
+            <xs:attribute name="class">
+              <xs:simpleType>
+                <xs:restriction base="xs:string">
+                  <xs:enumeration value="date"/>
+                </xs:restriction>
+              </xs:simpleType>
+            </xs:attribute>
+            <xs:attribute name="first" type="xs:date"/>
+            <xs:attribute name="generic_uri" type="xs:string"/>
+            <xs:attribute name="id" type="xs:ID" use="required"/>
+            <xs:attribute name="language" type="xs:string"/>
+            <xs:attribute name="offset" type="xs:string"/>
+            <xs:attribute name="title" type="xs:string"/>
+          </xs:complexType>
+        </xs:element>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
diff --git a/data/meson.build b/data/meson.build
index b17beee..7d6ecad 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -51,10 +51,19 @@ if desktop_file_validate.found()
   )
 endif
 
+comics = 'comics.xml'
 install_data(
-  'comics.xml',
+  comics,
   install_dir: comicsdir,
 )
+if xmllint.found()
+  test(
+    'Validating @0@'.format(comics),
+    xmllint,
+    args: ['--noout', '--schema', 'comic_list.xsd', comics],
+    workdir: meson.current_source_dir(),
+  )
+endif
 
 gnome.mkenums(
   'org.gnome.buoh.enums.xml',
diff --git a/meson.build b/meson.build
index 57f5f7e..613e25e 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,7 @@ libxml2 = dependency('libxml-2.0', version: '>= 2.4.0')
 
 desktop_file_validate = find_program('desktop-file-validate', required: false)
 gtk_builder_tool = find_program('gtk-builder-tool', required: false)
+xmllint = find_program('xmllint', required: false)
 
 buoh_deps = [
   gtk,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]