/[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 2493 - (show annotations)
Wed Mar 26 16:44:01 2014 UTC (7 years, 5 months ago) by gerard.lemson
File MIME type: text/xml
File size: 4841 byte(s)
update vo-dml schematron file to include updates to meta-model.
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
12 <!-- Check that a model import exists for a utyperef with prefix not equal to utype of the model. -->
13 <sch:pattern name="RemoteModelImport">
14 <sch:rule context="utype[substring-before(text(),':') != '' and substring-before(text(),':') != /vo-dml:model/vodml-id]">
15 <sch:let name="prefix" value="substring-before(text(),':')"/>
16 <sch:assert test="/vo-dml:model/import/vodml-id = $prefix">
17 ERROR: There is no imported model corresponding to model prefix '<sch:value-of select="$prefix"/>' in this model.
18 </sch:assert>
19 </sch:rule>
20 </sch:pattern>
21
22 <sch:pattern name="Utypes">
23 <sch:rule context="attribute">
24 <sch:let name="owner" value="./vodml-id"/>
25 <sch:let name="target" value="fct:vo-dml_element(datatype/utype,/vo-dml:model)"/>
26 <sch:assert test="$target = 'primitiveType' or $target = 'dataType' or $target='enumeration'">
27 ERROR: datatype of <sch:value-of select="$owner"/> is not a value type but a '<sch:value-of select="$target"/>'
28 </sch:assert>
29 </sch:rule>
30
31 <sch:rule context="reference">
32 <sch:let name="owner" value="./vodml-id"/>
33 <sch:let name="target" value="fct:vo-dml_element(datatype/utype,/vo-dml:model)"/>
34 <sch:assert test="$target = 'objectType'">
35 ERROR: datatype of reference <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
36 </sch:assert>
37 </sch:rule>
38
39 <sch:rule context="objectType/collection">
40 <sch:let name="owner" value="./vodml-id"/>
41 <sch:let name="target" value="fct:vo-dml_element(datatype/utype,/vo-dml:model)"/>
42 <sch:assert test="$target = 'objectType'">
43 ERROR: datatype of collection <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
44 </sch:assert>
45 </sch:rule>
46
47 <sch:rule context="objectType[extends]">
48 <sch:let name="owner" value="./vodml-id"/>
49 <sch:let name="target" value="fct:vo-dml_element(extends/utype,/vo-dml:model)"/>
50 <sch:assert test="$target = 'objectType'">
51 ERROR: base type of objectType <sch:value-of select="$owner"/> is not an object type but a '<sch:value-of select="$target"/>'
52 </sch:assert>
53 </sch:rule>
54 <!-- rules on subsets can be rather complex.
55 A subsets element must be owned by a role that has a datatype that is a subtype of the datatype of the subsetted role.
56 The owner of the role must be a subtype of the owner of the subsetted role.
57 Problem: need not be direct subtypes, i.e. need recursion.
58 The roles must be of the same type (ie.e both attributes, or references or collections).
59 The roles must have same name (TBD correct?) -->
60 <sch:rule context="subsets">
61 <sch:let name="owner" value="../name()"/>
62 <sch:let name="target" value="fct:vo-dml_element(./utype,/vo-dml:model)"/>
63 <sch:assert test="$target">
64 ERROR: target of subsets relation with utype <sch:value-of select="./utype"/> can not be found
65 </sch:assert>
66 <sch:assert test="$target = $owner">
67 ERROR: role with subsets relation of type '<sch:value-of select="$owner"/>' MUST have same type as subsetted role (<sch:value-of select="$target"/>)
68 </sch:assert>
69 </sch:rule>
70
71 <!-- TODO more rules need implementing
72 - ...
73 -->
74
75 </sch:pattern>
76
77
78
79
80 <xsl:function name="fct:vo-dml_element" as="xs:string">
81 <!-- returns name of element containing the utype identified by the utyperef -->
82 <xsl:param name="utype"/>
83 <xsl:param name="model"/>
84
85 <xsl:variable name="prefix" select="substring-before($utype,':')"/>
86 <xsl:variable name="targetUtype" select="substring-after($utype,concat($prefix,':'))"/>
87 <xsl:choose>
88 <xsl:when test="$prefix = $model/vodml-id">
89 <xsl:value-of select="$model//*[vodml-id = $targetUtype]/name()"/>
90 </xsl:when>
91 <xsl:otherwise>
92 <xsl:variable name="import" select="$model/import[vodml-id = $prefix]/url"/>
93 <xsl:choose>
94 <xsl:when test="$import">
95 <xsl:variable name="doc" select="document($import)"/>
96 <xsl:value-of select="$doc//*[vodml-id = $targetUtype]/name()"/>
97 </xsl:when>
98 <xsl:otherwise>
99 <xsl:value-of select="'ERROR'"/>
100 </xsl:otherwise>
101 </xsl:choose>
102 </xsl:otherwise>
103 </xsl:choose>
104 </xsl:function>
105
106
107
108
109 </sch:schema>

Properties

Name Value
svn:mime-type text/xml

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