What is wrong with this schema?

This should cover W3C XML Schema, Relax NG and DTD related problems.
frankmoss
Posts: 5

What is wrong with this schema?

Wed Feb 09, 2011 11:53 am

I have a schema, which uses an imported namespace, and elements represented in that namespace are not recognized. What am I doing wrong? Thanks in advance.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://gov.co.uk/frbr/"
    xmlns="http://gov.co.uk/frbr"
    xmlns:tns="http://gov.co.uk/frbr/"
    xmlns:marcxml="http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
    elementFormDefault="qualified">
    <xs:import namespace="marcxml" schemaLocation="http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"/>
   
     <xs:element name="work" type="tns:work"/>
    <xs:element name="person" type="tns:person"/>
    <xs:complexType name="record">
        <xs:sequence>
            <xs:element ref="tns:manifestation"/>
        </xs:sequence>
        <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
   
    <xs:complexType name="work">
        <xs:sequence>
            <xs:element name="title" type="tns:title"/>
            <xs:element name="hasSubject" type="tns:subject"/>
            <xs:element ref="marcxml:datafield"/>
            <xs:element name="person" type="tns:person" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="adaption" type="xs:NMTOKEN" use="optional"/>
        <xs:attribute name="adaptionOf" type="xs:NMTOKEN" use="optional"/>
        <xs:attribute name="complement" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="complementOf" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="creator" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="imitation" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="imitationOf" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="successor" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="successorOf" use="optional" type="xs:NMTOKEN"/>
        <xs:attribute name="relation" use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="adaption"/>
                    <xs:enumeration value="adaptionOf"/>
                    <xs:enumeration value="complement"/>
                    <xs:enumeration value="complementOf"/>
                    <xs:enumeration value="creator"/>
                    <xs:enumeration value="realization"/>
                    <xs:enumeration value="imitation"/>
                    <xs:enumeration value="imitationOf"/>
                    <xs:enumeration value="successorOf"/>
                    <xs:enumeration value="successor"/>
                    <xs:enumeration value="summarization"/>
                    <xs:enumeration value="summarizationOf"/>
                    <xs:enumeration value="supplement"/>
                    <xs:enumeration value="supplementOf"/>
                    <xs:enumeration value="transformation"/>
                    <xs:enumeration value="transformationOf"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="person">
        <xs:sequence>
            <xs:choice>
                <xs:element name="fullName" minOccurs="0" maxOccurs="1"/>
                <xs:element name="name" minOccurs="0" maxOccurs="1">
                    <xs:complexType>
                        <xs:attribute name="first" type="xs:string"/>
                        <xs:attribute name="last" type="xs:string"/>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
            <xs:element ref="marcxml:datafield"/>
        </xs:sequence>
        <xs:attribute name="creatorOf" type="xs:IDREFS" use="optional"/>
        <xs:attribute name="relation">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="creatorOf"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:element name="identifier">
        <xs:complexType>
            <xs:all>
                <xs:element ref="marcxml:controlfield"/>
                <xs:element ref="marcxml:datafield"/>
            </xs:all>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="title">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="published">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="description">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>   
    </xs:complexType>   
    <xs:complexType name="series">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>   
    </xs:complexType>
    <xs:complexType name="language">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="subject">
        <xs:sequence>
            <xs:element ref="marcxml:datafield" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
frankmoss
Posts: 5

Re: What is wrong with this schema?

Wed Feb 09, 2011 12:00 pm

BTW the error reported by Oxygen is:

Code: Select all

E [Xerces] src-resolve.4.2: Error resolving component 'marcxml:controlfield'. It was detected that 'marcxml:controlfield' is in namespace 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', but components from this namespace are not referenceable from schema document 'file:/myfile.xsd'. If this is the incorrect namespace, perhaps the prefix of 'marcxml:controlfield' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/myfilehybrid.xsd'.

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 2 guests