[ 
https://issues.apache.org/jira/browse/DAFFODIL-2877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17821801#comment-17821801
 ] 

Steve Lawrence commented on DAFFODIL-2877:
------------------------------------------

Note that we do already have this problem with xs:strings where Daffodil 
converts XML Illegal characters to private use characters. Using a pattern 
restriction on those requires that users know to match PUA chars instead of the 
chars that are in the data. So this problem isn't really new. It just takes 
some education to make users aware that restrictions apply to the canonicalized 
infoset representation and not where the data came from. 

I agree that schematron or XML Schema 1.1 is probably the best way to do more 
complex number checking beyond min/max ranges, but some systems just don't have 
access to that.

If we don't want to support this in Daffodil, maybe one option is to change the 
SDE to a SDW saying that the pattern restriction is ignored? So we won't 
validate patterns with limited validation enabled, but using full validation or 
an external validator can still work using the same DFDL schema.

> 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
>            Priority: Major
>
> 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