/[volute]/trunk/projects/dm/vo-dml/xsd/vo-dml.sch.xml
ViewVC logotype

Contents of /trunk/projects/dm/vo-dml/xsd/vo-dml.sch.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3038 - (show annotations)
Tue Aug 25 14:27:31 2015 UTC (5 years, 11 months ago) by gerard.lemson
File MIME type: text/xml
File size: 7316 byte(s)
updating vo-dml XSD products.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
3 xmlns:fct="localFunctions"
4 xmlns:xs="http://www.w3.org/2001/XMLSchema"
5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6 <sch:ns uri="http://volute.googlecode.com/dm/vo-dml/v0.9" prefix="vo-dml"/>
7 <sch:ns prefix="fct" uri="localFunctions"/>
8
9 <sch:title>Schematron VO-DML Validator</sch:title>
10
11 <sch:pattern name="Unique_vodml-id">
12 <sch:rule context="vodml-id[not(../name() = 'vo-dml:model')]">
13 <sch:let name="count" value="count(./following::vodml-id[. = current()])"/>
14 <sch:assert test="$count = 0" flag="error">
15 vodml-id '<sch:value-of select="."/>' is not unique, there are <sch:value-of select="$count"/> other elements with same vodml-id in this model.
16 </sch:assert>
17 </sch:rule>
18 </sch:pattern>
19
20
21 <sch:pattern name="Single_Inheritance">
22 <sch:rule context="objectType|dataType|enumeration|primitiveType">
23 <sch:let name="count" value="count(extends)"/>
24 <sch:assert test="$count &lt; 2" flag="error">
25 <sch:value-of select="./vodml-id"/> has more than one extends relation.
26 </sch:assert>
27 </sch:rule>
28 </sch:pattern>
29
30 <sch:pattern name="Unique_composition">
31 <sch:rule context="collection/datatype/vodml-ref">
32 <sch:let name="count" value="count(//collection/datatype/vodml-ref[. = current()])"/>
33 <sch:assert test="$count = 1" flag="error">
34 <sch:value-of select="."/> is used more than once, namely <sch:value-of select="$count"/> times as target of composition relation.
35 (this message will repeat itself <sch:value-of select="$count"/> times!)
36 </sch:assert>
37 </sch:rule>
38 </sch:pattern>
39
40
41
42
43 <!-- Check that a model import exists for a vodml-refref with prefix not equal to vodml-ref of the model. -->
44 <sch:pattern name="RemoteModelImport">
45 <sch:rule context="vodml-ref[substring-before(text(),':') != '' and substring-before(text(),':') != /vo-dml:model/vodml-id]">
46 <sch:let name="prefix" value="substring-before(text(),':')"/>
47 <sch:assert test="/vo-dml:model/import/prefix = $prefix" flag="error">
48 There is no imported model corresponding to model prefix '<sch:value-of select="$prefix"/>' in this model.
49 </sch:assert>
50 </sch:rule>
51 </sch:pattern>
52
53 <sch:pattern name="vodml-refs">
54 <sch:rule context="objectType/attribute | dataType/attribute">
55 <sch:let name="owner" value="./vodml-id"/>
56 <sch:let name="target" value="fct:vo-dml_element(datatype/vodml-ref,/vo-dml:model)"/>
57 <sch:assert test="$target = 'primitiveType' or $target = 'dataType' or $target='enumeration'" flag="error">
58 datatype <sch:value-of select="datatype/vodml-ref"/> of <sch:value-of select="$owner"/> is not a value type but a '<sch:value-of select="$target"/>'
59 </sch:assert>
60 </sch:rule>
61
62 <sch:rule context="reference">
63 <sch:let name="owner" value="./vodml-id"/>
64 <sch:let name="target" value="fct:vo-dml_element(datatype/vodml-ref,/vo-dml:model)"/>
65 <sch:assert test="$target = 'objectType'" flag="error">
66 datatype <sch:value-of select="datatype/vodml-ref"/> of reference <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
67 </sch:assert>
68 </sch:rule>
69
70 <sch:rule context="objectType/collection">
71 <sch:let name="owner" value="./vodml-id"/>
72 <sch:let name="target" value="fct:vo-dml_element(datatype/vodml-ref,/vo-dml:model)"/>
73 <sch:assert test="$target = 'objectType'" flag="error">
74 datatype <sch:value-of select="datatype/vodml-ref"/> of collection <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
75 </sch:assert>
76 </sch:rule>
77
78 <sch:rule context="objectType/extends">
79 <sch:let name="owner" value="../vodml-id"/>
80 <sch:let name="target" value="fct:vo-dml_element(vodml-ref,/vo-dml:model)"/>
81 <sch:assert test="$target = 'objectType'" flag="error">
82 Super type <sch:value-of select="vodml-ref"/> of objectType <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
83 </sch:assert>
84 </sch:rule>
85
86 <sch:rule context="dataType/extends">
87 <sch:let name="owner" value="./vodml-id"/>
88 <sch:let name="target" value="fct:vo-dml_element(vodml-ref,/vo-dml:model)"/>
89 <sch:assert test="$target = 'dataType'" flag="error">
90 Super type <sch:value-of select="vodml-ref"/> of dataType/extends <sch:value-of select="$owner"/> is not a data type but a '<sch:value-of select="$target"/>'
91 </sch:assert>
92 </sch:rule>
93
94
95 <!-- rules on subsets can be rather complex.
96 A subsets element must be owned by a constraint on a type restricting a role on one of its super-types.
97 The subsets constraints must identify a datatype for the inherited role that is a subtype of the type
98 defined on the role.
99 The owner of the constraint must be a subtype of the owner of the subsetted role.
100 Problem: need not be direct subtypes, i.e. need recursion.
101 The roles must be of the same type (ie.e both attributes, or references or collections).
102 The roles must have same name (TBD correct?)
103 also, constraint must have n xsi:type identifying it a such.
104 OR shall we create a separate roleConstraint element? on structured types only.
105 -->
106 <sch:rule context="subsets">
107 <sch:let name="owner" value="../name()"/>
108 <sch:let name="target" value="fct:vo-dml_element(./vodml-ref,/vo-dml:model)"/>
109 <sch:assert test="$target" flag="error">
110 Target of subsets relation on '<sch:value-of select="../vodml-id"/>' with vodml-ref <sch:value-of select="./vodml-ref"/> can not be found
111 </sch:assert>
112 <sch:assert test="$target = $owner" flag="error">
113 Role '<sch:value-of select="../vodml-id"/>' with subsets relation of type '<sch:value-of select="$owner"/>' MUST have same type as subsetted role (<sch:value-of select="$target"/>)
114 </sch:assert>
115 </sch:rule>
116
117 <!-- TODO more rules need implementing
118 - objectType can only be contained in one other objecttype
119 - same, including inheritance (i.e. recursive, more tricky in Schematron?)
120 -...
121 -->
122
123 </sch:pattern>
124
125
126
127
128 <xsl:function name="fct:vo-dml_element" as="xs:string">
129 <!-- returns name of element containing the vodml-id identified by the vodml-ref -->
130 <xsl:param name="vodml-ref"/>
131 <xsl:param name="model"/>
132
133 <xsl:variable name="prefix" select="substring-before($vodml-ref,':')"/>
134 <xsl:variable name="targetvodml-ref" select="substring-after($vodml-ref,concat($prefix,':'))"/>
135 <xsl:choose>
136 <xsl:when test="$prefix = $model/name">
137 <xsl:value-of select="$model//*[vodml-id = $targetvodml-ref]/name()"/>
138 </xsl:when>
139 <xsl:otherwise>
140 <xsl:variable name="import" select="$model/import[name = $prefix]/url"/>
141 <xsl:choose>
142 <xsl:when test="$import">
143 <xsl:variable name="doc" select="document($import)"/>
144 <xsl:value-of select="$doc//*[vodml-id = $targetvodml-ref]/name()"/>
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:value-of select="'ERROR'"/>
148 </xsl:otherwise>
149 </xsl:choose>
150 </xsl:otherwise>
151 </xsl:choose>
152 </xsl:function>
153
154
155
156
157 </sch:schema>

Properties

Name Value
svn:mime-type text/xml

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26