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

simpleType, schemas, patterns

> Hi, I just started dabbling with XML Schemas and Xerces, and I have a few
> questions.  First of all, some important info:
> - using Xerces 1.2.3 on Ultra10 running Solaris 2.6
> - the following features are set:
>       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);
> Attached is the full code for my parser class:
>  <<APIDOMParser.java>> 
> 
> (1) I snagged a sample from a tutorial and tried it out.  See
> tutorial2.xsd and tutorial2.xml attached to this message.
>  <<tutorial2.xml>>  <<tutorial2.xsd>> 
> Note that the schema namespace used is
> http://www.w3.org/2000/10/XMLSchema.  I get the following errors:
> [Error] tutorial2.xml:2:119: Element type "BookCatalogue" must be
> declared.
> [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.
> 
> Is the http://www.w3.org/2000/10/XMLSchema namespace not supported?
> 
> (2) See the attached files tutorial1999.xml and tutorial1999.xsd:
>  <<tutorial1999.xml>>  <<tutorial1999.xsd>> 
> These are the same files as before, except that I have changed the schema
> namespace to http://www.w3.org/1999/XMLSchema.  Now it works, but it seems
> that simpleType needs to be implemented differently under this older
> schema.  Is this correct?  I commented out the original definition of the
> ISBNType simpleType and replaced it with one that works.  Now I get the
> following errors:
> [Error] tutorial.xml:14:44: Datatype error: In element 'ISBN' : Value
> '0-440-34319-4' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
> [Error] tutorial.xml:21:44: Datatype error: In element 'ISBN' : Value
> '0-06-064831-7' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
> 
> If I change the order of the pattern definitions, it always sticks with
> the last one.  So, instead of OR-ing all the patterns together, it is
> simply using the last one.  Is this the way it is supposed to work?  Am I
> completely out to lunch?
> 
> -scott
> 
> 
> 

Re: simpleType, schemas, patterns

Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Scott, 

Please, use xerces-j-user mailing list for these kind of questions.

> Attached is the full code for my parser class:
> <<APIDOMParser.java>>
I could not open attachment, however I ran tutorial2.xml with
sax.SAXCount -v and it works fine.

> Is the http://www.w3.org/2000/10/XMLSchema namespace not supported?
It is supported. And you must use this NS to make you schema work (with
Xerces 1.3.0).

> (2) See the attached files tutorial1999.xml and tutorial1999.xsd:
> <<tutorial1999.xml>> <<tutorial1999.xsd>>
> These are the same files as before, except that I have changed the
> schema namespace to http://www.w3.org/1999/XMLSchema.  Now it works,

It means, you have an older vs of xerces in your path. It is not suppose
to work.. ;-)

 
> [Error] tutorial.xml:14:44: Datatype error: In element 'ISBN' : Value
> '0-440-34319-4' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
> 
> [Error] tutorial.xml:21:44: Datatype error: In element 'ISBN' : Value
> '0-06-064831-7' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
Hmm.. It might be a bug but I need to clarify it with schema specs. 
As it implemented in Xerces - you are only allowed to have one pattern
definition per <simpleType>. If it is a bug I will fix it. In a mean
time - you could used <union> datatype to achieve the same.

Elena

Re: simpleType, schemas, patterns

Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Scott,

> [Error] tutorial.xml:14:44: Datatype error: In element 'ISBN' : Value
> '0-440-34319-4' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
> 
> [Error] tutorial.xml:21:44: Datatype error: In element 'ISBN' : Value
> '0-06-064831-7' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
Yep, it is a bug, according to [datatypes] 5.2.4 pattern.
It has been fixed in CVS.

Thanks for finding it :).
Elena.

Re: simpleType, schemas, patterns

Posted by Mathias Laguérie <ml...@softeam.fr>.
I had the same problem with xerces 1.0.3. I could resolve that when I
installed the version 1.3.0 of Xerces.
Mathias

Scott Cocks a �crit :

>
>
> Hi, I just started dabbling with XML Schemas and Xerces, and I have a
> few questions.  First of all, some important info:
>
> - using Xerces 1.2.3 on Ultra10 running Solaris 2.6
> - the following features are set:
>       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);
> Attached is the full code for my parser class:
> <<APIDOMParser.java>>
>
> (1) I snagged a sample from a tutorial and tried it out.  See
> tutorial2.xsd and tutorial2.xml attached to this message.
> <<tutorial2.xml>> <<tutorial2.xsd>>
> Note that the schema namespace used is
> http://www.w3.org/2000/10/XMLSchema.  I get the following errors:
> [Error] tutorial2.xml:2:119: Element type "BookCatalogue" must be
> declared.
> [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.
>
> Is the http://www.w3.org/2000/10/XMLSchema namespace not supported?
>
> (2) See the attached files tutorial1999.xml and tutorial1999.xsd:
> <<tutorial1999.xml>> <<tutorial1999.xsd>>
> These are the same files as before, except that I have changed the
> schema namespace to http://www.w3.org/1999/XMLSchema.  Now it works,
> but it seems that simpleType needs to be implemented differently under
> this older schema.  Is this correct?  I commented out the original
> definition of the ISBNType simpleType and replaced it with one that
> works.  Now I get the following errors:
>
> [Error] tutorial.xml:14:44: Datatype error: In element 'ISBN' : Value
> '0-440-34319-4' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
>
> [Error] tutorial.xml:21:44: Datatype error: In element 'ISBN' : Value
> '0-06-064831-7' does not match regular expression facet
> '\d{5}-\d{5}-\d{5}'..
>
> If I change the order of the pattern definitions, it always sticks
> with the last one.  So, instead of OR-ing all the patterns together,
> it is simply using the last one.  Is this the way it is supposed to
> work?  Am I completely out to lunch?
>
> -scott
>
>
>    ----------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>