Opened 12 years ago

Closed 8 years ago

#236 closed enhancement (fixed)

Namespace prefixes for generic CMDI attributes (and possibly elements)

Reported by: twagoo Owned by: Dieter Van Uytvanck
Priority: major Milestone: CMDI 1.2
Component: ComponentSchema Version:
Keywords: attributes namespace Cc:

Description

Some or possibly all generic CMDI bits that go in the metadata instances should be prefixed to distinguish them from (potentially conflicting) profile specific elements. The clearest example is the 'ref' attribute that can go on all component instances; therefore at the moment we disallow custom attributes by that name. Namespaces would solve this more elegantly and arguably the same thing should be done for the other common things (mostly the header).

Change History (7)

comment:1 Changed 12 years ago by dietuyt

Would be ok for attributes like ref, however I would not do it for the Header elements, see the outcome of the previous (lengthy) discussion on this: http://trac.clarin.eu/wiki/CmdiNews#a2012-2-3

comment:2 Changed 11 years ago by twagoo

Keywords: attributes added

comment:3 Changed 10 years ago by mwindhouwer

Keywords: namespace added

comment:4 Changed 10 years ago by mwindhouwer

Here is an contextual diff to add @ref and @ComponentId as globally declared attributes, which have to be qualified and get referred to locally.

Index: comp2schema-v2/cleanup-xsd.xsl
===================================================================
--- comp2schema-v2/cleanup-xsd.xsl	(revision 4428)
+++ comp2schema-v2/cleanup-xsd.xsl	(working copy)
@@ -14,31 +14,20 @@
     <xsl:template match="/xs:schema" mode="clean">
         <xs:schema xmlns:cmd="http://www.clarin.eu/cmd/">
             <xsl:copy-of select="@*"/>
-	    <!-- Keep the annotation with header information -->
-            <xsl:copy-of select="xs:annotation" />
-            <xsl:apply-templates select="xs:import" mode="clean"/>
+            <!-- Copy most information -->
+            <xsl:copy-of select="* except (xs:simpleType|xs:complexType|xs:element)" />
             <!-- Remove double entries for named simpleType and complexType definitions at the begin of the XSD.  -->
             <xsl:for-each-group select="./xs:simpleType" group-by="@name">
                 <!-- only take the first item -->
-                <xsl:copy-of select="current-group( )[1]"/>
+                <xsl:copy-of select="current-group()[1]"/>
             </xsl:for-each-group>
-
             <xsl:for-each-group select="./xs:complexType" group-by="@name">
                 <!-- only take the first item -->
-                <xsl:copy-of select="current-group( )[1]"/>
+                <xsl:copy-of select="current-group()[1]"/>
             </xsl:for-each-group>
-
-            <xsl:apply-templates select="xs:element" mode="clean"/>
+            <!-- Copy the elements -->
+            <xsl:copy-of select="xs:element"/>
         </xs:schema>
     </xsl:template>

-
-    <!-- identity copy -->
-    <xsl:template match="@*|node()" mode="clean">
-        <xsl:copy>
-            <xsl:apply-templates select="@*|node()" mode="clean"/>
-        </xsl:copy>
-    </xsl:template>
-
-
 </xsl:stylesheet>
Index: comp2schema-v2/comp2schema.xsl
===================================================================
--- comp2schema-v2/comp2schema.xsl	(revision 4428)
+++ comp2schema-v2/comp2schema.xsl	(working copy)
@@ -72,7 +72,9 @@
             <xs:import namespace="http://www.w3.org/XML/1998/namespace"
                 schemaLocation="http://www.w3.org/2001/xml.xsd"/>

-
+            <xs:attribute name="ref" type="xs:IDREFS"/>
+            <xs:attribute name="ComponentId" type="xs:anyURI"/>
+
             <!--  first create complex types for valueschemes (not inline) -->
             <xsl:call-template name="CreateComplexTypes"/>

@@ -234,10 +236,10 @@
                 <xs:attribute ref="xml:base"/>
 		-->
                 <!-- @ref to the resource proxy (TODO: put this in the CMD namespace, i.e., @cmd:ref -->
-                <xs:attribute name="ref" type="xs:IDREFS"/>
+                <xs:attribute ref="cmd:ref"/>
                 <xsl:apply-templates select="./AttributeList/Attribute"/>
                 <xsl:if test="@ComponentId">
-                    <xs:attribute name="ComponentId" type="xs:anyURI" fixed="{@ComponentId}"/>
+                    <xs:attribute ref="cmd:ComponentId" fixed="{@ComponentId}"/>
                 </xsl:if>
             </xs:complexType>

cleanup-xsd.xsl also needs to change to make sure it doesn't prune the new attribute declarations away.

comment:5 Changed 10 years ago by twagoo

that last TODO can probably go :)

comment:6 Changed 10 years ago by Dieter Van Uytvanck

Owner: changed from dietuyt to Dieter Van Uytvanck
Status: newassigned

comment:7 Changed 8 years ago by Twan Goosen

Resolution: fixed
Status: assignedclosed

Fixed as part of CMDI 1.2 (See CMDI 1.2/Specification)

Note: See TracTickets for help on using tickets.