`
lydawen
  • 浏览: 464667 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Element must have no character or element information item [children], because

 
阅读更多

自定义XSD对XML校验,eclipse校验出现如下错误:

XML内容:

<PrimaryKey>123456</PrimaryKey>

 

错误提示:

 

Element  must have no character or element information item [children], because the type's content type is empty

 

修改前的XSD定义:

 

<xs:element name="PrimaryKey" type="KeyType" nillable="false" maxOccurs="15"/>

  <xs:complexType name="KeyType">
    <xs:attribute name="type" default="STRING"  use="optional">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="\d+" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
 </xs:complexType>

 

 

将 KeyType修改为继承自xs:string后通过。

<xs:complexType name="KeyType">
    <xs:simpleContent>
       <xs:extension base="xs:string">
          <xs:attribute name="type" default="STRING"  use="optional">
             <xs:simpleType>
		 <xs:restriction base="xs:string">
		      <xs:pattern value="\d+" />
		 </xs:restriction>
	     </xs:simpleType>
          </xs:attribute>
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>

 

 参考文档:http://stackoverflow.com/questions/4432183/xml-schema-definition-problem

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics