【问题标题】:Invalid content was found starting with element 'Role'发现以元素“角色”开头的无效内容
【发布时间】:2013-02-18 06:02:49
【问题描述】:

我的架构:

<xsd:element name="GetTasksForRolesResponse">
                        <xsd:complexType>
                          <xsd:sequence>
                            <xsd:element name="tuple" maxOccurs="unbounded">
                              <xsd:complexType>
                                <xsd:sequence>
                                  <xsd:element name="old">
                                    <xsd:complexType>
                                      <xsd:sequence>
                                        <xsd:element name="Role">
                                          <xsd:complexType mixed="true">
                                            <xsd:sequence>
                                              <xsd:element minOccurs="0" maxOccurs="unbounded" ref="ns:Task" xmlns:ns="http://schemas.cordys.com/task/1.0/"/>
                                            </xsd:sequence>
                                            <xsd:attribute type="xsd:string" name="dn" use="optional"/>                                         
                                            <xsd:attribute type="xsd:string" name="configTaskId" use="optional"/>
                                          </xsd:complexType>
                                        </xsd:element>
                                      </xsd:sequence>
                                    </xsd:complexType>
                                  </xsd:element>
                                </xsd:sequence>
                              </xsd:complexType>
                            </xsd:element>
                          </xsd:sequence>
                        </xsd:complexType>
                      </xsd:element>

我的内容:

<GetTasksForRolesResponse
            xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns="http://schemas.cordys.com/task/1.0/runtime/">
            <tuple>
                <old>
                    <Role
                        xmlns="http://schemas.cordys.com/task/1.0/"
                        dn="cn=Analyst,cn=Cordys@Work,cn=cordys,cn=defaultInst,o=vanenburg.com"></Role>
                </old>
            </tuple>
        </GetTasksForRolesResponse>

请帮我解决上述错误。


错误 原因:org.xml.sax.SAXException:cvc-complex-type.2.4.a:发现以元素“角色”开头的无效内容。需要 '{"http://schemas.cordys.com/task/1.0/runtime/":Role}' 之一。 org.xml.sax.SAXParseException;行号:9;列号:77; cvc-complex-type.2.4.a:发现以元素“角色”开头的无效内容。需要 '{"http://schemas.cordys.com/task/1.0/runtime/":Role}' 之一。

【问题讨论】:

    标签: xml xsd xml-validation xsd-validation


    【解决方案1】:

    XML 中的 Role 元素有一个明确的命名空间

    http://schemas.cordys.com/task/1.0/
    

    而验证器似乎期望它在命名空间中

    http://schemas.cordys.com/task/1.0/runtime/
    

    【讨论】:

    • 这会有帮助吗? &lt;GetTasksForRolesResponse xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/task/1.0/runtime/"&gt; &lt;tuple&gt; &lt;old&gt; &lt;Role dn="cn=Analyst,cn=Cordys@Work,cn=cordys,cn=defaultInst,o=vanenburg.com"&gt;&lt;/Role&gt; &lt;/old&gt; &lt;/tuple&gt; &lt;/GetTasksForRolesResponse&gt;
    • 你试过了吗?看起来它将 Role 放入正确的 NS 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-22
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多