Restrict type of xsd:any to xsd:string only?

前端 未结 1 1241
伪装坚强ぢ
伪装坚强ぢ 2021-01-20 07:06

So I\'m writing a new XSD and I\'ve come across a little issue. Now I\'ll admit I\'m not the best with these, but I would have thought what I have done should have worked bu

1条回答
  •  难免孤独
    2021-01-20 07:19

    XSD 1.1

    See @IanRoberts fine suggestion in the comments regarding asserting that no grandchild elements exist under the children of extraInfo.

    XSD 1.0

    If you want more control over the type of the extraInfo child elements, you'll have to specify their names a priori.

    Attributes

    Or, why not leverage the fact that attribute values already are constrained not to have subelements and use xsd:anyAttribute instead:

      
        
          
        
      
    

    Users could then add extraInfo along these lines:

    
    

    and

    
    

    which would be natural given that you wish to allow only string values.

    Elements (update per OP question in comments)

    If the max of 42 constraint is important to you, you could go meta with a structure such as

    
        
        
    
    

    Then you could restrict the number of item elements trivially in XSD 1.0 via @maxOccurs.

    0 讨论(0)
提交回复
热议问题