Help please...How to import a schema with a different namespace?

Discussion in 'XML' started by Ingrid, Aug 23, 2004.

  1. Ingrid

    Ingrid Guest

    I am looking to incorporate Schema 1 (below) into Schema 2, using the
    <import> element. But I just can't figure out how to declare the in:
    namespace prefix/use targetNamespace correctly - for both Schemas...

    Any ideas? Please put me out of my misery - somebody...

    As soon as I add the targetNamespace="http://num/in"> in Schema 1 both
    Schemas throw up the following error message:

    Error resolving component 'numType'. It was detected that 'numType'
    has no namespace, but components with no target namespace are not
    referenceable from schema document "Schema 1". If 'numType' is
    intended to have a namespace, perhaps a prefix needs to be provided.
    If it is intended that 'numType' has no namespace, then an 'import'
    without a "namespace" attribute should be added to "Schema 1".

    Schema 2:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema elementFormDefault="qualified"
    attributeFormDefault="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:in="http://num/in">
    <xs:import namespace="http://num/in"
    schemaLocation="Num.xsd"></xs:import>
    <xs:element name="num">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="in:num"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>


    Schema 1:
    <in:schema xmlns:in="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://num/in">
    <in:element name="num" type="numType"></in:element>
    <in:complexType name="numType">
    <in:simpleContent>
    <in:extension base="pageRange">
    <in:attribute name="type" use="required">
    <in:simpleType>
    <in:restriction base="in:string">
    <in:enumeration
    value="pagerange"></in:enumeration>
    </in:restriction>
    </in:simpleType>
    </in:attribute>
    </in:extension>
    </in:simpleContent>
    </in:complexType>
    <in:simpleType name="pageRange">
    <in:restriction base="in:string">
    <in:minLength value="3"></in:minLength>
    <in:maxLength value="7"></in:maxLength>
    <in:pattern value="\d{1,3}-\d{1,3}"></in:pattern>
    </in:restriction>
    </in:simpleType>
    </in:schema>
    Ingrid, Aug 23, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,522
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,245
    Stanimir Stamenkov
    Apr 25, 2005
  3. Vitali Gontsharuk
    Replies:
    2
    Views:
    561
    Vitali Gontsharuk
    Aug 25, 2005
  4. Replies:
    1
    Views:
    509
    George Bina
    Jul 20, 2006
  5. Christof Winter
    Replies:
    1
    Views:
    1,005
    Christof Winter
    Jul 28, 2008
Loading...

Share This Page