users@jaxb.java.net

RE: Request clarification using regular expressions within simple types

From: James Henderson <JamesHenderson_at_cornerstonesoftware.com>
Date: Wed, 27 Aug 2003 09:35:03 -0400

So from what you are saying there is a bug within JAXB.
Where should I report this bug?

(Oh yeah, and when might there be a possible fix for this issue?)

-James

>-----Original Message-----
>From: Pete Hendry [mailto:peter.hendry_at_capeclear.com]
>Sent: Tuesday, August 26, 2003 1:48 AM
>To: users_at_jaxb.dev.java.net
>Subject: Re: Request clarification using regular expressions within
>simple types
>
>
>Facets such as pattern, length, minLength, maxLength, totalDigits,
>fractionDigits should be applied to the string value before it is parsed
>I believe. That is why Xerces says it's valid (because it is). It does
>not make sense to do it another way.
>
>Pete
>
>James Henderson wrote:
>
>>I'm using a regular expression within a simple type to restrict the simple
>>type. The reason I am doing this is to provide an optional 5 digit
>>extension associated with a phone number.
>>
>>However when I use the value 00000 for the extension and use JAXB to
>>validate the XML document, the validation will fail with the following
>>message:
>>
>>[ERROR]: the value does not match the regular expression "\d{5}".
>>
>>This problem does not happen if I use the value 11111 for the extension.
>>
>>
>>What is the correct behavior in this situation?
>>a) The value is converted to integer and then evaluated as a regular
>>expression (meaning that JAXB validation is correct)
>>b) The value should be evaluated as a regular expression and then
>converted
>>to an integer (meaning that JAXB validation is incorrect)
>>
>>[As a side not Apache Xerces indicates that the XML document is valid.]
>>
>>
>>XSD and XML document follow:
>>
>>BusinessData.xsd
>>================
>><?xml version="1.0" encoding="UTF-8"?>
>><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>elementFormDefault="unqualified" attributeFormDefault="unqualified">
>> <xs:element name="BusinessData">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="phone"
>>type="ctPhoneNumber"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>> <xs:complexType name="ctBusinessDefinition" />
>> <xs:complexType name="ctPhoneNumber">
>> <xs:annotation>
>> <xs:documentation>Describes a phone number in the
>>system.</xs:documentation>
>> </xs:annotation>
>> <xs:complexContent>
>> <xs:extension base="ctBusinessDefinition">
>> <xs:sequence>
>> <xs:element name="number"
>>type="stPhoneNumber">
>> <xs:annotation>
>>
>> <xs:documentation>Describes the phone number. </xs:documentation>
>> </xs:annotation>
>> </xs:element>
>> <xs:element name="extension"
>>minOccurs="0">
>> <xs:annotation>
>>
>> <xs:documentation>Describes the phone extension. </xs:documentation>
>> </xs:annotation>
>> <xs:simpleType>
>> <xs:restriction
>>base="xs:int">
>> <xs:pattern
>>value="\d{5}"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> </xs:sequence>
>> </xs:extension>
>> </xs:complexContent>
>> </xs:complexType>
>> <xs:simpleType name="stPhoneNumber">
>> <xs:annotation>
>> <xs:documentation>Describes a phone number.
>></xs:documentation>
>> </xs:annotation>
>> <xs:restriction base="xs:string">
>> <xs:pattern value="\d{3}-\d{3}-\d{4}"/>
>> <xs:pattern value="(\d{3})-\d{3}-\d{4}"/>
>> </xs:restriction>
>> </xs:simpleType>
>></xs:schema>
>>
>>
>>
>>
>>
>>BusinessDataSample.xml
>>======================
>><?xml version="1.0" encoding="UTF-8"?>
>><BusinessData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>xsi:noNamespaceSchemaLocation="BusinessData.xsd">
>> <phone>
>> <number>000-000-0000</number>
>> <extension>00000</extension>
>> </phone>
>></BusinessData>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net