Xml cvc复杂类型.2.4.a:发现以元素';参数';。一个';{param}';预计
下面是我的xsd和xmlXml cvc复杂类型.2.4.a:发现以元素';参数';。一个';{param}';预计,xml,eclipse,xsd,Xml,Eclipse,Xsd,下面是我的xsd和xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" targetNamespace="http://example.com/DashboardSchema" xmlns:tns="http://example.com/DashboardSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://example.com/DashboardSchema" xmlns:tns="http://example.com/DashboardSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="dashboard" type="tns:xmlDashboard"/>
<xs:complexType name="xmlDashboard">
<xs:sequence>
<xs:element name="param" type="tns:xmlDashboardParameter" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="xmlDashboardParameter">
<xs:sequence/>
<xs:attribute name="module" type="xs:int" use="required"/>
<xs:attribute name="node" type="xs:int" use="required"/>
<xs:attribute name="parameter" type="xs:int" use="required"/>
</xs:complexType>
</xs:schema>
<dashboard xmlns="http://example.com/DashboardSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.com/DashboardSchema ./schema3.xsd">
<param module="1" node="1" parameter="4" />
<param module="1" node="2" parameter="6" />
<param module="2" node="0" parameter="4" />
<param module="2" node="0" parameter="5" />
</dashboard>
当我尝试在Eclipse中验证xml时,我得到了提到的错误。我做错了什么?您可能希望param位于架构的targetNamespace中,在这种情况下,您应该向xs:schema元素添加
elementFormDefault=“qualified”
这几乎总是要使用的正确设置。不幸的是,XSD设计人员将默认值弄错了
这也是一个糟糕的错误消息:如果您使用的是Saxon,它会说
Validation error on line 4 of test.xml:
XSD: In content of element <dashboard>: The content model does not allow element
<Q{.../DashboardSchema}param> to appear as the first child. The element is in namespace
http://example.com/DashboardSchema but it should be in no namespace.
Validating /dashboard[1]/param[1]
See http://www.w3.org/TR/xmlschema11-1/#cvc-complex-type clause 2.4
test.xml的第4行出现验证错误:
XSD:In-content of-element:内容模型不允许元素
作为第一个孩子出现。元素位于命名空间中
http://example.com/DashboardSchema 但是它不应该在名称空间中。
正在验证/仪表板[1]/param[1]
看见http://www.w3.org/TR/xmlschema11-1/#cvc-复杂类型第2.4条
谢谢你的回答。我现在得到一个不同的错误
error:(5,33)src import.3.1:namespace属性'http://example.com/PropertyTypeSchema元素信息项的“”必须与targetNamespace属性“”相同http://example.com/ModulesSchema,导入的文档。
。你知道这是什么吗?我应该发布文件的内容吗,可能在另一个问题中?听起来不相关,所以发布一个新问题。