XSD: how to restrict number of characters in string type attribute?

后端 未结 5 1911
别跟我提以往
别跟我提以往 2020-12-08 07:08

I have a question regarding adding restriction in my xml schema(xsd). I have a complex-type like:


   

        
5条回答
  •  离开以前
    2020-12-08 07:41

    You can restrict the string to a number of chars like this:

    
      
        3-char strings only
      
      
        
      
    
    

    The xs:length in the above limits the length of the string to exactly 3 chars. You can also use xs:minLength and xs:maxlength, or both.

    You can provide a pattern like so:

    
      
        
      
    
    

    The above says, 4 chars, of any of a-z, A-Z. The xs:pattern is a regular expression, so go to town with it.

    You can restrict the string to a particular set of strings in this way:

    
      
        ISO-4217 3-letter currency codes. Only a subset are defined here.
      
      
        
        
        
        
        
        
        
        
        
        
        
      
    
    

提交回复
热议问题