Page 1 of 1

xs:pattern allows unallowed token

Posted: Thu Mar 12, 2009 1:31 pm
by SaschaF.
Hello.

I defined the following pattern for evaluating a date-string:

Code: Select all


([0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2})?
IMHO this should only allow something like 2009-03-12 or nothing!

But the XML-Validation (all engines) allows the following chars: a, e, n, p, r and t

i.e.

Code: Select all


<tag>a</tag>
is allowed.

Whats that :?: :?:

Btw: Oxygens inplaced RegEx-Konstruktor does not have this behavior.

Re: xs:pattern allows unallowed token

Posted: Thu Mar 12, 2009 5:37 pm
by sorin_ristache
Hello,

I tested your pattern in Oxygen both in the XML Schema regex builder tool (available on the Tools menu) and in an XML document validated against an XML Schema that specifies the pattern. It works correctly. Illegal characters like a, e, n, p, etc are reported as error. Can you post a sample schema for reproducing the problem?


Regards,
Sorin

Re: xs:pattern allows unallowed token

Posted: Thu Mar 12, 2009 6:02 pm
by SaschaF.
XSD

Code: Select all

?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TEST">
<xs:complexType>
<xs:sequence>
<xs:element name="FIELDVALUE">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[pattern]"/>
<xs:pattern value="(\d{4}\-\d{1,2}\-\d{1,2})?"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<TEST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Test.xsd">
<FIELDVALUE>a</FIELDVALUE>
</TEST>
<oXygen/> XML Editor 10.1, build 2009022414

Re: xs:pattern allows unallowed token

Posted: Thu Mar 12, 2009 6:16 pm
by sorin_ristache
SaschaF. wrote:

Code: Select all

<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[pattern]"/>
<xs:pattern value="(\d{4}\-\d{1,2}\-\d{1,2})?"/>
</xs:restriction>
</xs:simpleType>
The two patterns are ORed, not ANDed which means the following values are accepted: p, a, t, e, r, n, 2009-03-12, 1863-3-6, etc.


Regards,
Sorin

Re: xs:pattern allows unallowed token

Posted: Fri Mar 13, 2009 11:51 am
by SaschaF.
sorin wrote: The two patterns [...]
Args - Mea culpa! :?

Thanks sorin!