Schema import statements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis B. Hansen

    #1

    Schema import statements

    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"
    elementFormDefa ult="qualified" >
    <simpleType name="NonEmptyS tring">
    <restriction base="string">
    <minLength value="1"/>
    </restriction>
    </simpleType>
    </schema>

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

    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace ="Foo"
    xmlns:test="Tes ter"
    xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied"
    version="1.0">
    <import namespace="Test er" schemaLocation= "SimpleNumber.x sd"/>
    <import namespace="Test er" schemaLocation= "SimpleString.x sd"/>
    <complexType name="StringNum ber">
    <sequence>
    <element name="aString" type="test:NonE mptyString"
    minOccurs="0"/>
    <element name="aNumber" type="test:Posi tiveNumber"
    minOccurs="0"/>
    </sequence>
    </complexType>
    </schema>

    .... Thanx in advance

    /Dennis
  • Mike Grayson

    #2
    Re: Schema import statements

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

    Sorry! We can't seem to find the resource you're looking for


    Sorry! We can't seem to find the resource you're looking for



    mimer@privat.dk (Dennis B. Hansen) wrote in message news:<3f2e0e63. 3024743140@news .tele.dk>...[color=blue]
    > 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"
    > elementFormDefa ult="qualified" >
    > <simpleType name="NonEmptyS tring">
    > <restriction base="string">
    > <minLength value="1"/>
    > </restriction>
    > </simpleType>
    > </schema>
    >
    > <?xml version="1.0"?>
    > <schema targetNamespace ="Tester"
    > xmlns="http://www.w3.org/2001/XMLSchema"
    > elementFormDefa ult="qualified" >
    > <simpleType name="PositiveN umber">
    > <restriction base="integer">
    > <minInclusive value="0"/>
    > </restriction>
    > </simpleType>
    > </schema>
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <schema targetNamespace ="Foo"
    > xmlns:test="Tes ter"
    > xmlns="http://www.w3.org/2001/XMLSchema"
    > elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied"
    > version="1.0">
    > <import namespace="Test er" schemaLocation= "SimpleNumber.x sd"/>
    > <import namespace="Test er" schemaLocation= "SimpleString.x sd"/>
    > <complexType name="StringNum ber">
    > <sequence>
    > <element name="aString" type="test:NonE mptyString"
    > minOccurs="0"/>
    > <element name="aNumber" type="test:Posi tiveNumber"
    > minOccurs="0"/>
    > </sequence>
    > </complexType>
    > </schema>
    >
    > ... Thanx in advance
    >
    > /Dennis[/color]

    Comment

    Working...