Cannot validate a ".xsd" file (Xerces 2.7.0 C++ on Windows XP)

Discussion in 'XML' started by ciaran.mchale@iona.com, Nov 16, 2005.

  1. Guest

    Hi folks,

    I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am
    using it to help me get up to speed with XML and XML Schema. So please
    excuse me if this is a "novice" question.

    In the samples/data directory, I ran the following command for all the
    files:

    DOMPrint -n -s -f -v=always <filename>

    The above command worked for the two ".xml" files. So far, so good.

    The above command failed for the ".dtd" files. This is fine because a
    ".dtd" file is *not* in XML format.

    What confuses me is that the above command failed for the ".xsd" file.
    The file is "well formed", as I can see if I run DOMPrint on it
    *without* the schema validation options. However, when I use the schema
    validation options then DOMPrint complains about 128 "validity" errors.

    This surprises me because I was expecting to be able to use a
    validating
    parser (such as Xerces) to validate schemas as well as schema
    instances.

    Am I doing something wrong? Is there a mistake in the ".xsd" document?
    Is there a bug in Xerces?

    I am including the ".xsd" file below for people who do not have Xerces
    C++.

    ----start of .xsd file----
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

    <xs:import namespace="http://www.w3.org/XML/1998/namespace">
    <xs:annotation>
    <xs:documentation>
    The schemaLocation of the relevant file is
    "http://www.w3.org/2001/xml.xsd"; however,
    we don't want to assume people are always
    connected to the 'net when playing with this file.
    </xs:documentation>
    </xs:annotation>
    </xs:import>

    <xs:element name="personnel">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="person" minOccurs='1' maxOccurs='unbounded'/>
    </xs:sequence>
    </xs:complexType>

    <xs:unique name="unique1">
    <xs:selector xpath="person"/>
    <xs:field xpath="name/given"/>
    <xs:field xpath="name/family"/>
    </xs:unique>
    <xs:key name='empid'>
    <xs:selector xpath="person"/>
    <xs:field xpath="@id"/>
    </xs:key>
    <xs:keyref name="keyref1" refer='empid'>
    <xs:selector xpath="person"/>
    <xs:field xpath="link/@manager"/>
    </xs:keyref>

    </xs:element>

    <xs:element name="person">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="name"/>
    <xs:element ref="email" minOccurs='0' maxOccurs='unbounded'/>
    <xs:element ref="url" minOccurs='0' maxOccurs='unbounded'/>
    <xs:element ref="link" minOccurs='0' maxOccurs='1'/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use='required'/>
    <xs:attribute name="note" type="xs:string"/>
    <xs:attribute name="contr" default="false">
    <xs:simpleType>
    <xs:restriction base = "xs:string">
    <xs:enumeration value="true"/>
    <xs:enumeration value="false"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="salary" type="xs:integer"/>
    <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace"
    processContents="skip"/>
    </xs:complexType>
    </xs:element>

    <xs:element name="name">
    <xs:complexType>
    <xs:all>
    <xs:element ref="family"/>
    <xs:element ref="given"/>
    </xs:all>
    <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace"
    processContents="skip"/>
    </xs:complexType>
    </xs:element>

    <xs:element name="family">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base='xs:string'>
    <xs:anyAttribute
    namespace="http://www.w3.org/XML/1998/namespace"
    processContents="skip"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>

    <xs:element name="given" >
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base='xs:string'>
    <xs:anyAttribute
    namespace="http://www.w3.org/XML/1998/namespace"
    processContents="skip"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>

    <xs:element name="email" type='xs:string'/>

    <xs:element name="url">
    <xs:complexType>
    <xs:attribute name="href" type="xs:string" default="http://"/>
    </xs:complexType>
    </xs:element>

    <xs:element name="link">
    <xs:complexType>
    <xs:attribute name="manager" type="xs:IDREF"/>
    <xs:attribute name="subordinates" type="xs:IDREFS"/>
    </xs:complexType>
    </xs:element>

    <xs:notation name='gif' public='-//APP/Photoshop/4.0'
    system='photoshop.exe'/>

    </xs:schema>
    ----end of .xsd file----

    Regards,
    Ciaran.
    , Nov 16, 2005
    #1
    1. Advertising

  2. wrote:
    > Hi folks,
    >
    > [cut]



    You should not post all your xml xsd here,

    just look at the message Xalan gives you..
    the message will help you locate the problem.
    Tjerk Wolterink, Nov 16, 2005
    #2
    1. Advertising

  3. Ian Pilcher Guest

    FWIW, I have never gotten the Java version of Xerces (included in the
    Sun JRE) to validate a schema.

    --
    ========================================================================
    Ian Pilcher
    ========================================================================
    Ian Pilcher, Nov 16, 2005
    #3
  4. Peter Flynn Guest

    wrote:

    > Hi folks,
    >
    > I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am
    > using it to help me get up to speed with XML and XML Schema. So please
    > excuse me if this is a "novice" question.
    >
    > In the samples/data directory, I ran the following command for all the
    > files:
    >
    > DOMPrint -n -s -f -v=always <filename>
    >
    > The above command worked for the two ".xml" files. So far, so good.
    >
    > The above command failed for the ".dtd" files. This is fine because a
    > ".dtd" file is *not* in XML format.


    Strictly speaking, a DTD *is* in XML format -- but it uses XML
    Declaration Syntax, not XML Document Syntax. A DTD can't therefore
    be validated in the same way as an XML document, but it can be checked
    for syntax simply by creating a dummy document instance and running
    that through software containing a validating parser.

    > What confuses me is that the above command failed for the ".xsd" file.
    > The file is "well formed", as I can see if I run DOMPrint on it
    > *without* the schema validation options. However, when I use the
    > schema validation options then DOMPrint complains about 128 "validity"
    > errors.
    >
    > This surprises me because I was expecting to be able to use a
    > validating parser (such as Xerces) to validate schemas as well
    > as schema instances.
    >
    > Am I doing something wrong? Is there a mistake in the ".xsd" document?
    > Is there a bug in Xerces?


    I can't speak for Xerces, but the XSD file you posted validates with
    the DTD for Schemas.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
    Peter Flynn, Nov 16, 2005
    #4
    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.
Similar Threads
  1. Jens M. Felderhoff

    Re: validate xml against xsd, xerces

    Jens M. Felderhoff, Jul 11, 2003, in forum: XML
    Replies:
    0
    Views:
    2,494
    Jens M. Felderhoff
    Jul 11, 2003
  2. Replies:
    1
    Views:
    854
    Martin Honnen
    Jan 14, 2004
  3. -saarland.de
    Replies:
    8
    Views:
    1,767
    naivexml
    May 16, 2011
  4. heiko
    Replies:
    0
    Views:
    1,050
    heiko
    Oct 1, 2005
  5. naivexml
    Replies:
    0
    Views:
    2,459
    naivexml
    May 16, 2011
Loading...

Share This Page