#acl AndyPowell:read,write,delete,admin PeteJohnston:read,write,delete,admin All:read = DC-XML and W3C XML Schema = This document is part of the [wiki:Self:. DC Architecture Wiki]. '''IMPORTANT:''' Do '''not''' cite materials in this Wiki other than for the purposes of collaborating on document creation. This Wiki is intended to be used to work on draft copies of documents. Finished documents will be published, in a persistent and citable form, on the dublincore.org Web site (or elsewhere in some cases). This is a draft document, made available for public comment. Comments should be sent to the DC-ARCHITECTURE@jiscmail.ac.uk mailing list (for detailed technical comments) or to the DC-GENERAL@jiscmail.ac.uk mailing list (for comments of a more general nature). || '''Title:''' || '''DC-XML and W3C XML Schema''' || || '''Creator:''' || Pete Johnston, Eduserv Foundation || || '''Creator:''' || Andy Powell, Eduserv Foundation || || '''Date Issued:''' || 2006-05-29 || || '''Identifier:''' || http://dublincore.org/architecturewiki/DCXMLRevision/DCXMLSchema/2006-05-29 || || '''Replaces:''' || Not applicable || || '''Is Replaced By:''' || Not applicable || || '''Latest Version:''' || http://dublincore.org/architecturewiki/DCXMLRevision/DCXMLSchema || || '''Description of Document:''' || This document discusses how W3C XML Schema may be used to describe the DC-XML XML format. || == Contents == 1. Introduction 1. DC-XML and W3C XML Schema 1. Constraining DC-XML using W3C XML Schema 1. Notes 1. References [[Anchor(sec1)]] == 1. Introduction == The DCMI Abstract Model [[#DCAM DCAM]] describes the constructs that make up a DC metadata ''description set''. DC-XML is an XML format for representing a DC metadata ''description set'' in XML [[#DCXML DCXML]] (See [#Note1 Note 1]) This document outlines briefly how the DC-XML format is described using W3C XML Schema in the set of schemas provided by DCMI. It then provides some examples of how these schemas may be used in conjunction with other schemas defined by other parties to implement some of the constraints on a DC ''description set'' which are typically specified by a DC Application Profile. Note: This document references various XML schemas and XML instances. These are presently made available as attachments to pages in this Wiki. This is a temporary measure, and, when stable, they will be assigned persistent URIs on the DCMI Web site. [[Anchor(sec2)]] == 2. DC-XML and W3C XML Schema == The DC-XML format is not dependent on any features of W3C XML Schema, but can be described using W3C XML Schema. DCMI provides the following set of schemas to describe the DC-XML format; * Schema: [attachment:DCXMLRevision/DCXMLBaseSchemas/dcx.xsd dcx.xsd][[BR]]Target XML Namespace: `http://purl.org/dc/xml/` * Schema: [attachment:DCXMLRevision/DCXMLBaseSchemas/dc.xsd dc.xsd][[BR]]Target XML Namespace: `http://purl.org/dc/elements/1.1/` * Schema: [attachment:DCXMLRevision/DCXMLBaseSchemas/dcterms.xsd dcterms.xsd][[BR]]Target XML Namespace: `http://purl.org/dc/terms/` * Schema: [attachment:DCXMLRevision/DCXMLBaseSchemas/dcmitype.xsd dcmitype.xsd][[BR]]Target XML Namespace: `http://purl.org/dc/dcmitype/` [[Anchor(sec2.1)]] === 2.1 Schema: dcx.xsd Target XML Namespace: http://purl.org/dc/xml/ === This schema declares the XML elements and attributes associated with names in the `http://purl.org/dc/xml/` XML Namespace. It also defines a set of XML Schema complex types which describe the default content models for these elements. [[Anchor(sec2.1.1)]] ==== 2.1.1 The dcx:DescriptionSetElement complex type ==== The `dcx:DescriptionSetElement` complex type defines the content model for a DC-XML Description Set Element. A DC-XML Description Set Element may contain one or more DC-XML Description Elements; the names of those Description Elements may be from any XML Namespace. A DC-XML Description Set Element may also have XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 1: The dcx:!DescriptionSetElement complexType''' [[Anchor(sec2.1.2)]] ==== 2.1.2 The dcx:DescriptionElement complex type ==== The `dcx:DescriptionElement` complex type defines the content model for a DC-XML Description Element. A DC-XML Description Element may contain one or more DC-XML Statement Elements; the names of those Statement Elements may be from any XML Namespace other than `http://purl.org/dc/xml/`. A DC-XML Description Element may also have a `dcx:resourceURI` and a `dcx:descriptionId` attribute. A DC-XML Description Element may also have other XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 2: The dcx:!DescriptionElement complexType''' [[Anchor(sec2.1.3)]] ==== 2.1.3 The dcx:StatementElement complex type ==== The `dcx:StatementElement` complex type defines the content model for a DC-XML Statement Element. A DC-XML Statement Element may contain Value Representation Elements, which must have the names indicated. A DC-XML Statement Element may also have a `dcx:valueURI`, `dcx:vocabEncSchemeURI` or `dcx:descriptionRef` attribute. A DC-XML Statement Element may also have other XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 3: The dcx:!StatementElement complexType''' [[Anchor(sec2.1.4)]] ==== 2.1.4 The dcx:ValueStringElement complex type ==== The `dcx:ValueStringElement` complex type defines the content model for a DC-XML Value String Element. A DC-XML Value String Element must have simple content. A DC-XML Statement Element may also have a xml:lang, `dcx:syntaxEncSchemeURI` or `dcx:syntaxEncSchemeQName` attribute. A DC-XML Statement Element may also have other XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 4: The dcx:!ValueStringElement complexType''' [[Anchor(sec2.1.5)]] ==== 2.1.5 The dcx:XMLRepresentationElement complex type ==== The `dcx:XMLRepresentationElement` complex type defines the content model for a DC-XML XML Representation Element. A DC-XML XML Representation Element may have mixed content. A DC-XML XML Representation Element may have a `dcx:representationURI` attribute. A DC-XML XML Representation Element may also have other XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 5: The dcx:XML!RepresentationElement complexType''' [[Anchor(sec2.1.6)]] ==== 2.1.6 The dcx:BinaryRepresentationElement complex type ==== The `dcx:BinaryRepresentationElement` complex type defines the content model for a DC-XML Binary Representation Element. A DC-XML Binary Representation Element must have simple content. A DC-XML Binary Representation Element may have a `dcx:representationURI` attribute. A DC-XML Binary Representation Element may also have other XML attributes, the names of which may be from any XML Namespace other than `http://purl.org/dc/xml/`. {{{ }}} '''XSD Example 6: The dcx:!BinaryRepresentationElement complexType''' [[Anchor(sec2.2)]] === 2.2 Schema: dc.xsd Target XML Namespace: http://purl.org/dc/elements/1.1/ === This schema declares a set of Statement Elements to represent ''statements'' referring to the 15 ''properties'' of the DCMES, i.e. these declarations use the complex type `dcx:StatementElement`. It also defines a complex type `dc:DescriptionElement` as a convenience for schema authors who need to define a Description Element allowing all of the Statement Elements in the `http://purl.org/dc/elements/1.1/` XML Namespace as child elements. [[Anchor(sec2.3)]] === 2.3 Schema: dcterms.xsd Target XML Namespace: http://purl.org/dc/terms/ === This schema declares a set of Statement Elements to represent ''statements'' referring to the ''properties'' of the DC Terms vocabulary., i.e. these declarations use the complex type `dcx:StatementElement`. It also defines a complex type `dcterms:DescriptionElement` as a convenience for schema authors who need to define a Description Element for all of the Statement Elements in the `http://purl.org/dc/terms/` XML Namespace. [[Anchor(sec2.4)]] === 2.4 Schema: dcmitype.xsd Target XML Namespace: http://purl.org/dc/dcmitype/ === This schema defines only a set of named XML Schema simple types which specify an enumerated lists of strings, URIs and XML QNames for referring to the classes of the DCMI Type Vocabulary. [[Anchor(sec3)]] == 3. Constraining DC-XML using W3C XML Schema == A Dublin Core Application Profile (DCAP) specifies the terms that are used in a class of DC ''description sets''. In the context of an application, it may be desirable to constrain the content of a DC-XML instance so that it supports the representation of only certain metadata terms (e.g. the set of ''properties'' and classes specified by a DC Application Profile), or so that the use of certain constructs from the DCMI Abstract Model are required (e.g. for a specified ''property'', ''statements'' always use a ''value string'', or for another ''property'', ''statements'' use a ''value URI''), and for a validator to check that these constraints are met by the instance. The content models for the principal XML elements within a DC-XML instance are defined by the XML Schema complex types listed in [#sec2 section 2]. XML Schema provides a mechanism known as ''type derivation'' by which new XML Schema datatypes can be defined, based on existing types, to specify new content models. In particular this document focuses on the derivation of complex types ''by restriction'': A complex type derived by restriction is very similar to its base type, except that its declarations are more limited than the corresponding declarations in the base type. In fact, the values represented by the new type are a subset of the values represented by the base type (as is the case with restriction of simple types). In other words, an application prepared for the values of the base type would not be surprised by the values of the restricted type [[#XMLSCHEMA-0 XMLSCHEMA-0]] Once a new derived complex type has been defined, it must be associated with the XML element to which it is being applied. There are two mechanisms for achieving this: * associating the derived complex type with the name of an XML element in an XML element declaration within an XML Schema * referring to the derived complex type using the `xsi:type` attribute within an XML instance Examples of both approaches are described below. Whichever of the two approaches is taken, it is important to note that the use of these derived complex types '''does not change''' the interpretation of a DC-XML instance document in the sense of how the components within the XML document are mapped to the constructs used within the DCMI Abstract Model: the use of derived complex types enables more restrictive checking of an instance by a processor performing XML Schema validation, but does not add to the DC metadata ''description set''. [[Anchor(sec3.1)]] === 3.1 Constraining the Descriptions within a Description Set === The DC-XML syntax requires the use of the `dcx:descriptionSet` XML element to represent a ''description set''. Each child element of the `dcx:descriptionSet` XML element represents a ''description''. The default content model for the `dcx:DescriptionSet` XML element permits these child elements, the Description Elements, to have any name. An application might specify a content model requiring those Description Elements to be of elements of specific names (and then provide a restricted content model for those elements. See section [#sec3.2 section 3.2].) Using W3C XML Schema, this might be done by deriving a named XML Schema complex type that restricts the default content model for the `dcx:descriptionSet` XML element and referencing this derived type using the `xsi:type` attribute. [[Anchor(sec3.1.1)]] ==== 3.1.1 Deriving a complex type by restriction ==== The definition of the `!FooBarDescriptionSet` complex type below specfies that the Description Elements (the child elements of the Description Set Element) must have the names `your:fooDescription` and `your:barDescription`, and that there must be at least one occurrence of each. {{{ }}} '''XSD Example 7: Deriving a restricted complex type for the Description Set Element''' An XML instance references this new complex type using the `xsi:type` attribute: {{{ }}} '''XML Example 1: Referencing the derived complex type for the Description Set Element''' The `xsi:type` approach is taken for this case because the DC-XML format requires that the Description Set Element has the name `dcx:descriptionSet`, and a declaration for this element is provided in the DCMI-supplied dc.xsd schema. It is possible to use the `xsd:redefine` mechanism to modify the definition of the `dcx:DescriptionSetElement` complex type. However, that modified definition would then apply to all other schema components that reference that type: it would not be possible, for example, to reference the original definition of the `dcx:DescriptionSetElement` complex type in another declaration. Also the use of the `xsd:redefine` mechanism can make it difficult for a human reader of the schemas to interpret which version of the type definition is in force: looking at the base schema, a reader has no indication where that the type has been redefined in another schema. [[Anchor(sec3.1.2)]] ==== 3.1.2 Example Schemas and Instances ==== The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/simpledc.xsd simpledc.xsd] example schema defines a complex type which restricts the content of the Description Set Element to a single Description Element with the name `dcx:description`. The instance [attachment:DCXMLRevision/DCXMLInstances/ex1.xml ex1.xml] validates against the simpledc.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/qualifieddc.xsd qualifieddc.xsd] example schema defines a complex type which requires that the content of the Description Set Element is at least one Description Element with the name `dcx:description`. The instance [attachment:DCXMLRevision/DCXMLInstances/ex2.xml ex2.xml] validates against the qualifieddc.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/mydcap.xsd mydcap.xsd] example schema defines a complex type which requires that the content of the Description Set Element is at least one Description Element with the name `dcx:description`. The instances [attachment:DCXMLRevision/DCXMLInstances/ex3.xml ex3.xml], [attachment:DCXMLRevision/DCXMLInstances/ex4.xml ex4.xml] and [attachment:DCXMLRevision/DCXMLInstances/ex5.xml ex5.xml] validate against the mydcap.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/yourdcap.xsd yourdcap.xsd] example schema defines a complex type which requires that the content of the Description Set Element is at least one Description Element with the name `dcap:fooDescription` followed by at least one Description Element with the name `dcap:barDescription` (where the prefix `dcap` is associated with a non-DCMI owned XML Namespace Name). The instance [attachment:DCXMLRevision/DCXMLInstances/ex6.xml ex6.xml] validates against the yourdcap.xsd schema. [[Anchor(sec3.2)]] === 3.2 Constraining the Statements used in a Description === Each child element of the `dcx:DescriptionSet` XML element represents a ''description'', and is referred to as a Description Element. Each child element of those Description Elements represents a ''statement'', and is referred to as a Statement Element. An application might specify that ''statements'' within a class of ''descriptions'' refer only to specified ''properties''. In DC-XML this can be achieved by specifying a content model for a Description Element that requires the Statement Elements to be of elements with specific names. Either of the approaches described at the start of [#sec3 section 3] might be applied in this case. [[Anchor(sec3.2.1)]] ==== 3.2.1 Deriving a complex type by restriction ==== One approach would be to derive a named XML Schema complex type that restricts the default type for the `dcx:description` XML element, and to reference this derived type in the XML instance using the `xsi:type` attribute. The definition of the `!FooDescription` complex type definition below specfies that the Statement Elements (the child elements of the Description Element) must have the names `dc:title`, `dc:type`, `dc:subject` or `dcterms:isReferencedBy`. {{{ }}} '''XSD Example 8: Deriving a restricted complex type for the Description Element''' {{{ First foo Horse-drawn vehicles -- Queensland -- Atherton Image }}} '''XML Example 2: Referencing the derived complex type for the Description Element''' [[Anchor(sec3.2.2)]] ==== 3.2.2 Declaring a new Description Element ==== Since the DC-XML format permits Description Elements to have any name, an application might declare elements with its own names for Description Elements and provide content models for those elements, using a complex type derived by restriction from the `dcx:DescriptionElement` complex type. The element declaration below declares the `your:fooDescription` Description Element. The content model limits the Statement Elements which can occur within this Description Element to those with the names `dc:title`, `dc:type`, `dc:subject` or `dcterms;isReferencedBy`. The example uses a named complex type but it could also have used an anonymous complex type since the type is not referenced anywhere else in the schema or in the XML instance {{{ }}} '''XSD Example 9: Declaring a new Description Element''' {{{ First foo Horse-drawn vehicles -- Queensland -- Atherton Image }}} '''XML Example 3: Using a new Description Element''' [[Anchor(sec3.2.3)]] ==== 3.2.3 Example Schemas and Instances ==== The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/simpledc.xsd simpledc.xsd] example schema defines a complex type which restricts the content of the Description Element to a set of Statement Elements with names corresponding to the URIs of the 15 ''properties'' of the DCMES. The instance [attachment:DCXMLRevision/DCXMLInstances/ex1.xml ex1.xml] validates against the simpledc.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/qualifieddc.xsd qualifieddc.xsd] example schema defines a complex type which restricts the content of the Description Elements to a set of Statement Elements with names corresponding to the URIs of the ''properties'' defined by DCMI. The instance [attachment:DCXMLRevision/DCXMLInstances/ex2.xml ex2.xml] validates against the qualifieddc.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/mydcap.xsd mydcap.xsd] example schema defines complex types which restricts the content of the Description Elements to Statement Elements with names corresponding to specified lists of ''properties''. The instances [attachment:DCXMLRevision/DCXMLInstances/ex3.xml ex3.xml], [attachment:DCXMLRevision/DCXMLInstances/ex4.xml ex4.xml] and [attachment:DCXMLRevision/DCXMLInstances/ex5.xml ex5.xml] validate against the mydcap.xsd schema. The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/yourdcap.xsd yourdcap.xsd] example schema defines complex types which restrict the content of the Description Elements to Statement Elements with names corresponding to specified lists of ''properties''. It also declares the `dcap:fooDescription` Description Element and the `dcap:barDescription` Description Element using those complex types. The instance [attachment:DCXMLRevision/DCXMLInstances/ex6.xml ex6.xml] validates against the yourdcap.xsd schema. [[Anchor(sec3.3)]] === 3.3 Constraining the Constructs used in a Statement === An application might specify that for a ''statement'' referencing a specified ''property'', there are limitations on the other DCAM constructs that can be used in that ''statement''. In DC-XML this can be achieved by specifying a content model for a Statement Element. The name of the Statement Element is determined by the `property URI`, so this is typically done by derive a named XML Schema complex type that restricts the default type for the Statement Element, and referencing this derived type in the XML instance using the `xsi:type` attribute. [[Anchor(sec3.3.1)]] ==== 3.3.1 Deriving a complex type by restriction ==== The definition of the `FooIsRefByStatement` complex type definition below specifies that the Statement Element must provide a `dcx:valueURI` attribute, and must be empty. {{{ }}} '''XSD Example 10: Deriving a restricted complex type for a Statement Element''' {{{ First foo Horse-drawn vehicles -- Queensland -- Atherton Image }}} '''XML Example 4: Referencing the derived complex type for the Statement Element''' [[Anchor(sec3.3.2)]] ==== 3.3.2 Example Schemas and Instances ==== The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/theirdcap.xsd theirdcap.xsd] example schema defines a complex type which restricts the content of the Statement Element for the dcterms:isReferencedBy ''property''. The instance [attachment:DCXMLRevision/DCXMLInstances/ex7.xml ex7.xml] validates against the theirdcap.xsd schema. [[Anchor(sec3.4)]] === 3.4 Constraining the Content of a Value Representation === [[Anchor(sec3.4.1)]] ==== 3.4.1 Constraining the Content of a Value String ==== An application may derive an XML Schema complex type that restricts the default type for the `dcx:valueString` XML element. This derived complex type is referenced in the XML instance using the `xsi:type` attribute. In this example, the content is limited to the set of ''value strings'' associated with the classes of the DCMI Type Vocabulary. {{{ }}} '''XSD Example 11: Deriving a restricted complex type for the Value String Element''' {{{ First foo Horse-drawn vehicles -- Queensland -- Atherton Image }}} '''XML Example 5: Referencing the derived complex type for the Value String Element''' [[Anchor(sec3.4.1.1)]] ===== 3.4.1.1 Example Schemas and Instances ===== The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/theirdcap.xsd theirdcap.xsd] example schema defines a complex type which restricts the content of the Value String Element for the dc:type ''property''. The instance [attachment:DCXMLRevision/DCXMLInstances/ex7.xml ex7.xml] validates against the theirdcap.xsd schema. [[Anchor(sec3.4.2)]] ==== 3.4.2 Constraining the Content of an XML Representation ==== An application may derive an XML Schema complex type that restricts the default type for the `dcx:XMLRepresentation` XML element. This derived complex type is referenced in the XML instance using the `xsi:type` attribute. In this example, the content is limited to a single XHTML element. {{{ }}} '''XSD Example 12: Deriving a restricted complex type for the XML Representation Element''' {{{ First bar Text John Smith Smith, John Big Co

First bar is the occasional newsletter of Big Co.

}}} '''XML Example 7: Referencing the derived complex type for the XML Representation Element''' [[Anchor(sec3.4.2.1)]] ===== 3.4.2.1 Example Schemas and Instances ===== The schema [attachment:DCXMLRevision/DCXMLDCAPSchemas/theirdcap.xsd theirdcap.xsd] example schema defines a complex type which restricts the content of the XML Representation Element for the dc:description ''property''. The instance [attachment:DCXMLRevision/DCXMLInstances/ex7.xml ex7.xml] validates against the theirdcap.xsd schema. == Appendix A: Examples == The examples referred to in this document are listed together on the following pages * Base schemas http://dublincore.org/architecturewiki/DCXMLRevision/DCXMLBaseSchemas * DCAP schemas http://dublincore.org/architecturewiki/DCXMLRevision/DCXMLDCAPSchemas * Instances http://dublincore.org/architecturewiki/DCXMLRevision/DCXMLInstances == Notes == [[Anchor(Note1)]]'''[1]''' DC-XML is one XML format for representing DC metadata ''description sets'' in XML. Other such formats may exist. For example, the Open Archives Initiative Protocol for Metadata Harvesting [[#OAIPMH OAIPMH]] defines a format, commonly known as oai_dc, which supports the serialisation of DC ''description sets'' containing a single ''description'', with ''statements'' referencing only the fifteen ''properties'' of the DCMES, and using ''value strings'' only. == References == [[Anchor(DCXML)]]'''[DCXML]'''[[BR]]Expressing Dublin Core metadata using XML. Working Draft of 2006-05-29.[[BR]]http://dublincore.org/documents/dc-xml/2006-05-29/ [[Anchor(DCAM)]]'''[DCAM]'''[[BR]]DCMI Abstract Model[[BR]]http://dublincore.org/documents/abstract-model/ [[Anchor(XML)]]'''[XML]'''[[BR]]''Extensible Markup Language (XML) 1.0 (Third Edition)''. W3C Recommendation 04 February 2004.[[BR]]http://www.w3.org/TR/REC-xml [[Anchor(XMLSCHEMA-0)]]'''[XMLSCHEMA-0]'''[[BR]]''XML Schema Part 0: Primer Second Edition''. W3C Recommendation 28 October 2004.[[BR]]http://www.w3.org/TR/xmlschema-0/ [[Anchor(XMLSCHEMA-1)]]'''[XMLSCHEMA-1]'''[[BR]]''XML Schema Part 1: Structures Second Edition''. W3C Recommendation 28 October 2004.[[BR]]http://www.w3.org/TR/xmlschema-1/ [[Anchor(XMLSCHEMA-2)]]'''[XMLSCHEMA-2]'''[[BR]]''XML Schema Part 2: Datatypes Second Edition''. W3C Recommendation 28 October 2004.[[BR]]http://www.w3.org/TR/xmlschema-2/ [[Anchor(OAIPMH)]]'''[OAIPMH]'''[[BR]]''The Open Archives Initiative Protocol for Metadata Harvesting'' Protocol Version 2.0 of 2002-06-14.[[BR]]http://www.openarchives.org/OAI/openarchivesprotocol.html [[Anchor(DC-TEXT)]]'''[DC-TEXT]'''[[BR]]''DC-Text: A Text Syntax for Dublin Core Metadata'' Draft of 2006-05-24.[[BR]]http://dublincore.org/architecturewiki/DCText/2006-05-24