Changeset 5628
- Timestamp:
- 09/15/14 10:21:49 (10 years ago)
- Location:
- metadata/trunk/toolkit
- Files:
-
- 11 deleted
- 3 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
metadata/trunk/toolkit/xsd/cmd-component.xsd
r5617 r5628 11 11 12 12 <!-- root element --> 13 <xs:element name="CMD_ComponentSpec"> 13 <xs:element name="ComponentSpec"> 14 <xs:annotation> 15 <xs:appinfo> 16 <sch:pattern id="h_succ"> 17 <sch:title>Check successor</sch:title> 18 <sch:rule context="Header/Successor"> 19 <sch:assert test="../Status='deprecated'">There can only be a successor component/profile if the status of this component/profile is deprecated!</sch:assert> 20 </sch:rule> 21 </sch:pattern> 22 <sch:pattern id="r_card"> 23 <sch:title>Cardinality root component</sch:title> 24 <sch:rule context="ComponentSpec/Component"> 25 <sch:assert test="empty(@CardinalityMin) or @CardinalityMin='1'">The minimum cardinality of the root component should be 1!</sch:assert> 26 <sch:assert test="empty(@CardinalityMax) or @CardinalityMax='1'">The maximum cardinality of the root component should be 1!</sch:assert> 27 </sch:rule> 28 </sch:pattern> 29 </xs:appinfo> 30 </xs:annotation> 14 31 <xs:complexType> 15 32 <xs:sequence> … … 20 37 <xs:element name="Name" type="xs:string" minOccurs="0"/> 21 38 <xs:element name="Description" type="xs:string" minOccurs="0"/> 39 <!-- status information --> 40 <xs:element name="Status" minOccurs="1" maxOccurs="1"> 41 <xs:simpleType> 42 <xs:restriction base="xs:string"> 43 <xs:enumeration value="development"/> 44 <xs:enumeration value="production"/> 45 <xs:enumeration value="deprecated"/> 46 </xs:restriction> 47 </xs:simpleType> 48 </xs:element> 49 <xs:element name="StatusComment" type="xs:string" minOccurs="0" maxOccurs="1"/> 50 <xs:element name="Successor" type="xs:anyURI" minOccurs="0" maxOccurs="1"/> 22 51 </xs:sequence> 23 52 </xs:complexType> 24 53 </xs:element> 25 <xs:element name="C MD_Component" type="CMD_Component_type">54 <xs:element name="Component" type="Component_type"> 26 55 <xs:annotation> 27 56 <xs:documentation>At the root level there should always be a … … 40 69 <sch:pattern id="c_sibs"> 41 70 <sch:title>Check siblings</sch:title> 42 <sch:rule context="C MD_Component|CMD_Element">71 <sch:rule context="Component|Element"> 43 72 <sch:assert test="empty(preceding-sibling::*[@name=current()/@name])">Sibling components or elements should all have a different name. Found multiple components or elements named '<sch:value-of select="@name"/>'!</sch:assert> 44 73 </sch:rule> … … 46 75 <sch:pattern id="c_csibs"> 47 76 <sch:title>Check component siblings</sch:title> 48 <sch:rule context="C MD_Component">49 <sch:assert test="empty(preceding-sibling::C MD_Component[@ComponentId=current()/@ComponentId])">Sibling components should all be different. Found multiple components with id '<sch:value-of select="@ComponentId"/>'!</sch:assert>50 </sch:rule> 51 </sch:pattern> 52 <!-- TODO: the names of referenced external components are not known, so we can't currently checktwo or more of them use the same name -->77 <sch:rule context="Component"> 78 <sch:assert test="empty(preceding-sibling::Component[@ComponentId=current()/@ComponentId])">Sibling components should all be different. Found multiple components with id '<sch:value-of select="@ComponentId"/>'!</sch:assert> 79 </sch:rule> 80 </sch:pattern> 81 <!-- TODO: check: the names of referenced external components are not known, so we can't currently check if two or more of them use the same name --> 53 82 <sch:pattern id="c_nest"> 54 83 <sch:title>Check nesting</sch:title> 55 <sch:rule context="C MD_Component[exists(CMD_Component|CMD_Element)]" role="warning">56 <sch:assert test="empty((C MD_Component|CMD_Element)[@name=current()/@name])">A nested component or element has the same name ('<sch:value-of select="@name"/>') as this component! Please, consider to rename one of them.</sch:assert>57 </sch:rule> 58 </sch:pattern> 59 </xs:appinfo> 84 <sch:rule context="Component[exists(Component|Element)]" role="warning"> 85 <sch:assert test="empty((Component|Element)[@name=current()/@name])">A nested component or element has the same name ('<sch:value-of select="@name"/>') as this component! Please, consider to rename one of them.</sch:assert> 86 </sch:rule> 87 </sch:pattern> 88 </xs:appinfo> 60 89 </xs:annotation> 61 90 <xs:sequence> 91 <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/> 62 92 <!-- from small (attribute) to big (component) --> 63 93 <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/> 64 <xs:element name=" CMD_Element" type="CMD_Element_type" minOccurs="0"94 <xs:element name="Element" type="Element_type" minOccurs="0" 65 95 maxOccurs="unbounded"> </xs:element> 66 <xs:element name="C MD_Component" type="CMD_Component_type" minOccurs="0"96 <xs:element name="Component" type="Component_type" minOccurs="0" 67 97 maxOccurs="unbounded"/> 68 98 </xs:sequence> … … 70 100 71 101 <!-- type definitions --> 72 <xs:complexType name="CMD_Element_type"> 102 <xs:complexType name="Documentation_type"> 103 <xs:annotation> 104 <xs:documentation>Some information an application (eg Arbil) can display to give 105 guidance to the user when entering metadata.</xs:documentation> 106 <xs:appinfo> 107 <sch:pattern id="d_dsibs"> 108 <sch:title>Check Documentation siblings</sch:title> 109 <sch:rule context="Documentation"> 110 <sch:assert test="empty(preceding-sibling::Documentation[@xml:lang=current()/@xml:lang])">Sibling Documentation elements should all be for different languages. Found multiple Documentation elements with xml:lang '<sch:value-of select="@xml:lang"/>'!</sch:assert> 111 </sch:rule> 112 </sch:pattern> 113 </xs:appinfo> 114 </xs:annotation> 115 <xs:simpleContent> 116 <xs:extension base="xs:string"> 117 <xs:attribute ref="xml:lang" use="optional"/> 118 </xs:extension> 119 </xs:simpleContent> 120 </xs:complexType> 121 122 <xs:complexType name="Element_type"> 123 <xs:annotation> 124 <xs:appinfo> 125 <sch:pattern id="e_vs"> 126 <sch:title>Check Element ValueScheme</sch:title> 127 <sch:rule context="Element"> 128 <sch:assert test="exists(@ValueScheme) or exists(ValueScheme)">An Element must have either a @ValueScheme or a ./ValueScheme!</sch:assert> 129 </sch:rule> 130 </sch:pattern> 131 </xs:appinfo> 132 </xs:annotation> 73 133 <xs:sequence> 134 <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/> 74 135 <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"> 75 136 <xs:annotation> … … 85 146 </xs:annotation> 86 147 </xs:element> 148 <xs:element name="AutoValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 87 149 </xs:sequence> 88 <xs:attributeGroup ref="clarin_element_attributes"/> 89 </xs:complexType> 90 150 <xs:attributeGroup ref="element_attributes"/> 151 </xs:complexType> 91 152 92 153 <xs:complexType name="ValueScheme_type"> 154 <xs:annotation> 155 <xs:appinfo> 156 <sch:pattern id="v_uri"> 157 <sch:title>Check Vocabulary URI</sch:title> 158 <sch:rule context="Vocabulary[exists(@URI)]"> 159 <sch:assert test="exists(@ValueProperty)">When an external vocabulary (identified by the @URI) a @ValueProperty has to be specified!</sch:assert> 160 </sch:rule> 161 </sch:pattern> 162 </xs:appinfo> 163 </xs:annotation> 93 164 <xs:choice> 94 165 <xs:element name="pattern" type="xs:string" maxOccurs="1"> … … 98 169 </xs:annotation> 99 170 </xs:element> 100 <xs:element name="enumeration" type="enumeration_type"> 101 <xs:annotation> 102 <xs:documentation>A list of the allowed values of a controlled 103 vocabulary.</xs:documentation> 171 <xs:element name="Vocabulary" type="Vocabulary_type"> 172 <xs:annotation> 173 <xs:documentation>Specification of an open or closed vocabulary</xs:documentation> 104 174 </xs:annotation> 105 175 </xs:element> … … 107 177 </xs:complexType> 108 178 179 <xs:complexType name="Vocabulary_type"> 180 <xs:sequence> 181 <xs:element name="enumeration" type="enumeration_type" minOccurs="0" maxOccurs="1"> 182 <xs:annotation> 183 <xs:documentation>A list of the allowed values of a controlled vocabulary.</xs:documentation> 184 </xs:annotation> 185 </xs:element> 186 </xs:sequence> 187 <xs:attribute name="URI" type="xs:anyURI"/> 188 <!-- optionally selects a label --> 189 <xs:attribute name="ValueProperty" type="xs:string"/> 190 <!-- optionally selects a language --> 191 <xs:attribute name="ValueLanguage" type="xs:language"/> 192 </xs:complexType> 109 193 110 194 <xs:complexType name="AttributeList_type"> 195 <xs:annotation> 196 <xs:appinfo> 197 <sch:pattern id="a_vs"> 198 <sch:title>Check Attribute ValueScheme</sch:title> 199 <sch:rule context="Attribute"> 200 <sch:assert test="exists(@ValueScheme) or exists(ValueScheme)">An Attribute must have either a @ValueScheme or a ./ValueScheme!</sch:assert> 201 </sch:rule> 202 </sch:pattern> 203 </xs:appinfo> 204 </xs:annotation> 111 205 <xs:sequence> 112 206 <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded"> … … 116 210 <sch:title>Check reserved attribute names</sch:title> 117 211 <sch:rule context="Attribute"> 118 <sch:assert test="not( Name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert>212 <sch:assert test="not(@name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert> 119 213 </sch:rule> 120 214 </sch:pattern> … … 122 216 <sch:title>Check attribute siblings</sch:title> 123 217 <sch:rule context="Attribute"> 124 <sch:assert test="empty(preceding-sibling::Attribute[ Name=current()/Name])">All attributes in an attribute list should have a different name. Found multiple attributes named '<sch:value-of select="Name"/>'!</sch:assert>218 <sch:assert test="empty(preceding-sibling::Attribute[@name=current()/@name])">All attributes in an attribute list should have a different name. Found multiple attributes named '<sch:value-of select="Name"/>'!</sch:assert> 125 219 </sch:rule> 126 220 </sch:pattern> … … 128 222 <sch:title>Check attribute nesting</sch:title> 129 223 <sch:rule context="Attribute" role="warning"> 130 <sch:assert test="empty((ancestor::C MD_Component|ancestor::CMD_Element)[1][@name=current()/Name])">An attribute has the same name ('<sch:value-of select="Name"/>') as its element or component! Please, consider to rename one of them.</sch:assert>224 <sch:assert test="empty((ancestor::Component|ancestor::Element)[1][@name=current()/@ame])">An attribute has the same name ('<sch:value-of select="@name"/>') as its element or component! Please, consider to rename one of them.</sch:assert> 131 225 </sch:rule> 132 226 </sch:pattern> 133 </xs:appinfo> 227 </xs:appinfo> 134 228 </xs:annotation> 135 229 <xs:complexType> 136 230 <xs:sequence> 137 <xs:element name="Name" type="xs:string"> 231 <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/> 232 <xs:element name="ValueScheme" type="ValueScheme_type" minOccurs="0"> 138 233 <xs:annotation> 139 <xs:documentation>The name of the attribute.</xs:documentation> 234 <xs:documentation>For the use of a regular expression or a 235 controlled vocabulary as the type of the 236 attribute.</xs:documentation> 140 237 </xs:annotation> 141 238 </xs:element> 142 <xs:element name="ConceptLink" type="xs:anyURI" minOccurs="0"> 143 <xs:annotation> 144 <xs:documentation>A link to the ISOcat data category registry (or any other concept registry).</xs:documentation> 145 </xs:annotation> 146 </xs:element> 147 <xs:choice> 148 <xs:element name="Type" type="allowed_attributetypes_type"> 149 <xs:annotation> 150 <xs:documentation>For the use of simple XML types as the type of 151 the attribute.</xs:documentation> 152 </xs:annotation> 153 </xs:element> 154 <xs:element name="ValueScheme" type="ValueScheme_type"> 155 <xs:annotation> 156 <xs:documentation>For the use of a regular expression or a 157 controlled vocabulary as the type of the 158 attribute.</xs:documentation> 159 </xs:annotation> 160 </xs:element> 161 </xs:choice> 239 <xs:element name="AutoValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 162 240 </xs:sequence> 241 <xs:attributeGroup ref="attribute_attributes"/> 163 242 </xs:complexType> 164 243 </xs:element> … … 166 245 </xs:complexType> 167 246 168 <xs:complexType name="C MD_Component_type">247 <xs:complexType name="Component_type"> 169 248 <xs:group ref="group" minOccurs="0"/> 170 <xs:attributeGroup ref="clarin_component_attributes"/> 171 </xs:complexType> 172 173 174 <!-- list of all attributes that can be bound to a cl_el --> 175 <xs:attributeGroup name="clarin_element_attributes"> 249 <xs:attributeGroup ref="component_attributes"/> 250 </xs:complexType> 251 252 <xs:attributeGroup name="attribute_attributes"> 176 253 <xs:attribute name="name" type="xs:Name" use="required"> 177 254 <xs:annotation> 178 <xs:documentation>The name of the element.</xs:documentation>255 <xs:documentation>The name of the attribute.</xs:documentation> 179 256 </xs:annotation> 180 257 </xs:attribute> … … 187 264 <xs:attribute name="ValueScheme" type="allowed_attributetypes_type"> 188 265 <xs:annotation> 266 <xs:documentation>For the use of simple XML types as the type of 267 the attribute.</xs:documentation> 268 </xs:annotation> 269 </xs:attribute> 270 <xs:attribute name="Required" type="xs:boolean"> 271 <xs:annotation> 272 <xs:documentation>Is the attribute required or not?</xs:documentation> 273 </xs:annotation> 274 </xs:attribute> 275 <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/> 276 </xs:attributeGroup> 277 278 <xs:attributeGroup name="element_attributes"> 279 <xs:attribute name="name" type="xs:Name" use="required"> 280 <xs:annotation> 281 <xs:documentation>The name of the element.</xs:documentation> 282 </xs:annotation> 283 </xs:attribute> 284 <xs:attribute name="ConceptLink" type="xs:anyURI"> 285 <xs:annotation> 286 <xs:documentation>A link to the ISOcat data category registry (or any other concept 287 registry).</xs:documentation> 288 </xs:annotation> 289 </xs:attribute> 290 <xs:attribute name="ValueScheme" type="allowed_attributetypes_type"> 291 <xs:annotation> 189 292 <xs:documentation>Used to specify that an element has a simple XML type (string, 190 293 integer, etc)</xs:documentation> … … 199 302 <xs:annotation> 200 303 <xs:documentation>Maximal number of occurrences.</xs:documentation> 201 </xs:annotation>202 </xs:attribute>203 <xs:attribute name="Documentation" type="xs:string">204 <xs:annotation>205 <xs:documentation>Some information an application (eg Arbil) can display to give206 guidance to the user when entering metadata.</xs:documentation>207 </xs:annotation>208 </xs:attribute>209 <xs:attribute name="DisplayPriority" type="xs:integer">210 <xs:annotation>211 <xs:documentation>The element with the highest priority will be displayed as the212 label for a metadata file (eg in Arbil)</xs:documentation>213 304 </xs:annotation> 214 305 </xs:attribute> … … 221 312 </xs:annotation> 222 313 </xs:attribute> 314 <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/> 223 315 </xs:attributeGroup> 224 316 225 <!-- list of all attributes that can be bound to a cl_comp --> 226 <xs:attributeGroup name="clarin_component_attributes"> 317 <xs:attributeGroup name="component_attributes"> 227 318 <xs:attribute name="name" type="xs:Name"/> 228 319 <xs:attribute name="ComponentId" type="xs:anyURI"> … … 238 329 </xs:annotation> 239 330 </xs:attribute> 240 <xs:attribute name="filename" type="xs:anyURI">241 <xs:annotation>242 <xs:documentation>Outdated way of including an external component. Here for backward243 compatibility with the XML-cmdi-toolkit.</xs:documentation>244 </xs:annotation>245 </xs:attribute>246 247 <!-- (components cannot have a ValueScheme attribute) -->248 249 331 <xs:attribute name="CardinalityMin" type="cardinality_type"/> 250 332 <xs:attribute name="CardinalityMax" type="cardinality_type"/> 251 333 <xs:attribute ref="xml:base"/> 334 <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/> 252 335 </xs:attributeGroup> 253 336 … … 381 464 </xs:annotation> 382 465 </xs:attribute> 466 <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/> 383 467 </xs:extension> 384 468 </xs:simpleContent> -
metadata/trunk/toolkit/xsd/cmd-envelop.xsd
r5617 r5628 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org" targetNamespace="http://www.clarin.eu/cmd/" attributeFormDefault="unqualified" elementFormDefault="qualified"> 3 <xs:element name="CMD"> 4 <xs:complexType> 5 <xs:sequence> 6 <xs:element name="Header"> 7 <xs:complexType> 8 <xs:sequence> 9 <xs:element name="MdCreator" type="xs:string" minOccurs="0"/> 10 <xs:element name="MdCreationDate" type="xs:date" minOccurs="0"/> 11 <xs:element name="MdSelfLink" type="xs:anyURI" minOccurs="0"/> 12 <xs:element name="MdProfile" type="xs:anyURI" minOccurs="0"/> 13 </xs:sequence> 14 </xs:complexType> 15 </xs:element> 16 <xs:element name="Resources"> 17 <xs:complexType> 18 <xs:sequence> 19 <xs:element name="ResourceProxyList"> 20 <xs:complexType> 21 <xs:sequence> 22 <xs:element maxOccurs="unbounded" minOccurs="0" name="ResourceProxy"> 23 <xs:complexType> 2 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:cmd="http://www.clarin.eu/cmd/" targetNamespace="http://www.clarin.eu/cmd/" elementFormDefault="qualified"> 3 <!-- globally declare attributes, so they have to be qualified --> 4 <xs:attribute name="ref" type="xs:IDREF"/> 5 <xs:attribute name="ComponentId" type="xs:anyURI"/> 6 <xs:attribute name="ValueConceptLink" type="xs:anyURI"/> 7 <!-- enumeration of resource types --> 8 <xs:simpleType name="Resourcetype_simple"> 9 <xs:restriction base="xs:string"> 10 <xs:enumeration value="Metadata"> 11 <xs:annotation> 12 <xs:documentation>The ResourceProxy refers to another component metadata instance (e.g. for grouping metadata descriptions into collections)</xs:documentation> 13 </xs:annotation> 14 </xs:enumeration> 15 <xs:enumeration value="Resource"> 16 <xs:annotation> 17 <xs:documentation>The ResourceProxy refers to a file that is not a metadata instance (e.g. a text document)</xs:documentation> 18 </xs:annotation> 19 </xs:enumeration> 20 <xs:enumeration value="SearchService"> 21 <xs:annotation> 22 <xs:documentation>The ResourceProxy refers to a (SRU/CQL) web service that can be used to query the resource described in this file</xs:documentation> 23 </xs:annotation> 24 </xs:enumeration> 25 <xs:enumeration value="SearchPage"> 26 <xs:annotation> 27 <xs:documentation>The ResourceProxy refers to a web page that can be used to query the resource described in this file</xs:documentation> 28 </xs:annotation> 29 </xs:enumeration> 30 <xs:enumeration value="LandingPage"> 31 <xs:annotation> 32 <xs:documentation>The ResourceProxy refers to a web page that contains the "original context" of the resource described in this file (e.g. repository web page displaying the metadata).</xs:documentation> 33 </xs:annotation> 34 </xs:enumeration> 35 </xs:restriction> 36 </xs:simpleType> 37 <!-- the root of a CMD record --> 38 <xs:element name="CMD"> 39 <xs:complexType> 40 <xs:sequence> 41 <!-- metadata of the CMD record --> 42 <xs:element name="Header" minOccurs="1" maxOccurs="1"> 43 <xs:complexType> 44 <xs:sequence> 45 <xs:element name="MdCreator" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 46 <xs:element name="MdCreationDate" type="xs:date" minOccurs="0" maxOccurs="1"/> 47 <xs:element name="MdSelfLink" type="xs:anyURI" minOccurs="0" maxOccurs="1"/> 48 <xs:element name="MdProfile" type="xs:anyURI" minOccurs="1" maxOccurs="1"/> 49 <xs:element name="MdCollectionDisplayName" type="xs:string" minOccurs="0" maxOccurs="1"/> 50 </xs:sequence> 51 </xs:complexType> 52 </xs:element> 53 <!-- this CMD record is related to these resources --> 54 <xs:element name="Resources" minOccurs="1" maxOccurs="1"> 55 <xs:complexType> 56 <xs:sequence> 57 <xs:element name="ResourceProxyList" minOccurs="1" maxOccurs="1"> 58 <xs:complexType> 24 59 <xs:sequence> 25 <xs:element maxOccurs="1" minOccurs="1" name="ResourceType">26 <xs:simpleType>27 <xs:restriction base="xs:string">28 <xs:enumeration value="Metadata">29 <xs:annotation>30 <xs:documentation>The ResourceProxy refers to another component metadata instance (e.g. for grouping metadata descriptions into collections)</xs:documentation>31 </xs:annotation>32 </xs:enumeration>33 <xs:enumeration value="Resource">34 <xs:annotation>35 <xs:documentation>The ResourceProxy refers to a file that is not a metadata instance (e.g. a text document)</xs:documentation>36 </xs:annotation>37 </xs:enumeration>38 </xs:restriction>39 </xs:simpleType>40 </xs:element>41 <xs:element maxOccurs="1" minOccurs="1" name="ResourceRef" type="xs:anyURI"/>60 <xs:element name="ResourceProxy" minOccurs="0" maxOccurs="unbounded"> 61 <xs:complexType> 62 <xs:sequence> 63 <xs:element name="ResourceType" minOccurs="1" maxOccurs="1"> 64 <xs:complexType> 65 <xs:simpleContent> 66 <xs:extension base="cmd:Resourcetype_simple"> 67 <xs:attribute name="mimetype" type="xs:string" use="optional"/> 68 </xs:extension> 69 </xs:simpleContent> 70 </xs:complexType> 71 </xs:element> 72 <xs:element name="ResourceRef" minOccurs="1" maxOccurs="1" type="xs:anyURI"/> 73 </xs:sequence> 74 <xs:attribute name="id" type="xs:ID" use="required"/> 75 </xs:complexType> 76 </xs:element> 42 77 </xs:sequence> 43 <xs:attribute name="id" type="xs:ID" use="required"/> 44 </xs:complexType> 45 </xs:element> 46 </xs:sequence> 47 </xs:complexType> 48 </xs:element> 49 <xs:element name="JournalFileProxyList"> 50 <xs:complexType> 51 <xs:sequence> 52 <xs:element maxOccurs="unbounded" minOccurs="0" name="JournalFileProxy"> 53 <xs:complexType> 78 </xs:complexType> 79 </xs:element> 80 <xs:element name="JournalFileProxyList" minOccurs="1" maxOccurs="1"> 81 <xs:complexType> 54 82 <xs:sequence> 55 <xs:element maxOccurs="1" minOccurs="1" name="JournalFileRef" type="xs:anyURI"/> 83 <xs:element name="JournalFileProxy" minOccurs="0" maxOccurs="unbounded"> 84 <xs:complexType> 85 <xs:sequence> 86 <xs:element name="JournalFileRef" minOccurs="1" maxOccurs="1" type="xs:anyURI"/> 87 </xs:sequence> 88 </xs:complexType> 89 </xs:element> 56 90 </xs:sequence> 57 </xs:complexType> 58 </xs:element> 59 </xs:sequence> 60 </xs:complexType> 61 </xs:element> 62 <xs:element name="ResourceRelationList"> 63 <xs:complexType> 64 <xs:sequence> 65 <xs:element maxOccurs="unbounded" minOccurs="0" name="ResourceRelation"> 66 <xs:complexType> 91 </xs:complexType> 92 </xs:element> 93 <!-- the resouces can have relationships among them --> 94 <xs:element name="ResourceRelationList" minOccurs="1" maxOccurs="1"> 95 <xs:complexType> 67 96 <xs:sequence> 68 <xs:element maxOccurs="1" minOccurs="1" name="RelationType"/> 69 <xs:element maxOccurs="1" minOccurs="1" name="Res1"> 70 <xs:complexType> 71 <xs:attribute name="ref" type="xs:IDREF"/> 72 </xs:complexType> 73 </xs:element> 74 <xs:element maxOccurs="1" minOccurs="1" name="Res2"> 75 <xs:complexType> 76 <xs:attribute name="ref" type="xs:IDREF"/> 77 </xs:complexType> 78 </xs:element> 97 <xs:element name="ResourceRelation" minOccurs="0" maxOccurs="unbounded"> 98 <xs:complexType> 99 <xs:sequence> 100 <xs:element name="RelationType" minOccurs="1" maxOccurs="1"> 101 <xs:complexType> 102 <xs:simpleContent> 103 <xs:extension base="xs:string"> 104 <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional"/> 105 </xs:extension> 106 </xs:simpleContent> 107 </xs:complexType> 108 </xs:element> 109 <xs:element name="Resource" minOccurs="2" maxOccurs="2"> 110 <xs:complexType> 111 <xs:sequence> 112 <xs:element name="Role" minOccurs="0" maxOccurs="1"> 113 <xs:complexType> 114 <xs:simpleContent> 115 <xs:extension base="xs:string"> 116 <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional"/> 117 </xs:extension> 118 </xs:simpleContent> 119 </xs:complexType> 120 </xs:element> 121 </xs:sequence> 122 <xs:attribute name="ref" type="xs:IDREF" use="required"/> 123 </xs:complexType> 124 </xs:element> 125 </xs:sequence> 126 </xs:complexType> 127 </xs:element> 79 128 </xs:sequence> 80 </xs:complexType> 81 </xs:element> 82 </xs:sequence> 83 </xs:complexType> 84 </xs:element> 85 <xs:element minOccurs="0" name="IsPartOfList"> 86 <xs:complexType> 87 <xs:sequence> 88 <xs:element maxOccurs="unbounded" minOccurs="0" name="IsPartOf" type="xs:anyURI"/> 89 </xs:sequence> 90 </xs:complexType> 91 </xs:element> 92 </xs:sequence> 93 </xs:complexType> 94 </xs:element> 95 <xs:element name="Components"> 96 <xs:complexType> 97 <xs:sequence> 98 <xs:any namespace="##targetNamespace" minOccurs="1" maxOccurs="unbounded" processContents="lax"/> 99 </xs:sequence> 100 </xs:complexType> 101 </xs:element> 102 </xs:sequence> 103 <xs:attribute name="CMDVersion" fixed="1.1" use="required"/> 104 </xs:complexType> 105 </xs:element> 129 </xs:complexType> 130 </xs:element> 131 </xs:sequence> 132 </xs:complexType> 133 </xs:element> 134 <!-- this CMD record can be part of ... --> 135 <xs:element name="IsPartOfList" minOccurs="0" maxOccurs="1"> 136 <xs:complexType> 137 <xs:sequence> 138 <xs:element name="IsPartOf" minOccurs="0" maxOccurs="unbounded" type="xs:anyURI"/> 139 </xs:sequence> 140 </xs:complexType> 141 </xs:element> 142 <xs:element name="Components" minOccurs="1" maxOccurs="1"> 143 <xs:complexType> 144 <xs:sequence> 145 <!-- only one root node is allowed --> 146 <xs:any namespace="##other" minOccurs="1" maxOccurs="1" processContents="strict"/> 147 </xs:sequence> 148 </xs:complexType> 149 </xs:element> 150 </xs:sequence> 151 <xs:attribute name="CMDVersion" fixed="1.2" use="required"/> 152 </xs:complexType> 153 <!-- Resource key and reference constraints --> 154 <xs:key name="ResourceProxy"> 155 <xs:selector 156 xpath="cmd:Resources/cmd:ResourceProxyList/cmd:ResourceProxy"/> 157 <xs:field xpath="@id"/> 158 </xs:key> 159 <xs:keyref name="EnvelopResourceRef" 160 refer="cmd:ResourceProxy"> 161 <xs:selector xpath=".//cmd:*"/> 162 <xs:field xpath="@ref"/> 163 </xs:keyref> 164 <xs:keyref name="PayloadResourceRef" 165 refer="cmd:ResourceProxy"> 166 <xs:selector xpath=".//*"/> 167 <xs:field xpath="@cmd:ref"/> 168 </xs:keyref> 169 </xs:element> 106 170 </xs:schema> -
metadata/trunk/toolkit/xslt/comp2schema.xsl
r5617 r5628 6 6 --> 7 7 8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" 9 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" 10 xmlns:ann="http://www.clarin.eu">11 12 <xsl:variable name="CMDVersion" select="'1. 1'"/>13 8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:ann="http://www.clarin.eu" xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:cue="http://www.clarin.eu/cmdi/cues/display/1.0"> 9 10 <xsl:param name="cmd-envelop" select="'../../xsd/cmd-envelop.xsd'"/> 11 12 <xsl:variable name="CMDVersion" select="'1.2'"/> 13 14 14 <xsl:strip-space elements="*"/> 15 <xsl:include href="comp2schema-header.xsl"/> 16 <xsl:include href="cleanup-xsd.xsl"/> 17 <!-- note: the automatic chaining with clean-xsd.xsl only works with the Saxon XSLT processor, otherwise you'll have to do this manually (or use e.g the Xalan pipeDocument tag) --> 18 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" /> 19 20 <!-- Start includes --> 15 16 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/> 21 17 22 18 <!-- resolve includes --> … … 27 23 </xsl:template> 28 24 29 <xsl:template match="C MD_Component[@filename]" mode="include">30 <!-- some of the outer CMD_Component attributes can overwrite the inner C MD_Component attributes -->25 <xsl:template match="Component[@filename]" mode="include"> 26 <!-- some of the outer CMD_Component attributes can overwrite the inner Component attributes --> 31 27 <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/> 32 <xsl:for-each select="document(@filename)/C MD_ComponentSpec/CMD_Component">28 <xsl:for-each select="document(@filename)/ComponentSpec/Component"> 33 29 <xsl:variable name="inner-attr" select="@*"/> 34 30 <xsl:copy> 35 31 <xsl:apply-templates select="$outer-attr" mode="include"/> 36 <xsl:apply-templates 37 select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]" 38 mode="include"/> 32 <xsl:apply-templates select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]" mode="include"/> 39 33 <xsl:apply-templates select="node()" mode="include"/> 40 34 </xsl:copy> 41 35 </xsl:for-each> 42 36 </xsl:template> 43 44 <!-- Stop includes -->45 37 46 38 <!-- main --> … … 51 43 </xsl:variable> 52 44 <!-- Process the complete tree --> 53 <xsl:variable name="schema"> 54 <xsl:apply-templates select="$tree/*"/> 55 </xsl:variable> 56 <xsl:apply-templates select="$schema" mode="clean" /> 45 <xsl:apply-templates select="$tree/*"/> 57 46 </xsl:template> 58 47 59 48 <!-- generate XSD --> 60 <xsl:template match="/CMD_ComponentSpec"> 61 62 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:cmd="http://www.clarin.eu/cmd/" targetNamespace="http://www.clarin.eu/cmd/" elementFormDefault="qualified"> 63 64 <!-- put the header information from the component specification in the schema as appinfo --> 49 <xsl:template match="/ComponentSpec"> 50 51 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:cmd="http://www.clarin.eu/cmd/" targetNamespace="{Header/ID}" elementFormDefault="qualified"> 52 53 <xsl:namespace name="cmdp" select="Header/ID"/> 54 55 <!-- put the header information from the component specification in the schema as appinfo --> 65 56 <xs:annotation> 66 57 <xs:appinfo xmlns:ann="http://www.clarin.eu"> … … 68 59 </xs:appinfo> 69 60 </xs:annotation> 70 71 <!-- import this for the use of the xml:lang attribute --> 72 <xs:import namespace="http://www.w3.org/XML/1998/namespace" 73 schemaLocation="http://www.w3.org/2001/xml.xsd"/> 61 62 <!-- import xml.xsd for the use of the xml:lang attribute --> 63 <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> 64 65 <!-- import cmd-envelop for the use of the tgeneral CMD attributes --> 66 <xs:import namespace="http://www.clarin.eu/cmd/" schemaLocation="{$cmd-envelop}"/> 74 67 75 68 … … 77 70 <xsl:call-template name="CreateComplexTypes"/> 78 71 79 <!-- then create simple type for the ResourceProxy --> 80 <xsl:call-template name="PrintHeaderType"/> 81 82 83 <xs:element name="CMD"> 84 <xs:complexType> 85 86 <xs:sequence> 87 88 <!-- Produce (fixed) header elements (description and resources)--> 89 <xsl:call-template name="PrintHeader"/> 90 91 <!-- Then generate the components --> 92 <xs:element name="Components"> 93 94 <xs:complexType> 95 <xs:sequence> 96 <!--Start with processing the root component once and then process everything else recursively--> 97 <xsl:apply-templates select="/CMD_ComponentSpec/CMD_Component"/> 98 </xs:sequence> 99 </xs:complexType> 100 </xs:element> 101 102 <!-- Generate the footer --> 103 </xs:sequence> 104 105 <!-- CMD version --> 106 <xs:attribute name="CMDVersion" fixed="{$CMDVersion}" use="required"/> 107 108 </xs:complexType> 109 </xs:element> 72 <!--Start with processing the root component once and then process everything else recursively--> 73 <xsl:apply-templates select="Component"/> 74 110 75 </xs:schema> 111 76 112 77 </xsl:template> 113 78 114 79 <xsl:template match="*" mode="Header"> 115 80 <xsl:element name="ann:{name()}" namespace="http://www.clarin.eu"> 116 81 <xsl:value-of select="text()"/> 117 <xsl:apply-templates select="*" mode="Header" 82 <xsl:apply-templates select="*" mode="Header"/> 118 83 </xsl:element> 119 84 </xsl:template> 120 85 121 86 <xsl:template name="CreateComplexTypes"> 122 <xsl:apply-templates select="CMD_Component" mode="types"/> 123 </xsl:template> 124 125 126 <!-- Start types --> 127 128 <!-- skip all text nodes --> 129 <xsl:template match="text()" mode="types"/> 130 131 <!-- first pass: create the complex types on top of the resulting XSD --> 132 <!-- ignore when this ValueScheme is descendant of an Attribute as we do not allow CV-attributes in a CV-list --> 133 <xsl:template match="ValueScheme[not(../../Attribute)]" mode="types"> 134 135 <!-- create a unique suffix (the path to the element) to ensure the unicity of the types to be created --> 136 <xsl:variable name="uniquePath"> 137 <xsl:call-template name="printComponentId"> 138 <!-- start from the CMD_Element above and go upwards in the tree --> 139 <xsl:with-param name="node" select=".."/> 140 </xsl:call-template> 141 </xsl:variable> 142 143 <!-- first auto-generate a name for the simpletype to be extended --> 144 <xs:simpleType name="simpletype{$uniquePath}"> 145 <xs:restriction base="xs:string"> 146 <xsl:apply-templates select="pattern"/> 147 <xsl:apply-templates select="enumeration"/> 148 </xs:restriction> 149 </xs:simpleType> 150 151 <!-- then auto-derive a complextype for the attributes --> 152 <xs:complexType name="complextype{$uniquePath}"> 153 <xs:simpleContent> 154 <xs:extension base="cmd:simpletype{$uniquePath}"> 155 <!-- now look at the attribute list of the CMD_Element parent of this ValueScheme--> 156 <xsl:apply-templates select="parent::node()/AttributeList/Attribute"/> 157 <!--<xs:attribute name="attributeName" type="xs:anyURI"/>--> 158 </xs:extension> 159 </xs:simpleContent> 160 </xs:complexType> 161 162 </xsl:template> 163 164 <!-- Stop types --> 165 166 <!-- create a unique identifier from the current ValueScheme element --> 167 <xsl:template name="printComponentId"> 87 <xsl:apply-templates select="Component" mode="types"/> 88 </xsl:template> 89 90 <!-- create a unique identifier from the current element --> 91 <xsl:function name="cmd:getComponentId"> 168 92 <xsl:param name="node"/> 93 169 94 <xsl:text>-</xsl:text> 170 95 171 96 <xsl:choose> 172 97 173 98 <!-- deeper recursion needed --> 174 <xsl:when test="$node[ not(@ComponentId)]">175 99 <xsl:when test="$node[empty(@ComponentId)]"> 100 176 101 <xsl:choose> 177 102 <!-- element has name, add it to the type name and recurse upwards in the tree --> 178 <xsl:when test=" name($node) = 'CMD_Element'">179 <xsl:value-of select="$node/ attribute::name"/>103 <xsl:when test="$node/self::Element"> 104 <xsl:value-of select="$node/@name"/> 180 105 </xsl:when> 181 106 <!-- "worst" case: embedded anonymous component without ComponentId: use the xpath --> 182 <xsl:when test=" name($node) = 'CMD_Component'">107 <xsl:when test="$node/self::Component"> 183 108 <xsl:value-of select="count($node/preceding-sibling::*)"/> 184 109 </xsl:when> 185 110 </xsl:choose> 186 111 187 112 <!-- recursive call --> 188 <xsl:call-template name="printComponentId"> 189 <xsl:with-param name="node" select="$node/.."/> 190 </xsl:call-template> 191 113 <xsl:value-of select="cmd:getComponentId($node/..)"/> 114 192 115 </xsl:when> 193 116 194 117 <!-- end of recursion: component has ComponentId --> 195 118 <xsl:otherwise> 196 <xsl:value-of select="replace($node/ attribute::ComponentId, ':', '.')"/>119 <xsl:value-of select="replace($node/@ComponentId, ':', '.')"/> 197 120 </xsl:otherwise> 198 121 199 122 </xsl:choose> 200 201 </xsl:template> 202 203 123 124 </xsl:function> 125 126 <!-- generate types --> 127 128 <!-- skip all text nodes --> 129 <xsl:template match="text()" mode="types"/> 130 131 <!-- first pass: create the complex types on top of the resulting XSD --> 132 <xsl:template match="Element/ValueScheme[exists(Vocabulary/enumeration)]" mode="types"> 133 134 <!-- only handle the ValueScheme if this is the first occurence of the Component --> 135 <xsl:variable name="Component" select="ancestor::Component[exists(@ComponentId)]"/> 136 <xsl:if test="empty($Component/preceding::Component[@ComponentId=$Component/@ComponentId])"> 137 138 <!-- create a unique suffix (the path to the element) to ensure the unicity of the types to be created --> 139 <xsl:variable name="uniquePath" select="cmd:getComponentId(..)"/> 140 141 <!-- first auto-generate a name for the simpletype to be extended --> 142 <xs:simpleType name="simpletype{$uniquePath}"> 143 <xs:restriction base="xs:string"> 144 <xsl:apply-templates select="pattern"/> 145 <xsl:apply-templates select="enumeration"/> 146 </xs:restriction> 147 </xs:simpleType> 148 149 <!-- then auto-derive a complextype for the attributes --> 150 <xs:complexType name="complextype{$uniquePath}"> 151 <xs:simpleContent> 152 <xs:extension base="cmdp:simpletype{$uniquePath}"> 153 <!-- now look at the attribute list of the Element parent of this ValueScheme--> 154 <xsl:apply-templates select="parent::Element/AttributeList/Attribute"/> 155 <!-- an element can refer to an entry in a closed external vocabulary --> 156 <xsl:if test="parent::Element/ValueScheme/Vocabulary/@URI"> 157 <xs:attribute ref="cmd:ValueConceptLink"/> 158 </xsl:if> 159 </xs:extension> 160 </xs:simpleContent> 161 </xs:complexType> 162 </xsl:if> 163 164 </xsl:template> 165 166 <!-- Stop types --> 204 167 205 168 <!-- convert all components --> 206 <xsl:template match="CMD_Component"> 207 <!-- use override values if specified in parent <CMD_Component filename=...> , otherwise use default cardinality for this component --> 208 <xsl:param name="MinOccurs" select="@CardinalityMin"/> 209 <xsl:param name="MaxOccurs" select="@CardinalityMax"/> 169 <xsl:template match="Component"> 210 170 211 171 <xs:element name="{@name}"> 212 172 213 <xsl:if test="$MinOccurs"> 214 <xsl:attribute name="minOccurs"> 215 <xsl:value-of select="$MinOccurs"/> 216 </xsl:attribute> 217 </xsl:if> 218 <xsl:if test="$MaxOccurs"> 219 <xsl:attribute name="maxOccurs"> 220 <xsl:value-of select="$MaxOccurs"/> 221 </xsl:attribute> 222 </xsl:if> 223 <!-- Add a dcr:datcat if a ConceptLink attribute is found --> 224 <xsl:apply-templates select="./@ConceptLink"/> 225 173 <xsl:call-template name="annotations"/> 174 175 <xsl:apply-templates select="@ConceptLink"/> 176 <xsl:apply-templates select="@CardinalityMin"/> 177 <xsl:apply-templates select="@CardinalityMax"/> 178 179 <xs:annotation> 180 <xsl:apply-templates select="Documentation"/> 181 </xs:annotation> 182 226 183 <xs:complexType> 184 227 185 <xs:sequence> 228 186 <!-- process all elements at this level --> 229 <xsl:apply-templates select="./ CMD_Element"/>187 <xsl:apply-templates select="./Element"/> 230 188 <!-- process all components at one level deeper (recursive call) --> 231 <xsl:apply-templates select="./C MD_Component"/>189 <xsl:apply-templates select="./Component"/> 232 190 </xs:sequence> 233 <!-- DISABLED (Arbil needs to handle it first) allow @xml:base as a residue of XInclude processing -X-> 191 192 <!-- allow @xml:base as a residue of XInclude processing --> 234 193 <xs:attribute ref="xml:base"/> 235 --> 236 <!-- @ref to the resource proxy (TODO: put this in the CMD namespace, i.e., @cmd:ref --> 237 <xs:attribute name="ref" type="xs:IDREFS"/> 194 195 <!-- @ref to the resource proxy --> 196 <xs:attribute ref="cmd:ref"/> 197 198 <!-- allow @ComponentId referring to this Component --> 199 <xsl:if test="exists(@ComponentId)"> 200 <xs:attribute ref="cmd:ComponentId" fixed="{@ComponentId}"/> 201 </xsl:if> 202 238 203 <xsl:apply-templates select="./AttributeList/Attribute"/> 239 <xsl:if test="@ComponentId"> 240 <xs:attribute name="ComponentId" type="xs:anyURI" fixed="{@ComponentId}"/> 241 </xsl:if> 204 242 205 </xs:complexType> 243 206 … … 246 209 </xsl:template> 247 210 248 <!-- Process all CMD_Elements, its attributes and children -->249 250 <!-- Highest complexity: both attributes and a valuescheme, link to the type we created during the preprocessing of the ValueScheme -->251 <xsl:template match=" CMD_Element[./AttributeList][./ValueScheme]" priority="3">211 <!-- Process all Elements, its attributes and children --> 212 213 <!-- Highest complexity: both attributes and a ValueScheme, link to the type we created during the preprocessing of the ValueScheme --> 214 <xsl:template match="Element[./AttributeList][./ValueScheme[exists(enumeration)]]" priority="3"> 252 215 <xs:element name="{@name}"> 253 254 <!-- process all Documentation and DisplayPriority attributes -->255 <xsl:call-template name="annotations"/>256 216 257 217 <xsl:apply-templates select="@ConceptLink"/> … … 260 220 <xsl:apply-templates select="ValueScheme"/> 261 221 222 <!-- process all autovalue and cues attributes --> 223 <xsl:call-template name="annotations"/> 224 225 <xs:annotation> 226 <xsl:apply-templates select="Documentation"/> 227 </xs:annotation> 228 262 229 </xs:element> 263 230 </xsl:template> 264 231 265 232 <!-- Medium complexity: attributes (or Multilingual field) but no valuescheme, can be arranged inline --> 266 <xsl:template match=" CMD_Element[./AttributeList or ./@Multilingual]" priority="2">233 <xsl:template match="Element[./AttributeList or ./@Multilingual]" priority="2"> 267 234 <xs:element name="{@name}"> 268 235 … … 272 239 <xsl:apply-templates select="@CardinalityMax"/> 273 240 274 <!-- process all Documentation and DisplayPriorityattributes -->241 <!-- process all autovalue and cues attributes --> 275 242 <xsl:call-template name="annotations"/> 276 243 277 <!-- <xsl:apply-templates select= "and(not(@type) and @*)"/> --> 244 <xs:annotation> 245 <xsl:apply-templates select="Documentation"/> 246 </xs:annotation> 247 278 248 <xs:complexType> 279 249 <xs:simpleContent> 280 250 <xs:extension base="{concat('xs:',@ValueScheme)}"> 281 251 <xsl:apply-templates select="./AttributeList/Attribute"/> 282 <!-- temporarily disabled -->283 252 <xsl:if test="./@Multilingual='true'"> 284 <xs:attribute ref="xml:lang" /> 253 <xs:attribute ref="xml:lang"/> 254 </xsl:if> 255 <!-- an element can refer to an entry in an open external vocabulary --> 256 <xsl:if test="exists(./ValueScheme/@URI)"> 257 <xs:attribute ref="cmd:ValueConceptLink"/> 285 258 </xsl:if> 286 259 </xs:extension> … … 290 263 </xsl:template> 291 264 292 293 265 <!-- Simple case: no attributes and no value scheme, 1-to-1 transform to an xs:element, just rename element and attributes --> 294 <xsl:template match=" CMD_Element" priority="1">266 <xsl:template match="Element" priority="1"> 295 267 <xsl:element name="xs:element"> 296 <xsl:apply-templates 297 select="@*[name() != 'Documentation' and name() != 'DisplayPriority'] | node()"/> 298 <!-- process all Documentation and DisplayPriority attributes --> 268 269 <xsl:apply-templates select="@name"/> 270 <xsl:apply-templates select="@Multilingual"/> 271 <xsl:apply-templates select="@ConceptLink"/> 272 <xsl:apply-templates select="@CardinalityMin"/> 273 <xsl:apply-templates select="@CardinalityMax"/> 274 <xsl:apply-templates select="@ValueScheme"/> 275 276 <!-- process all autovalue and cues attributes --> 299 277 <xsl:call-template name="annotations"/> 278 <xs:annotation> 279 <xsl:apply-templates select="Documentation"/> 280 </xs:annotation> 281 300 282 </xsl:element> 301 283 </xsl:template> 302 284 303 <!-- end of CMD_Element templates -->304 305 <!-- second pass, now link to the earlier created complextype definition -->285 <!-- end of Element templates --> 286 287 <!-- second pass, now link to the earlier created ComplexType definition --> 306 288 <xsl:template match="ValueScheme"> 307 <xsl:variable name="uniquePath"> 308 <xsl:call-template name="printComponentId"> 309 <!-- start from the CMD_Element above and go upwards in the tree --> 310 <xsl:with-param name="node" select=".."/> 311 </xsl:call-template> 312 </xsl:variable> 313 289 <xsl:variable name="uniquePath" select="cmd:getComponentId(..)"/> 314 290 <xsl:attribute name="type"> 315 <xsl:text>cmd :complextype</xsl:text>291 <xsl:text>cmdp:complextype</xsl:text> 316 292 <xsl:value-of select="$uniquePath"/> 317 293 </xsl:attribute> … … 320 296 <!-- Convert the AttributeList into real XSD attributes --> 321 297 <xsl:template match="AttributeList/Attribute"> 322 <xs:attribute name="{ ./Name}">298 <xs:attribute name="{@name}"> 323 299 324 300 <!-- Add a dcr:datcat if a ConceptLink element is found --> 325 <xsl:if test="normalize-space( ./ConceptLink)!=''">301 <xsl:if test="normalize-space(@ConceptLink)!=''"> 326 302 <xsl:attribute name="dcr:datcat"> 327 <xsl:value-of select=" ./ConceptLink"/>303 <xsl:value-of select="@ConceptLink"/> 328 304 </xsl:attribute> 329 305 </xsl:if> 330 306 331 307 <!-- add some extra stuff if we have a CV attribute --> 332 308 <xsl:choose> 333 309 334 310 <!-- complex situation: CV or regex --> 335 <xsl:when test="./ValueScheme"> 311 <xsl:when test="exists(./ValueScheme/(Vocabulary/enumeration|pattern))"> 312 313 <xs:annotation> 314 <xsl:apply-templates select="Documentation"/> 315 </xs:annotation> 316 336 317 <xs:simpleType> 337 318 <xs:restriction base="xs:string"> … … 345 326 <xsl:otherwise> 346 327 <xsl:attribute name="type"> 347 <xsl:value-of select="concat('xs:', ./Type)"/>328 <xsl:value-of select="concat('xs:',@ValueScheme)"/> 348 329 </xsl:attribute> 330 331 <xs:annotation> 332 <xsl:apply-templates select="Documentation"/> 333 </xs:annotation> 334 349 335 </xsl:otherwise> 350 336 … … 353 339 </xs:attribute> 354 340 </xsl:template> 355 356 341 357 342 <!-- Convert patterns --> 358 343 <xsl:template match="pattern"> … … 361 346 362 347 <!-- Convert enumerations --> 348 <xsl:template match="Vocabulary"> 349 <xsl:apply-templates select="@*|node()"/> 350 </xsl:template> 351 363 352 <xsl:template match="enumeration"> 364 365 353 <xsl:for-each select="item"> 366 354 <xs:enumeration value="{node()}"> 367 <!-- Add a dcr:datcat if a ConceptLink attribute is found -->368 355 <xsl:apply-templates select="./@ConceptLink"/> 369 356 <xsl:apply-templates select="./@AppInfo"/> … … 372 359 </xsl:template> 373 360 374 375 361 <!-- default action: keep the attributes like they are --> 376 362 <xsl:template match="@*|node()"> … … 378 364 </xsl:template> 379 365 380 381 366 <!-- except for those attributes we want to be renamed --> 382 367 <xsl:template match="@CardinalityMin"> … … 391 376 </xsl:attribute> 392 377 </xsl:template> 393 378 379 <!-- the root component can't have cardinality constraints --> 380 <xsl:template match="ComponentSpec/Component/@CardinalityMin" priority="1"/> 381 382 <xsl:template match="ComponentSpec/Component/@CardinalityMax"/> 383 394 384 <!-- start multilinguality part --> 395 385 396 <!-- if the multilingual attribute is there and the field has the type string, allow mult uple occurrences -->386 <!-- if the multilingual attribute is there and the field has the type string, allow multiple occurrences --> 397 387 <xsl:template match="@Multilingual[../@ValueScheme='string'][. = 'true'] "> 398 <!-- temporarily disabled until Arbil can deal with the <xs:import> to cope with xml:lang -->399 388 <xsl:attribute name="maxOccurs"> 400 389 <xsl:value-of>unbounded</xsl:value-of> … … 412 401 <!-- end multilinguality part --> 413 402 403 <!-- Add a @dcr:datcat if a ConceptLink attribute is found --> 414 404 <xsl:template match="@ConceptLink"> 415 405 <xsl:attribute name="dcr:datcat"> … … 419 409 420 410 <xsl:template match="@AppInfo"> 421 <xsl:attribute name="ann:label"><xsl:value-of select="."/></xsl:attribute> 411 <xsl:attribute name="ann:label"> 412 <xsl:value-of select="."/> 413 </xsl:attribute> 422 414 </xsl:template> 423 415 … … 427 419 </xsl:attribute> 428 420 </xsl:template> 429 430 <xsl:template match="@Documentation"> 431 <xsl:attribute name="ann:documentation"> 432 <xsl:value-of select="."/> 433 </xsl:attribute> 434 <!--<xs:documentation><xsl:value-of select="."/></xs:documentation>--> 435 </xsl:template> 436 437 <xsl:template match="@DisplayPriority"> 421 422 <xsl:template match="Vocabulary/@URI"> 423 <xsl:attribute name="ann:Vocabulary"> 424 <xsl:value-of select="."/> 425 </xsl:attribute> 426 </xsl:template> 427 428 <xsl:template match="@ValueProperty|@ValueLanguage"> 429 <xsl:attribute name="ann:{local-name()}"> 430 <xsl:value-of select="."/> 431 </xsl:attribute> 432 </xsl:template> 433 434 <xsl:template match="Documentation"> 435 <xs:documentation> 436 <xsl:copy-of select="@xml:lang"/> 437 <xsl:value-of select="."/> 438 </xs:documentation> 439 </xsl:template> 440 441 <xsl:template match="@AutoValue"> 442 <xsl:attribute name="ann:AutoValue"> 443 <xsl:value-of select="."/> 444 </xsl:attribute> 445 </xsl:template> 446 447 <xsl:template match="@cue:DisplayPriority" priority="1"> 438 448 <xsl:attribute name="ann:displaypriority"> 439 449 <xsl:value-of select="."/> 440 450 </xsl:attribute> 441 <!--<xs:appinfo><DisplayPriority><xsl:value-of select="."/></DisplayPriority></xs:appinfo>--> 442 </xsl:template> 443 451 </xsl:template> 452 453 <xsl:template match="@cue:*"> 454 <xsl:attribute name="ann:{local-name()}"> 455 <xsl:value-of select="."/> 456 </xsl:attribute> 457 </xsl:template> 458 444 459 <xsl:template name="annotations"> 445 <xsl:if test="@Documentation or @DisplayPriority"> 446 <!--<xs:annotation>--> 447 <xsl:apply-templates select="@Documentation"/> 448 <xsl:apply-templates select="@DisplayPriority"/> 449 <!--</xs:annotation>--> 450 </xsl:if> 451 </xsl:template> 452 460 <xsl:apply-templates select="@AutoValue"/> 461 <xsl:apply-templates select="@cue:*"/> 462 </xsl:template> 463 453 464 </xsl:stylesheet>
Note: See TracChangeset
for help on using the changeset viewer.