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



commit d18e5507aba1c7923dd6da523371785a8e34ed56
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 9929625..d13c3d5 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -32,10 +32,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 c7a4535..98f37f0 100644
--- a/meson.build
+++ b/meson.build
@@ -28,6 +28,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]