Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Beginner's Question - Schema Validation Problem

From: noah_mendelsohn@--.---.---
To: "Ayman El-Geneidy" <aelgeneidy@---------.--->
Date: 4/7/2004 7:21:00 AM
It would be helpful to see a bit more of your schema.  Presuming that:

<xsd:element name="qos" maxOccurs="1">

is indeed an immediate child (not grandchild) of <xsd:schema>, then your 
schema is not correctly formed.  There are roughly two forms of the 
<xsd:element> construction, plus a common shorthand that puts them 
togther:

<xsd:schema>
        <!-- global element declaration: maxoccurs not allowed here -->
        <xsd:element name="x">
                ...definition of "x"..
        </xsd:element>
</xsd:schema>

This defines x, but doesn't use it.  Now let's use it:

<xsd:schema>
        <!-- global element declaration: maxoccurs not allowed here -->
        <xsd:element name="x">
                ...definition of "x"..
        </xsd:element>

        <xsd:complexType name="t">
                <!-- use of element, maxOccurs allowed -->
                <xsd:element ref="x" maxOccurs="3">
        </xsd:complexType name="t">
</xsd:schema>

There is a very common shorthand the defines an element and uses it all in 
one step.  The result is a so-called locally scoped element, that is 
usable only right where you define it (more or less).

<xsd:schema>
        <!-- maxoccurs not allowed here -->
        <xsd:element name="x">
                <xsd:complexType name="t">
                        <xsd:element name="myLocal" maxOccurs="3">
                                ...definition of myLocal...
                        </xsd:element>
                </xsd:complexType name="t">
        </xsd:element>
</xsd:schema>

In the above, myLocal is both defined and used.  In this case, you can 
supply maxOccurs, >>because that is controlling the use<<.  It makes no 
sense to have maxOccurs on a global declaration as in your example.   A 
properly written schema processor should have rejected your element 
declaration as illegal for that reason.  It's possible that, seeing 
maxOccurs, the processor went into the part of the logic for dealing with 
element uses and said "ok, where's the definition".  In fact, it's not 
legal or sensible to have a use as an immediate child of <xsd:schema>.   I 
hope I've understood your problem, and that this helps.

Another common source of such problems is misuse of namespaces, but I 
don't see such errors in your example.

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------








"Ayman El-Geneidy" <aelgeneidy@i...>
Sent by: xmlschema-dev-request@w...
04/07/04 10:15 AM

 
        To:     <xmlschema-dev@w...>
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        Beginner's Question - Schema Validation Problem


I am trying to validate a schema and getting the error "Element 'qos' is 
used but not declared in DTD/Schema". 'qos' is my root element. I have 
looked at several books and at similar messages on this list with no luck.
 
This is how I am declaring it in my XML file:
 
<qos
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="qos.xsd"
     service_key="d5921160-3e16-11d5-98bf-002035229c64">
    ...............
 
</qos> 
 
And this is how it is declared in the schema file ('qos.xsd' located at 
the same directory as the XML file):
 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    .............................
 
     <xsd:element name="qos" maxOccurs="1">
          <xsd:complexType>
               <xsd:element ref="performance" minOccurs="0" 
maxOccurs="1"/>
           <xsd:element ref="information" minOccurs="0" maxOccurs="1"/>
           <xsd:element ref="configuration" minOccurs="0" maxOccurs="1"/>
           <xsd:element ref="security" minOccurs="0" maxOccurs="1"/> 
          </xsd:complexType>
      <xsd:attribute ref="service_key" use="required"/>
 </xsd:element>
 
</xsd:schema>
I have tried qualifying the path of the xsd file as it was explained in a 
previous message and got the same result. I am using the XRay editor from 
Architag.
 
I would appreciate any help and guidance.
 
Thank you.
 
Ayman 


From aelgeneidy@i...  Wed Apr  7 12:12:51 2004
Return-Path: <aelgeneidy@i...>
X-Original-To: xmlschema-dev@l...
Delivered-To: xml


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent