Re: combining enumeration and pattern

Re: combining enumeration and patternJeni - 

The point about how the facets are combined is the critical one.  
XML Spy agrees with your proposition.
I was looking for where this is explained in the rec.  
Can you point out where this behaviour is specified?

It is explicitly stated that multiple pattern facets on the same step are to be ORed [1]. 
It is implicitly explained that multiple enumeration facets are ORed (though it uses the phrase "set of") [2].  
I guess it is obvious that a minInclusive, maxInclusive pair (etc) is ANDed.  
But I don't think how other *mixtures* are combined is clear from the rec.   

[1] clause 4.3.4.3 http://www.w3.org/TR/xmlschema-2/#rf-pattern
[2] clause 4.3.5.3 http://www.w3.org/TR/xmlschema-2/#rf-enumeration

Simon Cox
  ----- Original Message ----- 
  From: Jeni Tennison 
  To: Cox, Simon (E&M, Kensington) 
  Cc: xmlschema-dev@w3.org ; Clemens Portele 
  Sent: Monday, June 30, 2003 4:52 PM
  Subject: Re: combining enumeration and pattern


  Hi Simon, 

  > Re: Re-using XSD schema-for-schemasIn simpleType derivation-by 
  > restriction, is it legal to apply both enumeration and pattern 
  > constraints in the same derivation step? 

  Yes, that's fine, but it means something different from what I think 
  you think it means. The example you give: 

  > <simpleType name="DrillCodeType"> 
  >     <restriction base="string"> 
  >       <enumeration value="RAB"/> 
  >       <enumeration value="RC"/> 
  >       <enumeration value="DD"/> 
  >       <enumeration value="DD-HQ"/> 
  >       <enumeration value="DD-NQ"/> 
  >       <pattern value="other:\w{2,}"/> 
  >     </restriction> 
  >   </simpleType> 

  means that values of the DrillCodeType must be one of 'RAB', 'RC', 
  'DD', 'DD-HQ' or 'DD-NQ' *and* must match the regular expression 
  'other:\w{2,}'. Since none of the enumerated values match the regular 
  expression, you end up with a type with no legal values (which isn't 
  good news). 

  If you want to say that DrillCodeType can be *either* one of the 
  enumerated values *or* match the pattern, then it needs to be a union 
  type: 

  <simpleType name="DrillCodeType"> 
    <union> 
      <simpleType> 
        <restriction base="string"> 
          <enumeration value="RAB"/> 
          <enumeration value="RC"/> 
          <enumeration value="DD"/> 
          <enumeration value="DD-HQ"/> 
          <enumeration value="DD-NQ"/> 
        </restriction> 
      </simpleType> 
      <simpleType> 
        <restriction base="string"> 
          <pattern value="other:\w{2,}"/> 
        </restriction> 
      </simpleType> 
    </restriction> 
  </simpleType> 

  You could alternatively create a type that allowed these values using 
  only pattern facets: 

  <simpleType name="DrillCodeType"> 
    <restriction base="string"> 
      <pattern value="RAB"/> 
      <pattern value="RC"/> 
      <pattern value="DD"/> 
      <pattern value="DD-HQ"/> 
      <pattern value="DD-NQ"/> 
      <pattern value="other:\w{2,}"/> 
    </restriction> 
  </simpleType> 

  but if you were using this schema with applications that, for example, 
  prompt the user with the allowed values, then it's better to use 
  enumerated values. 

  > If yes, is it still OK if the pattern used for a restiction of 
  > simpleContent in a complexType definition. 

  I'm not sure what you're asking here. You can use the pattern facet 
  however the simple type that you're defining is used. 

  Cheers, 

  Jeni 

  --- 
  Jeni Tennison 
  http://www.jenitennison.com/ 

Received on Monday, 30 June 2003 07:04:13 UTC