Changeset 6683


Ignore:
Timestamp:
10/17/15 07:12:51 (9 years ago)
Author:
Menzo Windhouwer
Message:

M toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl

  • try heuristics to see an XML element containing a @ref is a CMD element or component, otherwise resolve the path in to the XML element in the CMD profile specification

A toolkit/src/test/resources/toolkit/TEI/profiles/clarin.eu:cr1:p_1380106710826.xml

  • added for the test

M toolkit/src/main/resources/toolkit/xsd/cmd-envelop.xsd

  • styling
Location:
metadata/trunk/toolkit/src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl

    r6262 r6683  
    1717    <xsl:variable name="cr-profiles" select="concat($cr-uri,'/profiles')"/>
    1818    <xsl:variable name="cr-extension-xsd" select="'-1_2.xsd'"/>
    19 
     19    <xsl:variable name="cr-extension-xml" select="'.xml'"/>
     20   
    2021    <!-- identity copy -->
    2122    <xsl:template match="@*|node()">
     
    5758    <xsl:variable name="cmd-profile-uri" select="concat($cmd-profiles,'/',$profile)"/>
    5859    <xsl:variable name="cr-profile-xsd" select="concat($cr-profiles,'/',$profile,$cr-extension-xsd)"/>
     60    <xsl:variable name="cr-profile-xml" select="concat($cr-profiles,'/',$profile,$cr-extension-xml)"/>
    5961   
    6062    <!-- CMD version becomes 1.2 -->
     
    146148   
    147149    <!-- move CMD attributes to the CMD namespace -->
    148     <!-- TODO: @ref is allowed on elements, how to know if this is a element or a component with no children? -->
    149     <!--<xsl:template match="cmd0:Components//*[exists(*)]/@ref">-->
    150150    <xsl:template match="cmd0:Components//@ref">
    151         <xsl:attribute name="cmd:ref" select="."/>
     151        <xsl:choose>
     152            <xsl:when test="exists(parent::*/text()[normalize-space()!=''])">
     153                <!-- this is an element keep the @ref -->
     154                <xsl:copy/>
     155            </xsl:when>
     156            <xsl:when test="exists(../parent::*/node()) or exists(../parent::*/@ComponentId)">
     157                <!-- the parent is a component add the namespace to @ref -->
     158                <xsl:attribute name="cmd:ref" select="."/>
     159            </xsl:when>
     160            <xsl:otherwise>
     161                <!-- don't know if the parent is a component without children, or an element without value
     162                     have a look at the profile -->
     163                <xsl:variable name="prof" select="doc(resolve-uri($cr-profile-xml,base-uri()))"/>
     164                <xsl:variable name="path" select="ancestor::*[. >> /cmd0:CMD/cmd0:Components]"/>
     165                <xsl:variable name="attr" select="$prof//Attribute[Name='ref'][string-join(ancestor::*[local-name()=('CMD_Component','CMD_Element')]/@name,'/')=string-join($path/local-name(),'/')]"/>
     166                <xsl:choose>
     167                    <xsl:when test="exists($attr/parent::AttributeList/parent::CMD_Component)">
     168                        <!-- the parent is a component add the namespace to @ref -->
     169                        <xsl:message>!MENZO: the parent is a component add the namespace to @ref</xsl:message>
     170                        <xsl:attribute name="cmd:ref" select="."/>
     171                    </xsl:when>
     172                    <xsl:otherwise>
     173                        <!-- this is an element keep the @ref -->
     174                        <xsl:message>!MENZO: the parent is an element keep the @ref</xsl:message>
     175                        <xsl:copy/>
     176                    </xsl:otherwise>
     177                </xsl:choose>
     178            </xsl:otherwise>
     179        </xsl:choose>
    152180    </xsl:template>
    153181   
  • metadata/trunk/toolkit/src/main/resources/toolkit/xsd/cmd-envelop.xsd

    r6255 r6683  
    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/ns/dcr"
    3     xmlns:cmd="http://www.clarin.eu/cmd/1" targetNamespace="http://www.clarin.eu/cmd/1"
    4     elementFormDefault="qualified" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
    5     vc:minVersion="1.0" vc:maxVersion="1.1">
     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/1" targetNamespace="http://www.clarin.eu/cmd/1" elementFormDefault="qualified" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.0" vc:maxVersion="1.1">
    63    <!-- globally declare attributes, so they have to be qualified -->
    74    <xs:attribute name="ref" type="xs:IDREF"/>
     
    1310            <xs:enumeration value="Metadata">
    1411                <xs:annotation>
    15                     <xs:documentation>The ResourceProxy refers to another component metadata
    16                         instance (e.g. for grouping metadata descriptions into
    17                         collections)</xs:documentation>
     12                    <xs:documentation>The ResourceProxy refers to another component metadata instance (e.g. for grouping metadata descriptions into collections)</xs:documentation>
    1813                </xs:annotation>
    1914            </xs:enumeration>
    2015            <xs:enumeration value="Resource">
    2116                <xs:annotation>
    22                     <xs:documentation>The ResourceProxy refers to a file that is not a metadata
    23                         instance (e.g. a text document)</xs:documentation>
     17                    <xs:documentation>The ResourceProxy refers to a file that is not a metadata instance (e.g. a text document)</xs:documentation>
    2418                </xs:annotation>
    2519            </xs:enumeration>
    2620            <xs:enumeration value="SearchService">
    2721                <xs:annotation>
    28                     <xs:documentation>The ResourceProxy refers to a (SRU/CQL) web service that can
    29                         be used to query the resource described in this file</xs:documentation>
     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>
    3023                </xs:annotation>
    3124            </xs:enumeration>
    3225            <xs:enumeration value="SearchPage">
    3326                <xs:annotation>
    34                     <xs:documentation>The ResourceProxy refers to a web page that can be used to
    35                         query the resource described in this file</xs:documentation>
     27                    <xs:documentation>The ResourceProxy refers to a web page that can be used to query the resource described in this file</xs:documentation>
    3628                </xs:annotation>
    3729            </xs:enumeration>
    3830            <xs:enumeration value="LandingPage">
    3931                <xs:annotation>
    40                     <xs:documentation>The ResourceProxy refers to a web page that contains the
    41                         "original context" of the resource described in this file (e.g. repository
    42                         web page displaying the metadata).</xs:documentation>
     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>
    4333                </xs:annotation>
    4434            </xs:enumeration>
     
    5747                                    <xs:simpleContent>
    5848                                        <xs:extension base="xs:string">
    59                                             <xs:anyAttribute namespace="##other"
    60                                                 processContents="lax"/>
     49                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
    6150                                        </xs:extension>
    6251                                    </xs:simpleContent>
     
    6756                                    <xs:simpleContent>
    6857                                        <xs:extension base="xs:date">
    69                                             <xs:anyAttribute namespace="##other"
    70                                                 processContents="lax"/>
     58                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
    7159                                        </xs:extension>
    7260                                    </xs:simpleContent>
     
    7765                                    <xs:simpleContent>
    7866                                        <xs:extension base="xs:anyURI">
    79                                             <xs:anyAttribute namespace="##other"
    80                                                 processContents="lax"/>
     67                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
    8168                                        </xs:extension>
    8269                                    </xs:simpleContent>
     
    8774                                    <xs:simpleContent>
    8875                                        <xs:extension base="xs:anyURI">
    89                                             <xs:anyAttribute namespace="##other"
    90                                                 processContents="lax"/>
     76                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
    9177                                        </xs:extension>
    9278                                    </xs:simpleContent>
     
    9783                                    <xs:simpleContent>
    9884                                        <xs:extension base="xs:string">
    99                                             <xs:anyAttribute namespace="##other"
    100                                                 processContents="lax"/>
     85                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
    10186                                        </xs:extension>
    10287                                    </xs:simpleContent>
     
    11398                                <xs:complexType>
    11499                                    <xs:sequence>
    115                                         <xs:element name="ResourceProxy" minOccurs="0"
    116                                             maxOccurs="unbounded">
     100                                        <xs:element name="ResourceProxy" minOccurs="0" maxOccurs="unbounded">
    117101                                            <xs:complexType>
    118102                                                <xs:sequence>
    119                                                   <xs:element name="ResourceType" minOccurs="1"
    120                                                   maxOccurs="1">
    121                                                   <xs:complexType>
    122                                                   <xs:simpleContent>
    123                                                   <xs:extension base="cmd:Resourcetype_simple">
    124                                                   <xs:attribute name="mimetype" type="xs:string"/>
    125                                                   <xs:anyAttribute namespace="##other"
    126                                                   processContents="lax"/>
    127                                                   </xs:extension>
    128                                                   </xs:simpleContent>
    129                                                   </xs:complexType>
    130                                                   </xs:element>
    131                                                   <xs:element name="ResourceRef" minOccurs="1"
    132                                                   maxOccurs="1">
    133                                                   <xs:complexType>
    134                                                   <xs:simpleContent>
    135                                                   <xs:extension base="xs:anyURI">
    136                                                   <xs:anyAttribute namespace="##other"
    137                                                   processContents="lax"/>
    138                                                   </xs:extension>
    139                                                   </xs:simpleContent>
    140                                                   </xs:complexType>
    141                                                   </xs:element>
     103                                                    <xs:element name="ResourceType" minOccurs="1" maxOccurs="1">
     104                                                        <xs:complexType>
     105                                                            <xs:simpleContent>
     106                                                                <xs:extension base="cmd:Resourcetype_simple">
     107                                                                    <xs:attribute name="mimetype" type="xs:string"/>
     108                                                                    <xs:anyAttribute namespace="##other" processContents="lax"/>
     109                                                                </xs:extension>
     110                                                            </xs:simpleContent>
     111                                                        </xs:complexType>
     112                                                    </xs:element>
     113                                                    <xs:element name="ResourceRef" minOccurs="1" maxOccurs="1">
     114                                                        <xs:complexType>
     115                                                            <xs:simpleContent>
     116                                                                <xs:extension base="xs:anyURI">
     117                                                                    <xs:anyAttribute namespace="##other" processContents="lax"/>
     118                                                                </xs:extension>
     119                                                            </xs:simpleContent>
     120                                                        </xs:complexType>
     121                                                    </xs:element>
    142122                                                </xs:sequence>
    143123                                                <xs:attribute name="id" type="xs:ID" use="required"/>
    144                                                 <xs:anyAttribute namespace="##other"
    145                                                   processContents="lax"/>
     124                                                <xs:anyAttribute namespace="##other" processContents="lax"/>
    146125                                            </xs:complexType>
    147126                                        </xs:element>
     
    153132                                <xs:complexType>
    154133                                    <xs:sequence>
    155                                         <xs:element name="JournalFileProxy" minOccurs="0"
    156                                             maxOccurs="unbounded">
     134                                        <xs:element name="JournalFileProxy" minOccurs="0" maxOccurs="unbounded">
    157135                                            <xs:complexType>
    158136                                                <xs:sequence>
    159                                                   <xs:element name="JournalFileRef" minOccurs="1"
    160                                                   maxOccurs="1">
    161                                                   <xs:complexType>
    162                                                   <xs:simpleContent>
    163                                                   <xs:extension base="xs:anyURI">
    164                                                   <xs:anyAttribute namespace="##other"
    165                                                   processContents="lax"/>
    166                                                   </xs:extension>
    167                                                   </xs:simpleContent>
    168                                                   </xs:complexType>
    169                                                   </xs:element>
     137                                                    <xs:element name="JournalFileRef" minOccurs="1" maxOccurs="1">
     138                                                        <xs:complexType>
     139                                                            <xs:simpleContent>
     140                                                                <xs:extension base="xs:anyURI">
     141                                                                    <xs:anyAttribute namespace="##other" processContents="lax"/>
     142                                                                </xs:extension>
     143                                                            </xs:simpleContent>
     144                                                        </xs:complexType>
     145                                                    </xs:element>
    170146                                                </xs:sequence>
    171                                                 <xs:anyAttribute namespace="##other"
    172                                                   processContents="lax"/>
     147                                                <xs:anyAttribute namespace="##other" processContents="lax"/>
    173148                                            </xs:complexType>
    174149                                        </xs:element>
     
    181156                                <xs:complexType>
    182157                                    <xs:sequence>
    183                                         <xs:element name="ResourceRelation" minOccurs="0"
    184                                             maxOccurs="unbounded">
     158                                        <xs:element name="ResourceRelation" minOccurs="0" maxOccurs="unbounded">
    185159                                            <xs:complexType>
    186160                                                <xs:sequence>
    187                                                   <xs:element name="RelationType" minOccurs="1"
    188                                                   maxOccurs="1">
    189                                                   <xs:complexType>
    190                                                   <xs:simpleContent>
    191                                                   <xs:extension base="xs:string">
    192                                                   <xs:attribute name="ConceptLink" type="xs:anyURI"
    193                                                   use="optional"/>
    194                                                   <xs:anyAttribute namespace="##other"
    195                                                   processContents="lax"/>
    196                                                   </xs:extension>
    197                                                   </xs:simpleContent>
    198                                                   </xs:complexType>
    199                                                   </xs:element>
    200                                                   <xs:element name="Resource" minOccurs="2"
    201                                                   maxOccurs="2">
    202                                                   <xs:complexType>
    203                                                   <xs:sequence>
    204                                                   <xs:element name="Role" minOccurs="0"
    205                                                   maxOccurs="1">
    206                                                   <xs:complexType>
    207                                                   <xs:simpleContent>
    208                                                   <xs:extension base="xs:string">
    209                                                   <xs:attribute name="ConceptLink" type="xs:anyURI"
    210                                                   use="optional"/>
    211                                                   <xs:anyAttribute namespace="##other"
    212                                                   processContents="lax"/>
    213                                                   </xs:extension>
    214                                                   </xs:simpleContent>
    215                                                   </xs:complexType>
    216                                                   </xs:element>
    217                                                   </xs:sequence>
    218                                                   <xs:attribute name="ref" type="xs:IDREF"
    219                                                   use="required"/>
    220                                                   <xs:anyAttribute namespace="##other"
    221                                                   processContents="lax"/>
    222                                                   </xs:complexType>
    223                                                   </xs:element>
     161                                                    <xs:element name="RelationType" minOccurs="1" maxOccurs="1">
     162                                                        <xs:complexType>
     163                                                            <xs:simpleContent>
     164                                                                <xs:extension base="xs:string">
     165                                                                    <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional"/>
     166                                                                    <xs:anyAttribute namespace="##other" processContents="lax"/>
     167                                                                </xs:extension>
     168                                                            </xs:simpleContent>
     169                                                        </xs:complexType>
     170                                                    </xs:element>
     171                                                    <xs:element name="Resource" minOccurs="2" maxOccurs="2">
     172                                                        <xs:complexType>
     173                                                            <xs:sequence>
     174                                                                <xs:element name="Role" minOccurs="0" maxOccurs="1">
     175                                                                    <xs:complexType>
     176                                                                        <xs:simpleContent>
     177                                                                            <xs:extension base="xs:string">
     178                                                                                <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional"/>
     179                                                                                <xs:anyAttribute namespace="##other" processContents="lax"/>
     180                                                                            </xs:extension>
     181                                                                        </xs:simpleContent>
     182                                                                    </xs:complexType>
     183                                                                </xs:element>
     184                                                            </xs:sequence>
     185                                                            <xs:attribute name="ref" type="xs:IDREF" use="required"/>
     186                                                            <xs:anyAttribute namespace="##other" processContents="lax"/>
     187                                                        </xs:complexType>
     188                                                    </xs:element>
    224189                                                </xs:sequence>
    225                                                 <xs:anyAttribute namespace="##other"
    226                                                   processContents="lax"/>
     190                                                <xs:anyAttribute namespace="##other" processContents="lax"/>
    227191                                            </xs:complexType>
    228192                                        </xs:element>
Note: See TracChangeset for help on using the changeset viewer.