例外:cvc-complex-type.2.4.a:发现以元素“employee"开头的无效内容.“{contractemployee}"之一是预期的 [英] Exception: cvc-complex-type.2.4.a: Invalid content was found starting with eleme nt 'employee'. One of '{contractemployee}' is expected

查看:37
本文介绍了例外:cvc-complex-type.2.4.a:发现以元素“employee"开头的无效内容.“{contractemployee}"之一是预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以..我有这个ER图:

So ..I have this ER diagram:

因此我写了一个 company.xml 为:

Hence I wrote an company.xml as:

<?xml version="1.0" encoding="UTF-8"?>

<company xmlns="urn:company.Namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="urn:company.Namespace companyxsd.xsd">
    <companyname>ABC company</companyname>
    <address>xyz street, India.</address>

    <department>
        <dname>Marketing</dname>
        <deptphoneno>9876543210</deptphoneno>
        <deptfaxno>0442456879</deptfaxno>
        <deptemail>marketing@abc.com</deptemail>

        <employee>
            <empid>101</empid>
            <ename>Rishie</ename>
            <emailid>rishie@abc.com</emailid>
            <phoneno>9876543211</phoneno>
        </employee>

        <contractemployee>
            <name>Ravi</name>
            <phoneno>9874563214</phoneno>
        </contractemployee>
    </department>

</company>    

和我的companyxsd.xsd如下:

and my companyxsd.xsd as follows:

    <?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:company.Namespace" xmlns="urn:company.Namespace">

    <xs:element name="company">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="companyname" type="xs:string"/>
       <xs:element name="address" type="xs:string"/>

       <xs:element name="department">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="dname" type="xs:string"/>
          <xs:element name="deptphoneno" type="xs:integer"/>
          <xs:element name="deptfaxno" type="xs:integer"/>
          <xs:element name="deptemail" type="xs:string"/>

          <xs:element name="employee">      
           <xs:complexType>
            <xs:sequence>
             <xs:element name="empid" type="xs:integer"/>
             <xs:element name="ename" type="xs:string"/>
             <xs:element name="emailid" type="xs:string"/>
             <xs:element name="phoneno" type="xs:integer"/>
            </xs:sequence>
           </xs:complexType>
          </xs:element>


          <xs:element name="contractemployee">      
           <xs:complexType>
            <xs:sequence>
             <xs:element name="name" type="xs:string"/>
             <xs:element name="phoneno" type="xs:integer"/>
            </xs:sequence>
           </xs:complexType>
          </xs:element>

         </xs:sequence>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
     </xs:complexType>
    </xs:element>

</xs:schema>

我不确定我的 xml 是否按原样表示 ER 图.如果没有,请帮助我使用正确的 xml 模板.

I am not sure whether my xml represents the ER diagram as it is. If not please help me out with the correct xml template.

由于我是初学者..我对我写的 XSd 有疑问.':(

Since Iam a beginner..I have doubts on the XSd I have written. ':(

对于上述,我不断收到错误

For the above, I keep getting errors as such

Exception: cvc-complex-type.2.4.a: Invalid content was found starting with eleme
nt 'employee'. One of '{contractemployee}' is expected.

新的错误:

Exception: cvc-elt.1.a: Cannot find the declaration of element 'company'. 

朋友们帮帮我吧!

推荐答案

我也遇到了同样的两个错误.该错误不需要对 xmlxsd 文件的链接部分进行任何更改.实际上,scorm 编辑器可能非常棘手.

I too had the same two errors. The error does not require any changes in the linking part of the xml and xsd file. Actually, the scorm editor can be very tricky.

应为 {employee,contractemployee} 之一

此错误需要元素合同员工和员工中的一些属性,例如 minOccurs 和 MaxOccurs 属性.

This error expects some of the attributes in the element contract employee and employee such minOccurs and MaxOccurs attributes.

我已经为在 scorm 编辑器中成功运行的 xmlxsd 发布了适当的代码.编码快乐!!!

I have posted the appropriate code for the xml and xsd that runs successfully in the scorm editor. HAPPY CODING !!!

XML:

<?xml version="1.0" encoding="UTF-8"?>
<company>
    <companyname>company name</companyname>
    <address>address</address>
    <department>
        <dname>dname</dname>
        <deptphoneno>22238500</deptphoneno>
        <deptfaxno>123456789</deptfaxno>
        <deptemail>email@email</deptemail>
        <employee>
            <empid>123</empid>
            <ename>ename</ename>
            <emailid>email@email</emailid>
            <phoneno>9444872829</phoneno>
        </employee>
        <contractemployee>
            <name>name</name>
            <phoneno>9445815259</phoneno>
        </contractemployee>
    </department>
</company>

XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="company">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="companyname" type="xs:string"/>
                <xs:element name="address" type="xs:string"/>
                <xs:element maxOccurs="unbounded" name="department">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="dname" type="xs:string"/>
                            <xs:element name="deptphoneno" type="xs:string"/>
                            <xs:element name="deptfaxno" type="xs:integer"/>
                            <xs:element name="deptemail" type="xs:string"/>
                            <xs:element maxOccurs="unbounded" minOccurs="1" name="employee">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="empid" type="xs:integer"/>
                                        <xs:element name="ename" type="xs:string"/>
                                        <xs:element name="emailid" type="xs:string"/>
                                        <xs:element name="phoneno" type="xs:integer"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element maxOccurs="unbounded" minOccurs="0" name="contractemployee">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="name" type="xs:string"/>
                                        <xs:element name="phoneno" type="xs:integer"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

这篇关于例外:cvc-complex-type.2.4.a:发现以元素“employee"开头的无效内容.“{contractemployee}"之一是预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆