WIP: XML schema validated except no ref at toplevel

This commit is contained in:
Jean Sirmai 2021-09-21 21:13:51 +02:00
parent 3194a2ecf8
commit c4197bdb01
Signed by untrusted user who does not match committer: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 94 additions and 101 deletions

View File

@ -13,20 +13,21 @@
<version>1.0</version> <version>1.0</version>
<ref id="texte" date="1629830000" author="Jean" lang="fr">Ref</ref>
</identity> </identity>
<!-- Model parameters --> <!-- Model parameters -->
<parameters id="texte" date="0" author="Gaston Lagaffe"> <parameters id="texte" date="0" author="Gaston Lagaffe">
<simulation> <simulation>
<max_thread value="0"/> <max_thread>0</max_thread>
<max_cycles value="13"/> <max_cycles>13</max_cycles>
</simulation> </simulation>
<space-param> <space-param>
<dimension value="1"/> <dimension>1</dimension>
<size value="39"/> <size>39</size>
<site_multiplicity value="2"/> <site_multiplicity>2</site_multiplicity>
</space-param> </space-param>
@ -105,21 +106,21 @@
</if> </if>
<then> <then>
<quote> <quote lang="fr">
Therefore I can (and I want to) move it to its next east location Therefore I can (and I want to) move it to its next east location
</quote> </quote>
<arrow x="0" y="0" z="0" site="1" weight="0"/> <arrow x="0" y="0" z="0" site="1" weight="0"/>
<arrow x="1" y="0" z="0" site="0" weight="0"> <arrow x="1" y="0" z="0" site="0" weight="0">
<quote>The identified dimer no more exists ( :-(( </quote> <quote lang="fr">The identified dimer no more exists ( :-(( </quote>
</arrow> </arrow>
<arrow x="1" y="0" z="0" site="1" weight="1"/> <arrow x="1" y="0" z="0" site="1" weight="1"/>
<arrow x="2" y="0" z="0" site="0" weight="1"> <arrow x="2" y="0" z="0" site="0" weight="1">
<quote> <quote lang="fr">
Happily, it is now rebuilt at its east location ( ;-)) Happily, it is now rebuilt at its east location ( ;-))
</quote> </quote>
@ -132,9 +133,4 @@
</transitions> </transitions>
<!-- Non context-specific tags, designed to annotate anything -->
<ref id="texte" date="1629830000" author="Jean" lang="ref"></ref>
<quote id="texte" date="1629830000" author="Jean" lang="ref"></quote>
</gem-graph-model> </gem-graph-model>

View File

@ -1,34 +1,40 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- https://www.freeformatter.com/xml-validator-xsd.html -->
<!-- https://www.w3schools.com/xml/el_attribute.asp -->
<!-- use="required" is NOT allowed in attributes declarations-->
<!-- To know : Attribute 'name' Cannot Appear In Element 'element'.-->
<!-- xs:element name="name" type="xs:string"/ -->
<!-- Cos-element-consistent: Error For Type '#AnonType_identitygem-graph-model'.
Multiple Elements With Name 'name', With Different Types, Appear In The Model Group. -->
<xs:attribute name="id" type="xs:string"/> <xs:attribute name="id" type="xs:string"/>
<xs:attribute name="date" type="xs:integer"/> <!--TODO type ? --> <xs:attribute name="date" type="xs:integer"/>
<xs:attribute name="name" type="xs:string"/> <xs:attribute name="name" type="xs:string"/>
<xs:attribute name="lang" type="xs:string"/> <xs:attribute name="lang" type="xs:string"/>
<xs:attribute name="value" type="xs:integer"/> <!--TODO WARNING: It's an integer !--> <xs:attribute name="owner" type="xs:string"/>
<xs:attribute name="owner" type="xs:integer"/> <xs:attribute name="owner_id" type="xs:integer"/>
<xs:attribute name="author" type="xs:string"/> <xs:attribute name="author" type="xs:string"/>
<xs:attribute name="version" type="xs:float"/> <xs:attribute name="version" type="xs:float"/>
<xs:attribute name="sequence" type="xs:integer"/>
<xs:attribute name="probability" type="xs:integer"/> <xs:attribute name="probability" type="xs:integer"/>
<xs:attribute name="parent" type="xs:string"/>
<!-- TO EVALUATE Consider using 'group' (?) or NOT -->
<!-- https://www.w3schools.com/xml/schema_complex_indicators.asp -->
<!-- TO EVALUATE Other definitions of an arrow (coord origin + dest,...) -->
<!-- TO EVALUATE Hypercubes pave the space => add a potential dimension 'w':
<xs:attribute name="w" type="xs:integer" default="0"/>-->
<xs:element name="arrow"> <!-- TODO Consider using 'group' : --> <xs:element name="a_string" type="xs:string"/>
<!-- https://www.w3schools.com/xml/schema_complex_indicators.asp -->
<xs:element name="ref">
<xs:complexType> <xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="id"/>
<xs:attribute ref="date"/>
<xs:attribute ref="author"/>
<xs:attribute ref="lang" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="quote" substitutionGroup="ref"/>
<xs:element name="arrow">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="quote"/>
</xs:sequence>
<xs:attribute name="x" type="xs:integer" default="1"/> <xs:attribute name="x" type="xs:integer" default="1"/>
<xs:attribute name="y" type="xs:integer" default="0"/> <xs:attribute name="y" type="xs:integer" default="0"/>
<xs:attribute name="z" type="xs:integer" default="0"/> <xs:attribute name="z" type="xs:integer" default="0"/>
@ -37,16 +43,6 @@
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<!-- A state can be connex or not. A connex state is an object.
A transition goes from an origin (state) to a target.
Therefore, element 'State' is used in
- objects definitions,
- initial and produced/computed states declarations,
- origin and target declarations of a transition.
What attributes should always be associated to a state ? -->
<xs:element name="state"> <xs:element name="state">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded"> <xs:sequence minOccurs="1" maxOccurs="unbounded">
@ -58,14 +54,49 @@
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="transition"> <xs:element name="object" substitutionGroup="state"/>
<xs:element name="space">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="2" maxOccurs="2"> <!-- TODO ... Cannot use 'length' --> <xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element ref="state"/> <xs:element ref="arrow"/>
</xs:sequence> </xs:sequence>
<xs:attribute ref="id" use="required"/> <xs:attribute ref="id" use="required"/>
<xs:attribute ref="date" use="required"/> <xs:attribute ref="date" use="required"/>
<xs:attribute ref="author" use="required"/> <xs:attribute ref="author" use="required"/>
<xs:attribute ref="sequence" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="if">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element minOccurs="0" ref="quote"/>
<xs:element ref="arrow"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="then">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element minOccurs="0" ref="quote"/>
<xs:element ref="arrow"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="transition">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element minOccurs="0" ref="quote"/>
<xs:element ref="if"/>
<xs:element ref="then"/>
</xs:sequence>
<xs:attribute ref="id" use="required"/>
<xs:attribute ref="date" use="required"/>
<xs:attribute ref="author" use="required"/>
<xs:attribute ref="parent" use="required"/>
<xs:attribute ref="probability" use="required"/> <xs:attribute ref="probability" use="required"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
@ -73,70 +104,44 @@
<xs:element name="gem-graph-model"> <xs:element name="gem-graph-model">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="identity"> <xs:element name="identity">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="name" type="xs:string"/> <xs:element name="owner" type="xs:string"/>
<xs:element name="owner" type="xs:integer"/> <xs:element name="owner_id" type="xs:integer"/>
<xs:element name="date" type="xs:integer"/> <xs:element name="date" type="xs:integer"/>
<xs:element name="version" type="xs:float"/> <xs:element name="version" type="xs:float"/>
<xs:element minOccurs="0" ref="ref"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="parameters"> <xs:element name="parameters">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="modelization"> <xs:element name="simulation">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="max_thread"> <xs:element name="max_thread"/>
<xs:complexType>
<xs:attribute ref="value" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="max_cycles"> <xs:element name="max_cycles"/>
<xs:complexType>
<xs:attribute ref="value" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="space"> <xs:element name="space-param">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="dimension"> <xs:element name="dimension"/>
<xs:complexType>
<xs:attribute ref="value" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="size"> <xs:element name="size"/>
<xs:complexType>
<xs:attribute ref="value" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="site_multiplicity"> <xs:element name="site_multiplicity"/>
<xs:complexType>
<xs:attribute ref="value" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="boundaries">
<xs:complexType>
</xs:complexType>
</xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
@ -152,7 +157,7 @@
<xs:element name="objects"> <xs:element name="objects">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded"> <xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element ref="state"/> <!--An object is a connex state --> <xs:element ref="state"/>
</xs:sequence> </xs:sequence>
<xs:attribute ref="id" use="required"/> <xs:attribute ref="id" use="required"/>
<xs:attribute ref="date" use="required"/> <xs:attribute ref="date" use="required"/>
@ -160,14 +165,10 @@
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<!--An initial state is made of at least one object --> <xs:element name="savestates">
<xs:element ref="state"/>
<!--An produced state is made of at least one object -->
<xs:element name="produced_states">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="state"/> <xs:element ref="space"/>
</xs:sequence> </xs:sequence>
<xs:attribute ref="id" use="required"/> <xs:attribute ref="id" use="required"/>
<xs:attribute ref="date" use="required"/> <xs:attribute ref="date" use="required"/>
@ -186,12 +187,8 @@
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="ref" type="xs:string"/>
<xs:element name="quote" type="xs:string"/>
</xs:sequence> </xs:sequence>
<xs:attribute ref="version" use="required"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:schema> </xs:schema>