Changeset 5628 for metadata


Ignore:
Timestamp:
09/15/14 10:21:49 (10 years ago)
Author:
Menzo Windhouwer
Message:

Refactoring the toolkit to support CMDI 1.2

Location:
metadata/trunk/toolkit
Files:
11 deleted
3 copied
2 moved

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/xsd/cmd-component.xsd

    r5617 r5628  
    1111
    1212    <!-- 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>
    1431        <xs:complexType>
    1532            <xs:sequence>
     
    2037                            <xs:element name="Name" type="xs:string" minOccurs="0"/>
    2138                            <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"/>
    2251                        </xs:sequence>
    2352                    </xs:complexType>
    2453                </xs:element>
    25                 <xs:element name="CMD_Component" type="CMD_Component_type">
     54                <xs:element name="Component" type="Component_type">
    2655                    <xs:annotation>
    2756                        <xs:documentation>At the root level there should always be a
     
    4069                <sch:pattern id="c_sibs">
    4170                    <sch:title>Check siblings</sch:title>
    42                     <sch:rule context="CMD_Component|CMD_Element">
     71                    <sch:rule context="Component|Element">
    4372                        <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>
    4473                    </sch:rule>
     
    4675                <sch:pattern id="c_csibs">
    4776                    <sch:title>Check component siblings</sch:title>
    48                     <sch:rule context="CMD_Component">
    49                         <sch:assert test="empty(preceding-sibling::CMD_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 check two 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 -->
    5382                <sch:pattern id="c_nest">
    5483                    <sch:title>Check nesting</sch:title>
    55                     <sch:rule context="CMD_Component[exists(CMD_Component|CMD_Element)]" role="warning">
    56                         <sch:assert test="empty((CMD_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>
    6089        </xs:annotation>
    6190        <xs:sequence>
     91            <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
    6292            <!-- from small (attribute) to big (component) -->
    6393            <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"
    6595                maxOccurs="unbounded"> </xs:element>
    66             <xs:element name="CMD_Component" type="CMD_Component_type" minOccurs="0"
     96            <xs:element name="Component" type="Component_type" minOccurs="0"
    6797                maxOccurs="unbounded"/>
    6898        </xs:sequence>
     
    70100
    71101    <!-- 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>
    73133        <xs:sequence>
     134            <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
    74135            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1">
    75136                <xs:annotation>
     
    85146                </xs:annotation>
    86147            </xs:element>
     148            <xs:element name="AutoValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
    87149        </xs:sequence>
    88         <xs:attributeGroup ref="clarin_element_attributes"/>
    89     </xs:complexType>
    90 
     150        <xs:attributeGroup ref="element_attributes"/>
     151    </xs:complexType>
    91152
    92153    <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>
    93164        <xs:choice>
    94165            <xs:element name="pattern" type="xs:string" maxOccurs="1">
     
    98169                </xs:annotation>
    99170            </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>
    104174                </xs:annotation>
    105175            </xs:element>
     
    107177    </xs:complexType>
    108178
     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>
    109193
    110194    <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>
    111205        <xs:sequence>
    112206            <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded">
     
    116210                            <sch:title>Check reserved attribute names</sch:title>
    117211                            <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>
    119213                            </sch:rule>
    120214                        </sch:pattern>
     
    122216                            <sch:title>Check attribute siblings</sch:title>
    123217                            <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>
    125219                            </sch:rule>
    126220                        </sch:pattern>
     
    128222                            <sch:title>Check attribute nesting</sch:title>
    129223                            <sch:rule context="Attribute" role="warning">
    130                                 <sch:assert test="empty((ancestor::CMD_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>
    131225                            </sch:rule>
    132226                        </sch:pattern>
    133                     </xs:appinfo>           
     227                    </xs:appinfo>
    134228                </xs:annotation>
    135229                <xs:complexType>
    136230                    <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">
    138233                            <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>
    140237                            </xs:annotation>
    141238                        </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"/>
    162240                    </xs:sequence>
     241                    <xs:attributeGroup ref="attribute_attributes"/>
    163242                </xs:complexType>
    164243            </xs:element>
     
    166245    </xs:complexType>
    167246
    168     <xs:complexType name="CMD_Component_type">
     247    <xs:complexType name="Component_type">
    169248        <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">
    176253        <xs:attribute name="name" type="xs:Name" use="required">
    177254            <xs:annotation>
    178                 <xs:documentation>The name of the element.</xs:documentation>
     255                <xs:documentation>The name of the attribute.</xs:documentation>
    179256            </xs:annotation>
    180257        </xs:attribute>
     
    187264        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
    188265            <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>
    189292                <xs:documentation>Used to specify that an element has a simple XML type (string,
    190293                    integer, etc)</xs:documentation>
     
    199302            <xs:annotation>
    200303                <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 give
    206                     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 the
    212                     label for a metadata file (eg in Arbil)</xs:documentation>
    213304            </xs:annotation>
    214305        </xs:attribute>
     
    221312            </xs:annotation>
    222313        </xs:attribute>
     314        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
    223315    </xs:attributeGroup>
    224316
    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">
    227318        <xs:attribute name="name" type="xs:Name"/>
    228319        <xs:attribute name="ComponentId" type="xs:anyURI">
     
    238329            </xs:annotation>
    239330        </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 backward
    243                     compatibility with the XML-cmdi-toolkit.</xs:documentation>
    244             </xs:annotation>
    245         </xs:attribute>
    246 
    247         <!-- (components cannot have a ValueScheme attribute) -->
    248 
    249331        <xs:attribute name="CardinalityMin" type="cardinality_type"/>
    250332        <xs:attribute name="CardinalityMax" type="cardinality_type"/>
    251333        <xs:attribute ref="xml:base"/>
     334        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
    252335    </xs:attributeGroup>
    253336
     
    381464                    </xs:annotation>
    382465                </xs:attribute>
     466                <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
    383467            </xs:extension>
    384468        </xs:simpleContent>
  • metadata/trunk/toolkit/xsd/cmd-envelop.xsd

    r5617 r5628  
    11<?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>
    2459                                    <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>
    4277                                    </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>
    5482                                    <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>
    5690                                    </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>
    6796                                    <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>
    79128                                    </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>
    106170</xs:schema>
  • metadata/trunk/toolkit/xslt/comp2schema.xsl

    r5617 r5628  
    66-->
    77
    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   
    1414    <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"/>
    2117
    2218    <!-- resolve includes -->
     
    2723    </xsl:template>
    2824
    29     <xsl:template match="CMD_Component[@filename]" mode="include">
    30         <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes -->
     25    <xsl:template match="Component[@filename]" mode="include">
     26        <!-- some of the outer CMD_Component attributes can overwrite the inner Component attributes -->
    3127        <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/>
    32         <xsl:for-each select="document(@filename)/CMD_ComponentSpec/CMD_Component">
     28        <xsl:for-each select="document(@filename)/ComponentSpec/Component">
    3329            <xsl:variable name="inner-attr" select="@*"/>
    3430            <xsl:copy>
    3531                <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"/>
    3933                <xsl:apply-templates select="node()" mode="include"/>
    4034            </xsl:copy>
    4135        </xsl:for-each>
    4236    </xsl:template>
    43 
    44     <!-- Stop includes -->
    4537
    4638    <!-- main -->
     
    5143        </xsl:variable>
    5244        <!-- 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/*"/>
    5746    </xsl:template>
    5847
    5948    <!-- 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 -->
    6556            <xs:annotation>
    6657                <xs:appinfo xmlns:ann="http://www.clarin.eu">
     
    6859                </xs:appinfo>
    6960            </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}"/>
    7467
    7568
     
    7770            <xsl:call-template name="CreateComplexTypes"/>
    7871
    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
    11075        </xs:schema>
    11176
    11277    </xsl:template>
    113    
     78
    11479    <xsl:template match="*" mode="Header">
    11580        <xsl:element name="ann:{name()}" namespace="http://www.clarin.eu">
    11681            <xsl:value-of select="text()"/>
    117             <xsl:apply-templates select="*" mode="Header" />
     82            <xsl:apply-templates select="*" mode="Header"/>
    11883        </xsl:element>
    11984    </xsl:template>
    12085
    12186    <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">
    16892        <xsl:param name="node"/>
     93       
    16994        <xsl:text>-</xsl:text>
    170 
     95       
    17196        <xsl:choose>
    172 
     97           
    17398            <!-- deeper recursion needed -->
    174             <xsl:when test="$node[not(@ComponentId)]">
    175 
     99            <xsl:when test="$node[empty(@ComponentId)]">
     100               
    176101                <xsl:choose>
    177102                    <!-- 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"/>
    180105                    </xsl:when>
    181106                    <!-- "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">
    183108                        <xsl:value-of select="count($node/preceding-sibling::*)"/>
    184109                    </xsl:when>
    185110                </xsl:choose>
    186 
     111               
    187112                <!-- 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               
    192115            </xsl:when>
    193 
     116           
    194117            <!-- end of recursion: component has ComponentId -->
    195118            <xsl:otherwise>
    196                 <xsl:value-of select="replace($node/attribute::ComponentId, ':', '.')"/>
     119                <xsl:value-of select="replace($node/@ComponentId, ':', '.')"/>
    197120            </xsl:otherwise>
    198 
     121           
    199122        </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 -->
    204167
    205168    <!-- 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">
    210170
    211171        <xs:element name="{@name}">
    212172           
    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           
    226183            <xs:complexType>
     184
    227185                <xs:sequence>
    228186                    <!-- process all elements at this level -->
    229                     <xsl:apply-templates select="./CMD_Element"/>
     187                    <xsl:apply-templates select="./Element"/>
    230188                    <!-- process all components at one level deeper (recursive call) -->
    231                     <xsl:apply-templates select="./CMD_Component"/>
     189                    <xsl:apply-templates select="./Component"/>
    232190                </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 -->
    234193                <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
    238203                <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
    242205            </xs:complexType>
    243206
     
    246209    </xsl:template>
    247210
    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">
    252215        <xs:element name="{@name}">
    253 
    254             <!-- process all Documentation and DisplayPriority attributes -->
    255             <xsl:call-template name="annotations"/>
    256216
    257217            <xsl:apply-templates select="@ConceptLink"/>
     
    260220            <xsl:apply-templates select="ValueScheme"/>
    261221
     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           
    262229        </xs:element>
    263230    </xsl:template>
    264231
    265232    <!-- 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">
    267234        <xs:element name="{@name}">
    268235
     
    272239            <xsl:apply-templates select="@CardinalityMax"/>
    273240
    274             <!-- process all Documentation and DisplayPriority attributes -->
     241            <!-- process all autovalue and cues attributes -->
    275242            <xsl:call-template name="annotations"/>
    276243
    277             <!-- <xsl:apply-templates select= "and(not(@type) and @*)"/> -->
     244            <xs:annotation>
     245                <xsl:apply-templates select="Documentation"/>
     246            </xs:annotation>
     247           
    278248            <xs:complexType>
    279249                <xs:simpleContent>
    280250                    <xs:extension base="{concat('xs:',@ValueScheme)}">
    281251                        <xsl:apply-templates select="./AttributeList/Attribute"/>
    282                         <!-- temporarily disabled -->
    283252                        <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"/>
    285258                        </xsl:if>
    286259                    </xs:extension>
     
    290263    </xsl:template>
    291264
    292 
    293265    <!-- 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">
    295267        <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 -->
    299277            <xsl:call-template name="annotations"/>
     278            <xs:annotation>
     279                <xsl:apply-templates select="Documentation"/>
     280            </xs:annotation>
     281           
    300282        </xsl:element>
    301283    </xsl:template>
    302284
    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 -->
    306288    <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(..)"/>
    314290        <xsl:attribute name="type">
    315             <xsl:text>cmd:complextype</xsl:text>
     291            <xsl:text>cmdp:complextype</xsl:text>
    316292            <xsl:value-of select="$uniquePath"/>
    317293        </xsl:attribute>
     
    320296    <!-- Convert the AttributeList into real XSD attributes -->
    321297    <xsl:template match="AttributeList/Attribute">
    322         <xs:attribute name="{./Name}">
     298        <xs:attribute name="{@name}">
    323299
    324300            <!-- Add a dcr:datcat if a ConceptLink element is found -->
    325             <xsl:if test="normalize-space(./ConceptLink)!=''">
     301            <xsl:if test="normalize-space(@ConceptLink)!=''">
    326302                <xsl:attribute name="dcr:datcat">
    327                     <xsl:value-of select="./ConceptLink" />
     303                    <xsl:value-of select="@ConceptLink"/>
    328304                </xsl:attribute>
    329305            </xsl:if>
    330            
     306
    331307            <!-- add some extra stuff if we have a CV attribute -->
    332308            <xsl:choose>
    333309
    334310                <!-- 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
    336317                    <xs:simpleType>
    337318                        <xs:restriction base="xs:string">
     
    345326                <xsl:otherwise>
    346327                    <xsl:attribute name="type">
    347                         <xsl:value-of select="concat('xs:',./Type)"/>
     328                        <xsl:value-of select="concat('xs:',@ValueScheme)"/>
    348329                    </xsl:attribute>
     330                   
     331                    <xs:annotation>
     332                        <xsl:apply-templates select="Documentation"/>
     333                    </xs:annotation>
     334                   
    349335                </xsl:otherwise>
    350336
     
    353339        </xs:attribute>
    354340    </xsl:template>
    355    
    356    
     341
    357342    <!-- Convert patterns -->
    358343    <xsl:template match="pattern">
     
    361346
    362347    <!-- Convert enumerations -->
     348    <xsl:template match="Vocabulary">
     349        <xsl:apply-templates select="@*|node()"/>
     350    </xsl:template>
     351   
    363352    <xsl:template match="enumeration">
    364 
    365353        <xsl:for-each select="item">
    366354            <xs:enumeration value="{node()}">
    367                 <!-- Add a dcr:datcat if a ConceptLink attribute is found -->
    368355                <xsl:apply-templates select="./@ConceptLink"/>
    369356                <xsl:apply-templates select="./@AppInfo"/>
     
    372359    </xsl:template>
    373360
    374 
    375361    <!--  default action: keep the attributes like they are -->
    376362    <xsl:template match="@*|node()">
     
    378364    </xsl:template>
    379365
    380 
    381366    <!-- except for those attributes we want to be renamed -->
    382367    <xsl:template match="@CardinalityMin">
     
    391376        </xsl:attribute>
    392377    </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   
    394384    <!-- start multilinguality part -->
    395385
    396     <!-- if the multilingual attribute is there and the field has the type string, allow multuple occurrences -->
     386    <!-- if the multilingual attribute is there and the field has the type string, allow multiple occurrences -->
    397387    <xsl:template match="@Multilingual[../@ValueScheme='string'][. = 'true'] ">
    398         <!-- temporarily disabled until Arbil can deal with the <xs:import> to cope with xml:lang -->
    399388        <xsl:attribute name="maxOccurs">
    400389            <xsl:value-of>unbounded</xsl:value-of>
     
    412401    <!-- end multilinguality part -->
    413402
     403    <!-- Add a @dcr:datcat if a ConceptLink attribute is found -->
    414404    <xsl:template match="@ConceptLink">
    415405        <xsl:attribute name="dcr:datcat">
     
    419409
    420410    <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>
    422414    </xsl:template>
    423415
     
    427419        </xsl:attribute>
    428420    </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">
    438448        <xsl:attribute name="ann:displaypriority">
    439449            <xsl:value-of select="."/>
    440450        </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   
    444459    <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
    453464</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.