add XML schema - fixes #267

Thu, 03 Aug 2023 16:57:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 03 Aug 2023 16:57:57 +0200
changeset 29
5e958351935d
parent 28
98a259eabbf2
child 30
d4c38bb71fa0

add XML schema - fixes #267

test/make/project.xml file | annotate | diff | comparison | revisions
test/make/project2.xml file | annotate | diff | comparison | revisions
uwproj.xsd file | annotate | diff | comparison | revisions
--- a/test/make/project.xml	Tue Jul 25 17:43:43 2023 +0200
+++ b/test/make/project.xml	Thu Aug 03 16:57:57 2023 +0200
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project>
+<project xmlns="http://unixwork.de/uwproj">
 	<!-- makefile config -->
 	<config>
 		<var name="HOST" type="exec">uname -n</var>
--- a/test/make/project2.xml	Tue Jul 25 17:43:43 2023 +0200
+++ b/test/make/project2.xml	Thu Aug 03 16:57:57 2023 +0200
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project>
+<project xmlns="http://unixwork.de/uwproj">
 	<dependency name="curl" platform="windows">
 		<cflags>-I/mingw/include</cflags>
 		<ldflags>-lcurl</ldflags>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uwproj.xsd	Thu Aug 03 16:57:57 2023 +0200
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns="http://unixwork.de/uwproj"
+           targetNamespace="http://unixwork.de/uwproj"
+           elementFormDefault="qualified">
+    <xs:element name="project" type="ProjectType"/>
+
+    <xs:complexType name="ProjectType">
+        <xs:sequence>
+            <xs:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="config" type="ConfigType" minOccurs="0"/>
+            <xs:element name="dependency" type="DependencyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="target" type="TargetType" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="PropertyType">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="value" type="xs:string" use="required"/>
+    </xs:complexType>
+
+    <xs:complexType name="ConfigType">
+        <xs:sequence>
+            <xs:element name="var" type="ConfigVarType" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="ConfigVarType">
+        <xs:simpleContent>
+            <xs:extension base="xs:string">
+                <xs:attribute name="name" type="xs:string" use="required"/>
+                <xs:attribute name="type" type="ExecType"/>
+            </xs:extension>
+        </xs:simpleContent>
+    </xs:complexType>
+
+    <!-- TODO: we should replace this type with a simple Boolean -->
+    <xs:simpleType name="ExecType">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="exec"/>
+        </xs:restriction>
+    </xs:simpleType>
+
+    <xs:complexType name="DependencyType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:element name="lang" type="xs:string"/>
+            <xs:element name="cflags" type="FlagsType"/>
+            <xs:element name="ldflags" type="FlagsType"/>
+            <xs:element name="pkgconfig" type="xs:string"/>
+            <xs:element name="test" type="xs:string"/>
+            <xs:element name="make" type="xs:string"/>
+        </xs:choice>
+        <xs:attribute name="name" type="xs:string"/>
+        <xs:attribute name="platform" type="xs:string"/>
+        <xs:attribute name="not" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:complexType name="FlagsType">
+        <xs:simpleContent>
+            <xs:extension base="xs:string">
+                <xs:attribute name="type" type="ExecType"/>
+            </xs:extension>
+        </xs:simpleContent>
+    </xs:complexType>
+
+    <xs:complexType name="TargetType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:element name="feature" type="FeatureType"/>
+            <xs:element name="option" type="OptionType"/>
+            <xs:element name="define" type="DefineType"/>
+            <xs:element name="dependencies" type="DependenciesType"/>
+            <xs:element name="alldependencies">
+                <xs:complexType/>
+            </xs:element>
+        </xs:choice>
+        <xs:attribute name="name" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:complexType name="FeatureType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:group ref="TargetDataGroup"/>
+        </xs:choice>
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="arg" type="xs:string"/>
+        <xs:attribute name="default" default="false">
+            <!-- TODO: this should be just Boolean -->
+            <xs:simpleType>
+                <xs:restriction base="xs:string">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                    <xs:enumeration value="on"/>
+                    <xs:enumeration value="off"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
+    </xs:complexType>
+
+    <xs:complexType name="OptionType">
+        <xs:sequence>
+            <xs:element name="value" type="OptionValueType" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="default" type="OptionDefaultType" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+        <xs:attribute name="arg" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:complexType name="OptionValueType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:group ref="TargetDataGroup"/>
+        </xs:choice>
+        <xs:attribute name="str" type="xs:string" use="required"/>
+    </xs:complexType>
+
+    <xs:complexType name="OptionDefaultType">
+        <xs:attribute name="value" type="xs:string" use="required"/>
+        <xs:attribute name="platform" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:group name="TargetDataGroup">
+        <xs:choice>
+            <xs:element name="define" type="DefineType" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="dependencies" type="DependenciesType" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="make" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:choice>
+    </xs:group>
+
+    <xs:complexType name="DefineType">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="value" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:simpleType name="DependenciesType">
+        <xs:restriction base="xs:string"/>
+    </xs:simpleType>
+</xs:schema>
\ No newline at end of file

mercurial