[xml] xml schema quantifier differences
- From: "Nicolai Scheer" <scope planetavent de>
- To: xml gnome org
- Subject: [xml] xml schema quantifier differences
- Date: Tue, 23 Aug 2011 17:36:00 +0200 (CEST)
Hi!
Im currently facing difficulties validating a simple xml
document against a very simple schema.
The small document:
<?xml version="1.0"
encoding="UTF-8"?>
<root></root>
does not validate against:
<?xml version="1.0"
encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="root">
<simpleType>
<restriction base="string">
<pattern value="-?[0-9]{0,10}"></pattern>
</restriction>
</simpleType>
</element>
</schema>
but does validate against:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="root">
<simpleType>
<restriction base="string">
<pattern value="-{0,1}[0-9]{0,10}"></pattern>
</restriction>
</simpleType>
</element>
</schema>
The error message from xmllint is as
follows:
<?xml version="1.0"
encoding="UTF-8"?>
<root/>
dummy.xml:2:
element root: Schemas validity error : Element 'root': [facet 'pattern']
The value '' is not accepted by the pattern '-?[0-9]{0,10}'.
dummy.xml:2: element root: Schemas validity error : Element 'root': ''
is not a valid value of the local atomic type.
dummy.xml fails to
validate
Tested on Windows 2008 using the binaries linked in
the libxml web page (version 2.7.8).
When tested on Eclipse
Indigo the xml document validates using both schemas.
To my
mind "?" and "{0,1}" should be equivalent. I searched
the docs but found no specific details about which parts of the schema
standard is supported.
There seems to be no (confirmed) open bugs
about quantifiers either.
Am I getting something terribly wrong
here? The "?" quantifier does work, e.g. accepts
"1234" and "-1234", it just refuses to accept an empty
string in total.
Any help is appreciated!
Greeting,
scope
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]