开发者

XSD: restriction on type to not be empty /Blank and to exist? But its a simple type (string) inside a complexType [duplicate]

This question already has answers here: XML schema restriction pattern for not allowing empty strings (4 answers) Closed 9 years ago.

I have an XSD, here is part of it defined below, but it's not working. I need to ensure that Name isn't like this

   <Item Name="example"></Item> 

notice that there is nothing in between the tag, I run a validate and it passes. I have set use ="required". And I also tried setting some restrictions but it said it can only do it with a simple type. Well it is a complexType with a string inside.

      <xs:complexType>
        <xs:simpleContent msprop:Generator_ColumnVarNameInTable="columnItem_Text" 
                msprop:Generator_ColumnPropNameInRow="Item_Text" 
                msprop:Generator_ColumnPropNameInTable="Item_TextColumn" 
                msprop:Generator_UserColumnName="Item_Text" 
                msdata:ColumnName="Item_Text" msdata:Ordinal="1>
          <xs:extension base="xs:string" >
            <xs:attribute name="Name"
                msprop:Generator_ColumnVarNameInTable="columnName" 
                msprop:Generator_ColumnPropNameInRow="Name" 
                msprop:Generator_ColumnPropNameInTable="NameColumn" 
                msprop:Generator_UserColumnName="Name" type="xs:string"
                     use="required" />
          </xs开发者_如何转开发:extension>
        </xs:simpleContent>
      </xs:complexType>


Instead of using extension base="xs:string", use extension base="non-empty-string" where non-empty-string is a simple type defined as a restriction of xs:string using <minLength value='1'/> (or perhaps a regular expression, if you also want to prohibit a value containing only whitespace).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜