2015-12-15 32 views
1

我需要知道用户名的最小宽度限制是什么? 我试过这个,但它不起作用。如何设置分钟。宽度作为XML中元素值的限制?

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema 
xmlns="http://www.google.com" 
xmlns:xs="http://www.google.com" 
xs:schemaLocation="http://www.google.com"> 
    <xs:users> 
     <xs:element1 name="username" type="xs:string"> 
      <xs:restrictions> 
       <xs:minWidth="5"/> 
      </xs:restrictions> 
     </xs:element1> 
    </xs:users> 
</xs:schema> 

回答

1

您可以定义从xs:string派生的自定义simpleType其强制执行的5最小字符串长度:

<xs:users> 
    <xs:element1 name="username" type="UserString"/> 
</xs:users> 
+0

感谢:

<xs:simpleType name="UserString"> <xs:restriction base="xs:string"> <xs:minLength value="5" /> </xs:restriction> </xs:simpleType> 

然后你就可以在你原有的XSD文档中使用它恬。有用。! –

相关问题