Re: ERROR With XML Schema

On Jan 23, 2004, at 4:37 AM, Ferrari GIanni wrote:

> [Error] InvoiceXML.xml:1:174: cvc-elt.1: Cannot find the declaration 
> of element 'Invoice'.
> What kind of error is it? What does error mean?
>

The error code is defined in 
http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#cvc-elt (reason 1). 
  Basically, it looked for a definition of Invoice and could not find 
one.
>
> XML Model:
>
>  
>
> <Invoice xsi:schemaLocation="http://your_namespace 
> file://C:\Lavoro\Java\xerces-2_6_0\data\InvoiceXML.xsd" 
> xmlns="http://your_namespace" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> DocType="Delete">
>
>             <DocumentSender>
>
>                         <Company LegalName=""....
>
>
> How I can have a namespace? Can I try one for default?
>

The second entry in the xsi:schemaLocation is not a valid URI since it 
contains backslashes which are prohibited.  I also believe it should 
have three initial slashes.  RFC 2606 
(http://www.rfc-editor.org/rfc/rfc2606.txt) defines classes of URI's 
that can be used for testing and examples, so you could use 
http://ferrari.glanni.example/2004-01-23/invoice as a namespace


> XML Schema:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <xsd:element name="Invoice">
>
> <xsd:complexType>
>
> <xsd:sequence>.........
>
> .........

This is missing a targetNamespace attribute and default namespace 
declaration

> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                targetNamespace="http://your_namespace"
                               xmlns="http://your_namespace">

The targetNamespace defines the namespace in which the definitions 
appear, xmlns causes references without namespace prefixes to be 
interpreted as being links within the same namespace so <element 
ref="Company"/> will be interpreted as a reference to Company element 
in the "http://your_namespace" namespace.

Received on Friday, 23 January 2004 09:24:07 UTC