xml validation ... help!

Discussion in 'XML' started by ian.rutgers@gmail.com, Jan 20, 2005.

  1. Guest

    In validating http://www.otima.ca/XML/auto.xml (auto.xsd) I get the
    following error: "Attribute 'make' should be qualified[XML]" If you
    look at my schema i do havit it qualified, so I don't understand!
    Please, someone, set me right.

    Thank you,

    Ian
     
    , Jan 20, 2005
    #1
    1. Advertising

  2. Hi Ian,

    Default namespace declarations do not apply to attributes. So, when you
    use the "make" attribute in your instance, and don't prefix it, it is
    not in any namespace.

    To make it work, you need to assign a prefix to the namespace and prefix
    all the attribute names. For example,

    <dealership xmlns:eek:t="http://www.otima.ca"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.otima.ca auto.xsd">
    <ot:auto ot:make="Sienna" ot:model="XLE Limited" ot:year="2004"> ...

    I usually recommend against qualified attributes in cases like this
    because adding all the prefixes does not really add any information and
    clutters up the document.


    Hope that helps,
    Priscilla

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Priscilla Walmsley, Jan 20, 2005
    #2
    1. Advertising

  3. Ian Rutgers Guest

    Hi Priscilla,

    Thank you for taking a look at my files. (Alway appreciate an expert's
    advice). I have two follow up quesitons for you.
    1. I removed all the prefixes (after backing up the files) from both the
    xml and the xsd files and tried to validate the xml file ... told me it
    didn't know about most of the elements ... so I put everything back and
    when I re-validated ... the file validated?! Would you please take
    another look and explain why it is right now (maybe I didn't back
    everything up the same?)
    2. You're recommendation is to remove all prefixes in this instance.
    Would you please clarify in which file(s) to remove the prefixes and
    that "all" prefixes should be removed.


    Your humble student ...

    Ian

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Ian Rutgers, Jan 20, 2005
    #3
  4. Hi,

    Are you sure it's validating as it is now? Your schema is not
    well-formed XML because it has two default namespace declarations.

    Declaring the attributes as unqualified is not a matter of removing
    prefixes from the schema. What you need to do instead is:

    1. change attributeFormDefault to "unqualified" at the top of your
    schema (or leave it off completely - unqualified is the default).

    2. make your attribute declarations local, as in:

    <xs:element name="auto">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="interior"/>
    <xs:element ref="exterior"/>
    <xs:element ref="mechanical"/>
    </xs:sequence>
    <xs:attribute name="make" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="year" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>

    Then, you will not have to prefix the attributes in the instance
    document, and it will validate.

    Hope that helps!
    Priscilla
    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Priscilla Walmsley, Jan 24, 2005
    #4
  5. Ian Rutgers Guest

    That's perfect! Thanks for the details!

    Thank you,

    Ian

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Ian Rutgers, Jan 24, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page