错误:必须很好地形成根元素后面的标记

时间:2017-08-10 15:25:40

标签: xml xsd

我正在尝试使用XSD将此ER图转换为XML Trying to convert ER diagram to XML using xsd

嗨,我试图用ERSD将ER图转换为XML格式,但遇到了上述错误,我无法弄明白。

这是XML文件..

<?xml version="1.0" encoding="utf-8"?>
<company xmlns:xsi="http://www.w3.org/2001/XMLSchema_instance" xsi:SchemaLocation="companyxsd.xsd" companyName="abc" address="hj">
    <department dname="dfsdf" deptphoneno="1232321" deptfaxno="2323" deptemail="fefsf">
        <employee empid="fsd" ename="fuehuf" emailid="fhueh" phoneno="364764">
        </employee>
        <contractEmployee name="fdsf" phoneno="12345">
        </contractEmployee>
    </department>
</company>

这是companyxsd.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
    <xs:attribute name="companyName" type="xs:string" />
    <xs:attribute name="address" type="xs:string" />
    <xs:attribute name="dname" type="xs:string" />
    <xs:attribute name="deptphoneno" type="xs:string" />
    <xs:attribute name="deptfaxno" type="xs:string" />
    <xs:attribute name="deptemail" type="xs:string" />
    <xs:attribute name="empid" type="xs:string" />
    <xs:attribute name="ename" type="xs:string" />
    <xs:attribute name="emailid" type="xs:string" />
    <xs:attribute name="phoneno" type="xs:string" />
    <xs:attribute name="name" type="xs:string" />

    <xs:element name="employee">
        <xs:complexType>
            <xs:attribute ref="empid"/>
            <xs:attribute ref="ename"/>
            <xs:attribute ref="emailid"/>
            <xs:attribute ref="phoneno"/>
        </xs:complexType>
    </xs:element>


    <xs:element name="contractEmployee">
        <xs:complexType>
            <xs:attribute ref="name"/>
            <xs:attribute ref="phoneno"/>
        </xs:complexType>
    </xs:element>


    <xs:element name="department">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="employee"/>
                <xs:element ref="contractEmployee"/>
            </xs:sequence>
            <xs:attribute ref="dname"/>
            <xs:attribute ref="deptphoneno"/>
            <xs:attribute ref="deptfaxno"/>
            <xs:attribute ref="deptemail"/>
        </xs:complexType>
    </xs:element>

    <xs:element name="company">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="department"/>
            </xs:sequence>
            <xs:attribute ref="companyName"/>
            <xs:attribute ref="address"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

我是XML的新手,所以不知道它是否正确。我试图在网上搜索这个具体问题,但找不到任何满意的答案。任何建议都表示赞赏。

0 个答案:

没有答案