Steve Lawrence created DAFFODIL-2877:
----------------------------------------

             Summary: Allow pattern restriction facet to be used on non-string 
types
                 Key: DAFFODIL-2877
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2877
             Project: Daffodil
          Issue Type: New Feature
          Components: Back End, Front End
            Reporter: Steve Lawrence


Section 5.2 of the DFDL specification says that the pattern restriction facet 
can only be used for xs:string types. Daffodil currently implements this 
limitation.

However, there are a number of cases where a pattern is the only way to 
correctly restrict the value of non-string types, such as xs:long. 

One example is a number that can only be between 100 and 300 but in multiples 
of 5. In that case, a pattern like this would work:
{code}
<xs:pattern value="([12][0-9][05])|([300])" />
{code}

Another example could be apartment rooms, where the first digit represents the 
floor (e.g. 1-5), and the second two digits represent the room number between 1 
and 15 (assuming 15 rooms per floor). In that case, the pattern restriction 
might be:
{code}
<xs:pattern value="[1-5]((0[1-9])|(1[0-5]))" />
{code}

The patterns are often going to be a bit ugly, but in some cases it's the only 
way to correctly validate numbers using only XML Schema capabilities.

Note that only supporting pattern on xs:string types is a limitation imposed by 
DFDL--XML schema allows pattern restriction on all types. We should remove this 
limitation and allow pattern facet to be used on all types.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to