You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Oleg Galis <aq...@ibis.odessa.ua> on 2000/07/06 14:29:03 UTC

Shema: problem with definition recursive data types

How can I describe the recursive date types?
I tried something like this:

<?xml version="1.0"?>
<schema>
 <element name="aa" type="aaType"
          minOccurs='0' maxOccurs='unbounded'/>
 <complexType name="aaType">
   <element name="aa" type="aaType" minOccurs="0" maxOccurs='unbounded'/> 
 </complexType> 
</schema>

for the xml:
<aa xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
    xsi:noNamespaceSchemaLocation='re.xsd'
    >
 <aa> 
   <aa>
   </aa>
 </aa>
</aa>

I got the next errors:
[Error] re.xml:8:8: The content of element type "aa" must match "(aa)*".
[Error] re.xml:10:7: The content of element type "aa" must match "(aa)*".

Thanks,
Oleg Galis



RE: Re[2]: Shema: problem with definition recursive data types

Posted by Jean-Louis Vila <jl...@cosmosbay.com>.
Hi Eric,

What's about this answer ?

First,
> > <aa
> >     xmlns='NS'
> >     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> >     xsi:schemaLocation='NS re.xsd'
> >     >
> >  <aa>
> >    <aa>
> >    </aa>
> >  </aa>
> >
> > </aa>

This file is absolutly correct .... In this case, "" is the
default prefix !!! I don't really what you want to say in your
answer.

Secondly, your solution is correct depending on
elementFormQualified (here, must be "unqualified")
in your schema !

Jean-Louis

> -----Message d'origine-----
> De : Eric Ye [mailto:ericye@locus.apache.org]
> Envoyé : vendredi 7 juillet 2000 19:33
> À : xerces-j-dev@xml.apache.org; Oleg Galis
> Objet : Re: Re[2]: Shema: problem with definition recursive data types
>
>
> > -------------------------------------------------------------
> > xml:
> > -------------------------------------------------------------
> > <aa
> >     xmlns='NS'
> >     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> >     xsi:schemaLocation='NS re.xsd'
> >     >
> >  <aa>
> >    <aa>
> >    </aa>
> >  </aa>
> >
> > </aa>
> > --------------------------------------------------------------
>
> This is really not so straightforward. a simple rule of thumb is to use
> prefixes when you are using both schema and namespace.
> The reason is that the parser conforms to the XML namespaces
> spec, which is
> already a W3C recommendation. You sample xml file have a
> namespace bindings
> between empty prefix "" and uri "NS", so every element tag "aa" will be
> resolved to a qualifed name with uri "NS" and localpart "aa", but in your
> content model of comlexType "aaType",  the element "aa" is meant to be a
> locally scope element without a unqualified name "aa", that's why the
> validation complained about the mismatch between the actual
> children and the
> content model.
>
> You can change your xml file to :
>   <re:aa
>      xmlns:re='NS'
>      xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>      xsi:schemaLocation='NS re.xsd'
>      >
>     <aa>
>         <aa>
>         </aa>
>     </aa>
> </re:aa>
>
> the error should be gone.
> _____
>
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>


Re: Re[2]: Shema: problem with definition recursive data types

Posted by Eric Ye <er...@locus.apache.org>.
> -------------------------------------------------------------
> xml:
> -------------------------------------------------------------
> <aa
>     xmlns='NS'
>     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>     xsi:schemaLocation='NS re.xsd'
>     >
>  <aa>
>    <aa>
>    </aa>
>  </aa>
>
> </aa>
> --------------------------------------------------------------

This is really not so straightforward. a simple rule of thumb is to use
prefixes when you are using both schema and namespace.
The reason is that the parser conforms to the XML namespaces spec, which is
already a W3C recommendation. You sample xml file have a namespace bindings
between empty prefix "" and uri "NS", so every element tag "aa" will be
resolved to a qualifed name with uri "NS" and localpart "aa", but in your
content model of comlexType "aaType",  the element "aa" is meant to be a
locally scope element without a unqualified name "aa", that's why the
validation complained about the mismatch between the actual children and the
content model.

You can change your xml file to :
  <re:aa
     xmlns:re='NS'
     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
     xsi:schemaLocation='NS re.xsd'
     >
    <aa>
        <aa>
        </aa>
    </aa>
</re:aa>

the error should be gone.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org




Re[2]: Shema: problem with definition recursive data types

Posted by Oleg Galis <aq...@ibis.odessa.ua>.
Hi Eric,

  I tried to bound schema to a targetNS, but it didn't solve the
problem. I got the same error.

xsd:
---------------------------------------------------------
<?xml version="1.0"?>
<schema 
        xmlns="http://www.w3.org/1999/XMLSchema"
        xmlns:po="NS"
        targetNamespace="NS"
       >

 <element name="aa" type="po:aaType" 
          minOccurs='0' maxOccurs='unbounded'/>

 <complexType name="aaType"> 
   <element name="aa" type="po:aaType" minOccurs="0" maxOccurs='unbounded'/> 
 </complexType> 

</schema>
-------------------------------------------------------------
xml:
-------------------------------------------------------------
<aa
    xmlns='NS'
    xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
    xsi:schemaLocation='NS re.xsd'
    >
 <aa> 
   <aa>
   </aa>
 </aa>

</aa>
--------------------------------------------------------------
May be I have misunderstanding about term 'targetNS'? Any idea or working
samples would be helpful.
Thanks in advance

Oleg Galis

----- Original Message -----
From: "Eric Ye" <er...@locus.apache.org>
To: xerces-j-dev@xml.apache.org, "Oleg Galis" <aq...@ibis.odessa.ua>
Sent: 06.07.2000 20:59
Subject: Re: Schema: problem with definition recursive data types

EY> This is probably because you are using "noTargetNamespaceLocation", try it
EY> with you Schema bound to a targetNS and see if you problem can be solved.
EY> _____


EY> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

EY> ----- Original Message -----
EY> From: "Oleg Galis" <aq...@ibis.odessa.ua>
EY> To: <xe...@xml.apache.org>
EY> Sent: Thursday, July 06, 2000 5:29 AM
EY> Subject: Shema: problem with definition recursive data types


>> How can I describe the recursive date types?
>> I tried something like this:
>>
>> <?xml version="1.0"?>
>> <schema>
>>  <element name="aa" type="aaType"
>>           minOccurs='0' maxOccurs='unbounded'/>
>>  <complexType name="aaType">
>>    <element name="aa" type="aaType" minOccurs="0" maxOccurs='unbounded'/>
>>  </complexType>
>> </schema>
>>
>> for the xml:
>> <aa xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>>     xsi:noNamespaceSchemaLocation='re.xsd'
>>     >
>>  <aa>
>>    <aa>
>>    </aa>
>>  </aa>
>> </aa>
>>
>> I got the next errors:
>> [Error] re.xml:8:8: The content of element type "aa" must match "(aa)*".
>> [Error] re.xml:10:7: The content of element type "aa" must match "(aa)*".
>>
>> Thanks,
>> Oleg Galis
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
>> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>>
>>


EY> ---------------------------------------------------------------------
EY> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
EY> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org



Re: Shema: problem with definition recursive data types

Posted by Eric Ye <er...@locus.apache.org>.
This is probably because you are using "noTargetNamespaceLocation", try it
with you Schema bound to a targetNS and see if you problem can be solved.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Oleg Galis" <aq...@ibis.odessa.ua>
To: <xe...@xml.apache.org>
Sent: Thursday, July 06, 2000 5:29 AM
Subject: Shema: problem with definition recursive data types


> How can I describe the recursive date types?
> I tried something like this:
>
> <?xml version="1.0"?>
> <schema>
>  <element name="aa" type="aaType"
>           minOccurs='0' maxOccurs='unbounded'/>
>  <complexType name="aaType">
>    <element name="aa" type="aaType" minOccurs="0" maxOccurs='unbounded'/>
>  </complexType>
> </schema>
>
> for the xml:
> <aa xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>     xsi:noNamespaceSchemaLocation='re.xsd'
>     >
>  <aa>
>    <aa>
>    </aa>
>  </aa>
> </aa>
>
> I got the next errors:
> [Error] re.xml:8:8: The content of element type "aa" must match "(aa)*".
> [Error] re.xml:10:7: The content of element type "aa" must match "(aa)*".
>
> Thanks,
> Oleg Galis
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>