You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Scott Cocks <sc...@nortelnetworks.com> on 2001/02/20 21:45:04 UTC

schemas; problem migrating from 1.2.3 to 1.3.0

Hi, I had previously been using Xerces 1.2.3 which supported the WD schema
specs, but now I've moved to Xerces 1.3.0 (schema CR).  I am having problems
validating a document now.  Here is the info:
- using Xerces 1.3.0 on Ultra10 running Solaris 2.6
- the following features are set in my parser:
      parser.setFeature("http://xml.org/sax/features/validation", true);
      parser.setFeature("http://xml.org/sax/features/namespaces", true);
      parser.setFeature("http://apache.org/xml/features/validation/schema",
true);
 
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
false);

Here is the XSD file I am using (tutorial2.xsd):
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
    <xsd:simpleType name="ISBNType">
        <xsd:restriction base="string">
            <xsd:pattern value="\d{5}-\d{5}-\d{5}"/>
            <xsd:pattern value="\d{1}-\d{3}-\d{5}-\d{1}"/>
            <xsd:pattern value="\d{1}-\d{2}-\d{6}-\d{1}"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:element name="BookCatalogue">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Book" minOccurs="0"
maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="Title" type="xsd:string"
minOccurs="1" maxOccurs="1"/>
                            <xsd:element name="Author" type="xsd:string"
minOccurs="1" maxOccurs="1"/>
                            <xsd:element name="Date" type="xsd:year"
minOccurs="1" maxOccurs="1"/>
                            <xsd:element name="ISBN" type="ISBNType"
minOccurs="1" maxOccurs="1"/>
                            <xsd:element name="Publisher" type="xsd:string"
minOccurs="1" maxOccurs="1"/>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

...and here is the XML instance (tutorial2.xml):
<?xml version="1.0" encoding="UTF-8"?>
<BookCatalogue xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="tutorial2.xsd">
        <Book>
                <Title>My Life and Times</Title>
                <Author>Paul McCartney</Author>
                <Date>1998</Date>
                <ISBN>94303-12021-43892</ISBN>
                <Publisher>McMillin Publishing</Publisher>
        </Book>
        <Book>
                <Title>Illusions The Adventures of a Reluctant
Messiah</Title>
                <Author>Richard Bach</Author>
                <Date>1977</Date>
                <ISBN>0-440-34319-4</ISBN>
                <Publisher>Dell Publishing Co.</Publisher>
        </Book>
        <Book>
                <Title>The First and Last Freedom</Title>
                <Author>J. Krishnamurti</Author>
                <Date>1954</Date>
                <ISBN>0-06-064831-7</ISBN>
                <Publisher>Harper &amp; Row</Publisher>
        </Book>
    </BookCatalogue>

...this is the errors I get:
[Error] tutorial2.xml:2:119: Element type "BookCatalogue" must be declared.
[Error] tutorial2.xml:2:119: Attribute "xsi:noNamespaceSchemaLocation" must
be declared for element type "BookCatalogue".
[Error] tutorial2.xml:3:15: Element type "Book" must be declared.
[Error] tutorial2.xml:4:24: Element type "Title" must be declared.
[Error] tutorial2.xml:5:25: Element type "Author" must be declared.
[Error] tutorial2.xml:6:23: Element type "Date" must be declared.
[Error] tutorial2.xml:7:23: Element type "ISBN" must be declared.
[Error] tutorial2.xml:8:28: Element type "Publisher" must be declared.
[Error] tutorial2.xml:10:15: Element type "Book" must be declared.
[Error] tutorial2.xml:11:24: Element type "Title" must be declared.
[Error] tutorial2.xml:12:25: Element type "Author" must be declared.
[Error] tutorial2.xml:13:23: Element type "Date" must be declared.
[Error] tutorial2.xml:14:23: Element type "ISBN" must be declared.
[Error] tutorial2.xml:15:28: Element type "Publisher" must be declared.
[Error] tutorial2.xml:17:15: Element type "Book" must be declared.
[Error] tutorial2.xml:18:24: Element type "Title" must be declared.
[Error] tutorial2.xml:19:25: Element type "Author" must be declared.
[Error] tutorial2.xml:20:23: Element type "Date" must be declared.
[Error] tutorial2.xml:21:23: Element type "ISBN" must be declared.
[Error] tutorial2.xml:22:28: Element type "Publisher" must be declared.

What am I doing wrong?

thanks,
-scott

Re: schemas; problem migrating from 1.2.3 to 1.3.0

Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Scott,
Check your classpath. Seem like you still using 1.2.3..

> Scott Cocks wrote:
> 
> Hi, I had previously been using Xerces 1.2.3 which supported the WD
> schema specs, but now I've moved to Xerces 1.3.0 (schema CR).  I am
> having problems validating a document now.  Here is the info:
> 
> - using Xerces 1.3.0 on Ultra10 running Solaris 2.6
> - the following features are set in my parser:
>       parser.setFeature("http://xml.org/sax/features/validation",
> true);
>       parser.setFeature("http://xml.org/sax/features/namespaces",
> true);
> 
> parser.setFeature("http://apache.org/xml/features/validation/schema",
> true);
> 
> parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
> false);
> 
> Here is the XSD file I am using (tutorial2.xsd):
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
>     <xsd:simpleType name="ISBNType">
>         <xsd:restriction base="string">
>             <xsd:pattern value="\d{5}-\d{5}-\d{5}"/>
>             <xsd:pattern value="\d{1}-\d{3}-\d{5}-\d{1}"/>
>             <xsd:pattern value="\d{1}-\d{2}-\d{6}-\d{1}"/>
>         </xsd:restriction>
>     </xsd:simpleType>
>     <xsd:element name="BookCatalogue">
>         <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:element name="Book" minOccurs="0"
> maxOccurs="unbounded">
>                     <xsd:complexType>
>                         <xsd:sequence>
>                             <xsd:element name="Title"
> type="xsd:string" minOccurs="1" maxOccurs="1"/>
>                             <xsd:element name="Author"
> type="xsd:string" minOccurs="1" maxOccurs="1"/>
>                             <xsd:element name="Date" type="xsd:year"
> minOccurs="1" maxOccurs="1"/>
>                             <xsd:element name="ISBN" type="ISBNType"
> minOccurs="1" maxOccurs="1"/>
>                             <xsd:element name="Publisher"
> type="xsd:string" minOccurs="1" maxOccurs="1"/>
>                         </xsd:sequence>
>                     </xsd:complexType>
>                 </xsd:element>
>             </xsd:sequence>
>         </xsd:complexType>
>     </xsd:element>
> </xsd:schema>
> 
> ...and here is the XML instance (tutorial2.xml):
> <?xml version="1.0" encoding="UTF-8"?>
> <BookCatalogue
> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="tutorial2.xsd">
>         <Book>
>                 <Title>My Life and Times</Title>
>                 <Author>Paul McCartney</Author>
>                 <Date>1998</Date>
>                 <ISBN>94303-12021-43892</ISBN>
>                 <Publisher>McMillin Publishing</Publisher>
>         </Book>
>         <Book>
>                 <Title>Illusions The Adventures of a Reluctant
> Messiah</Title>
>                 <Author>Richard Bach</Author>
>                 <Date>1977</Date>
>                 <ISBN>0-440-34319-4</ISBN>
>                 <Publisher>Dell Publishing Co.</Publisher>
>         </Book>
>         <Book>
>                 <Title>The First and Last Freedom</Title>
>                 <Author>J. Krishnamurti</Author>
>                 <Date>1954</Date>
>                 <ISBN>0-06-064831-7</ISBN>
>                 <Publisher>Harper &amp; Row</Publisher>
>         </Book>
>     </BookCatalogue>
> 
> ...this is the errors I get:
> [Error] tutorial2.xml:2:119: Element type "BookCatalogue" must be
> declared.
> [Error] tutorial2.xml:2:119: Attribute "xsi:noNamespaceSchemaLocation"
> must be declared for element type "BookCatalogue".
> 
> [Error] tutorial2.xml:3:15: Element type "Book" must be declared.
> [Error] tutorial2.xml:4:24: Element type "Title" must be declared.
> [Error] tutorial2.xml:5:25: Element type "Author" must be declared.
> [Error] tutorial2.xml:6:23: Element type "Date" must be declared.
> [Error] tutorial2.xml:7:23: Element type "ISBN" must be declared.
> [Error] tutorial2.xml:8:28: Element type "Publisher" must be declared.
> 
> [Error] tutorial2.xml:10:15: Element type "Book" must be declared.
> [Error] tutorial2.xml:11:24: Element type "Title" must be declared.
> [Error] tutorial2.xml:12:25: Element type "Author" must be declared.
> [Error] tutorial2.xml:13:23: Element type "Date" must be declared.
> [Error] tutorial2.xml:14:23: Element type "ISBN" must be declared.
> [Error] tutorial2.xml:15:28: Element type "Publisher" must be
> declared.
> [Error] tutorial2.xml:17:15: Element type "Book" must be declared.
> [Error] tutorial2.xml:18:24: Element type "Title" must be declared.
> [Error] tutorial2.xml:19:25: Element type "Author" must be declared.
> [Error] tutorial2.xml:20:23: Element type "Date" must be declared.
> [Error] tutorial2.xml:21:23: Element type "ISBN" must be declared.
> [Error] tutorial2.xml:22:28: Element type "Publisher" must be
> declared.
> 
> What am I doing wrong?
> 
> thanks,
> -scott