Schema import statements

Discussion in 'XML' started by Dennis B. Hansen, Aug 4, 2003.

  1. Hi all...

    I'm having some problems JAXB compiling som schemas, and was wondering
    if what i was trying to do is simply wrong... the problem seems to be
    with my import statements, and I've tried to create a simple example
    that generates the error (included below).

    I have two imported schemas, and JAXB seems to only want to import one
    of them (possibly because they have same namespace (???)).

    My questions are:
    1) Have I misunderstood imports, and is it illegal to import two
    schemaes with the same namespace (XMLSpy does'nt seem to see that as a
    problem).
    2) Could it be done in another way?
    3) Anyone have experience with other XML -> Java generators?

    A simple eksempel ;-)... :

    <?xml version="1.0"?>
    <schema targetNamespace="Tester"
    xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <simpleType name="NonEmptyString">
    <restriction base="string">
    <minLength value="1"/>
    </restriction>
    </simpleType>
    </schema>

    <?xml version="1.0"?>
    <schema targetNamespace="Tester"
    xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <simpleType name="PositiveNumber">
    <restriction base="integer">
    <minInclusive value="0"/>
    </restriction>
    </simpleType>
    </schema>

    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="Foo"
    xmlns:test="Tester"
    xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    version="1.0">
    <import namespace="Tester" schemaLocation="SimpleNumber.xsd"/>
    <import namespace="Tester" schemaLocation="SimpleString.xsd"/>
    <complexType name="StringNumber">
    <sequence>
    <element name="aString" type="test:NonEmptyString"
    minOccurs="0"/>
    <element name="aNumber" type="test:positiveNumber"
    minOccurs="0"/>
    </sequence>
    </complexType>
    </schema>

    .... Thanx in advance

    /Dennis
     
    Dennis B. Hansen, Aug 4, 2003
    #1
    1. Advertising

  2. Dennis B. Hansen

    Mike Grayson Guest

    import namespace can't be same as targetNamespace of schema it exists in.

    http://www.w3schools.com/schema/el_import.asp

    http://www.w3schools.com/schema/el_include.asp


    (Dennis B. Hansen) wrote in message news:<>...
    > Hi all...
    >
    > I'm having some problems JAXB compiling som schemas, and was wondering
    > if what i was trying to do is simply wrong... the problem seems to be
    > with my import statements, and I've tried to create a simple example
    > that generates the error (included below).
    >
    > I have two imported schemas, and JAXB seems to only want to import one
    > of them (possibly because they have same namespace (???)).
    >
    > My questions are:
    > 1) Have I misunderstood imports, and is it illegal to import two
    > schemaes with the same namespace (XMLSpy does'nt seem to see that as a
    > problem).
    > 2) Could it be done in another way?
    > 3) Anyone have experience with other XML -> Java generators?
    >
    > A simple eksempel ;-)... :
    >
    > <?xml version="1.0"?>
    > <schema targetNamespace="Tester"
    > xmlns="http://www.w3.org/2001/XMLSchema"
    > elementFormDefault="qualified">
    > <simpleType name="NonEmptyString">
    > <restriction base="string">
    > <minLength value="1"/>
    > </restriction>
    > </simpleType>
    > </schema>
    >
    > <?xml version="1.0"?>
    > <schema targetNamespace="Tester"
    > xmlns="http://www.w3.org/2001/XMLSchema"
    > elementFormDefault="qualified">
    > <simpleType name="PositiveNumber">
    > <restriction base="integer">
    > <minInclusive value="0"/>
    > </restriction>
    > </simpleType>
    > </schema>
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <schema targetNamespace="Foo"
    > xmlns:test="Tester"
    > xmlns="http://www.w3.org/2001/XMLSchema"
    > elementFormDefault="qualified" attributeFormDefault="unqualified"
    > version="1.0">
    > <import namespace="Tester" schemaLocation="SimpleNumber.xsd"/>
    > <import namespace="Tester" schemaLocation="SimpleString.xsd"/>
    > <complexType name="StringNumber">
    > <sequence>
    > <element name="aString" type="test:NonEmptyString"
    > minOccurs="0"/>
    > <element name="aNumber" type="test:positiveNumber"
    > minOccurs="0"/>
    > </sequence>
    > </complexType>
    > </schema>
    >
    > ... Thanx in advance
    >
    > /Dennis
     
    Mike Grayson, Aug 11, 2003
    #2
    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. Neil Zanella
    Replies:
    8
    Views:
    1,232
    mfmehdi
    Oct 20, 2006
  2. Markus
    Replies:
    1
    Views:
    1,661
    Markus
    Nov 23, 2005
  3. Iain Robinson

    XML Schema import statements

    Iain Robinson, Nov 7, 2004, in forum: XML
    Replies:
    4
    Views:
    570
    Henry S. Thompson
    Nov 26, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,325
    Stanimir Stamenkov
    Apr 25, 2005
  5. Vitali Gontsharuk
    Replies:
    2
    Views:
    605
    Vitali Gontsharuk
    Aug 25, 2005
Loading...

Share This Page