xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy_C...@tertio.com
Subject Re: Problems finding schema definition
Date Mon, 11 Sep 2000 14:25:34 GMT
Thanks for the help.  I managed to see where I was going wrong in the
schema definition in the end.

Andy






"Eric Ye" <ericye@locus.apache.org> on 07/09/2000 18:47:57

Please respond to general@xml.apache.org

To:   <general@xml.apache.org>
cc:
Subject:  Re: Problems finding schema definition



We could do a better job for the error messages.

 #0 should be the name of an anonymous complex type defined in one of the
element decls that appears first in you schema file.  You can ignore the
line # and column # when you see a Schema error.

The error message means you have a complex type decl like this
<complexType>...</complexType> that contains no particle children in its
content, elements, groups, sequences and choices are categorized as
particles.

However, although the spec didn't see it explicity, we found something in
the primer about complexType, that says if no "content" attribute is
specified, the defaut value is "elementOnly",  and that is how we
implemented it.

So in your case, the solution is to add "content='textOnly'" to the
anonymous type kicked out by the parser.

If you can post the actual xsd file, I'd be more than happy to help take a
look.
_____


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

----- Original Message -----
From: <Andy_Carr@tertio.com>
To: <general@xml.apache.org>
Sent: Thursday, September 07, 2000 6:35 AM
Subject: Re: Problems finding schema definition


> Thanks for the replies.  Andy, I took your thorough advice but am getting
> another error.   The top of my XML looks like:
>
> line 1:  <?xml version="1.0" ?>
> line 2:
> line 3:  <GMI xmlns='NS'
> line 4:      xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> line 5:      xsi:schemaLocation='NS GMI.xsd'>
>
> and the error I get is:
>
>     java -cp
C:\XML\xerces-1_1_3\xerces.jar;C:\XML\xerces-1_1_3\xercesSamples.jar
dom.DOMCount -v file:///H:/Andy/Programs/Web/XML/GMI.xml
>     [Error] GMIwithSchema.xml:5:38:Schema error: complexType '#0' with a
elementOnly or mixed content need to have at least one particle child.
>
> Some questions:
>
> Is the error in my XML file (as suggested by the fact that the error is
on
line 5 of my XML file,) or my XSD file (as suggested by the fact that it is
>  a "Schema error")?
> I have no '#0' in my schema file so how can it cause an error?
> What is a particle child?  I have searched various XML resources for this
but with no luck.
> Is there a list of parser error messages somewhere and an explanation of
what they mean?
>
> Again, any assistance is appreciated.
>
> thanks,
>
> Andy
>
>
>
>
>
>
> Andy Clark <andyc@apache.org> on 06/09/2000 18:38:50
>
> Please respond to general@xml.apache.org
>
> To:   general@xml.apache.org
> cc:
> Subject:  Re: Problems finding schema definition
>
>
> Andy_Carr@tertio.com wrote:
> >     <GMI xmlns="file:///H:/Andy/Programs/Web/XML/GMI.xsd">
> > [...]
> >     <schema xmlns="http://www.w3.org/1999/XMLSchema">
>
> Okay, there are two problems with your XML and XSD files.
>
> 1) Your XML file is in a namespace but your XML Schema grammar
> doesn't specify a target namespace. If your document instance
> is in a namespace, then your grammar has to specify a target
> namespace and the two must match! Here's an example of a
> grammar:
>
>   <!-- grammar.xsd -->
>   <schema xmlns='http://www.w3.org/1999/XMLSchema'
>           targetNamespace='NS'>
>    <element name='root'>
>     <complexType>
>      <element ref='sub'/> <!-- WRONG -->
>     </complexType>
>    </element>
>    <element name='sub'/>
>   </schema>
>
> However, this leads to a common problem. When you specify a
> target namespace in your XML Schema document, then all of the
> references to element types and attribute groups are QNames!
> What does this mean? This means that my example is wrong.
>
> The Schema processor will look at "sub" as a qualified name
> so it thinks that you are referring to an element declared
> in the default namespace. And since I have bound the default
> namespace to "http://www.w3.org/1999/XMLSchema", it will look
> in *that* grammar for an element called "sub".
>
> So how do we avoid this problem? Well, we have to fully
> qualify the "sub" element reference which, in turn, means
> that we need to bind that namespace. Here's the fix:
>
>   <!-- grammar.xsd -->
>   <schema xmlns='http://www.w3.org/1999/XMLSchema'
>           xmlns:a='NS' targetNamespace='NS'>
>    <element name='root'>
>     <complexType>
>      <element ref='a:sub'/> <!-- RIGHT -->
>     </complexType>
>    </element>
>    <element name='sub'/>
>   </schema>
>
> Notice that the prefix "a" is bound to *exactly* the same
> namespace string as is specified in the targetNamespace
> attribute!
>
> Now on to your second problem...
>
> 2) The namespace binding is not the way in which that you
> tell the XML Schema processor to find your Schema grammar. The
> namespace is only a means of uniquely qualifying a namespace.
> So the following is incorrect.
>
>   <!-- document.xml -->
>   <root xmlns='NS'> <!-- WRONG -->
>    <sub/>
>   </root>
>
> First you have to bind the XML Schema instance document
> namespace and then use the special attribute "schemaLocation"
> in order to locate your grammar. (The specification says
> that this is only a "hint" but who are they kidding...) The
> value of schemaLocation is a set of tuples: each tuple is a
> pair of namespace and grammar location. For example:
>
>   <!-- document.xml -->
>   <root xmlns='NS'
>         xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>         xsi:schemaLocation='NS grammar.xsd'>
>    <sub/>
>   </root>
>
> Also, you probably shouldn't use 'file:///.../GMI.xsd' as
> your namespace binding; it's really the location of your
> grammar and should only be used in the xsi:schemaLocation
> or xsi:noNamespaceSchemaLocation attribute.
>
> Some disclaimers:
>
> a) Schema is confusing so if I've made any mistakes in the
>    above examples, someone please correct me.
> b) I really shouldn't be using "NS" as my namespace binding.
>    I'm only using it to simplify my example; otherwise
>    *everything* is a URI and confuses the person trying to
>    figure out what's related to what.
>
> --
> Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>
>


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org








Mime
View raw message