xml validation ... help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ian.rutgers@gmail.com

    xml validation ... help!

    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

  • Priscilla Walmsley

    #2
    Re: xml validation ... help!

    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:ot="http://www.otima.ca"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocat ion="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

    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

    Comment

    • Ian Rutgers

      #3
      Re: xml validation ... help!



      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!

      Comment

      • Priscilla Walmsley

        #4
        Re: xml validation ... help!

        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 attributeFormDe fault to "unqualifie d" 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

        ----------------------------------

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Ian Rutgers

          #5
          Re: xml validation ... help!

          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!

          Comment

          Working...