2

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>
halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327

1 Answers1

1

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).

Michael Kay
  • 156,231
  • 11
  • 92
  • 164