Description
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:
<xs:pattern value="([12][0-9][05])|([300])" />
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:
<xs:pattern value="[1-5]((0[1-9])|(1[0-5]))" />
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.