Women in Technology

Hear us Roar



Article:
  XML Document Validation with an XML Schema
Subject:   Error coming
Date:   2007-01-09 14:15:25
From:   javanew
Hello Deepak, when I try to use catalog.xml and catalog.xsd, i get the following errors. Can you please give me some idea on why this error could be coming:


org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="catalog"> <xsd:complexType> <xsd:sequence> <xsd:element ref="journal" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="title" type="xsd:string"/> <xsd:attribute name="publisher" type="xsd:string"/> </xsd:complexType> </xsd:element> <xsd:element name="journal"> <xsd:complexType> <xsd:sequence> <xsd:element ref="article" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="date" type="xsd:string"/> </xsd:complexType> </xsd:element> <xsd:element name="article"> <xsd:complexType> <xsd:sequence> <xsd:element name="title" type="xsd:string"/> <xsd:element ref="author" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="author" type="xsd:string"/></xsd:schema>', because
1) could not find the document;
2) the document could not be read;
3) the root element of the document is not <xsd:schema>.

Full Threads Newest First

Showing messages 1 through 7 of 7.

  • Error coming
    2007-01-09 14:57:47  Deepak Vohra | [View]

    Is the schema specified in the XML document?
    Please specify schema in XML document withn noNamespaceSchemaLocation attribute.
    • Error coming
      2007-01-09 15:06:15  javanew [View]

      Thanks for the quick reply Deepak. I will try what you advised.
      Actually, I was reading xml and xsd from file system and passing them as String. Now I am passing them as InputStream. Now I am getting these errors. Any idea?

      cvc-elt.1: Cannot find the declaration of element 'catalog'.
      cvc-elt.1: Cannot find the declaration of element 'journal'.
      cvc-elt.1: Cannot find the declaration of element 'article'.
      cvc-elt.1: Cannot find the declaration of element 'title'.
      cvc-elt.1: Cannot find the declaration of element 'author'.
      cvc-elt.1: Cannot find the declaration of element 'journal'.
      cvc-elt.1: Cannot find the declaration of element 'article'.
      cvc-elt.1: Cannot find the declaration of element 'title'.
      cvc-elt.1: Cannot find the declaration of element 'author'.
      XML Document has Error:true cvc-elt.1: Cannot find the declaration of element 'author'.
    • Error coming
      2007-01-09 15:08:32  javanew [View]

      i was not specifying noNamespaceSchemaLocation attribute. My xml looked like this:
      <?xml version="1.0" encoding="utf-8" ?>
      <catalog xmlns="catalog.xsd">
      <journal date="April 2004">
      <article>
      <title>Declarative Programming in Java</title>
      <author>Narayanan Jayaratchagan</author>
      </article>
      </journal>
      <journal date="January 2004">
      <article>
      <title>Data Binding with XMLBeans</title>
      <author>Daniel Steinberg</author>
      </article>
      </journal>
      </catalog>
      • Error coming
        2007-01-09 15:13:04  Deepak Vohra | [View]

        Please modify the root element.
        <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://c:/Schemas/OracleCatalog.xsd">
        • Error coming
          2007-01-09 15:26:03  javanew [View]

          Both xml and xsd are WSAD workspace, so I cannot give file path. There are in the same location. So, is there any way I can specify the path?
          <?xml version="1.0" encoding="utf-8" ?>
          <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="catalog.xsd" >
          <journal date="April 2004">
          <article>
          <title>Declarative Programming in Java</title>
          <author>Narayanan Jayaratchagan</author>
          </article>
          </journal>
          <journal date="January 2004">
          <article>
          <title>Data Binding with XMLBeans</title>
          <author>Daniel Steinberg</author>
          </article>
          </journal>
          </catalog>
      • Error coming
        2007-01-09 15:13:51  Deepak Vohra | [View]

        Please modify the root element.
        <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://c:/Schemas/catalog.xsd">
    • Error coming
      2007-01-09 15:19:41  javanew [View]

      Now I specified specifying noNamespaceSchemaLocation attribute. Now my xml looks like this. Both xml and xsd are WSAD workspace, so I cannot give file path. There are in the same location. So, do i need to mention any relative path?
      <?xml version="1.0" encoding="utf-8" ?>
      <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="catalog.xsd" >
      <journal date="April 2004">
      <article>
      <title>Declarative Programming in Java</title>
      <author>Narayanan Jayaratchagan</author>
      </article>
      </journal>
      <journal date="January 2004">
      <article>
      <title>Data Binding with XMLBeans</title>
      <author>Daniel Steinberg</author>
      </article>
      </journal>
      </catalog>