简单的XML问题

时间:2010-11-16 14:50:28

标签: xml

好吧,使用我的XML编辑器来检查我得到的验证“验证在第2行停止,第8列:找不到元素'Staff'的声明。有谁知道这是为什么?

此外,每三名工作人员的类型不同,每种类型都包含不同的元素(例如,兼职工作人员只有电子邮件,姓名,职位,而FullTime类型则包含所有元素的信息。)是不是形式不好将元素数据留空?如果他们是不同类型的StaffMembers,是否可以摆脱额外的元素,或者每个StaffMember是否都需要相同的元素?谢谢!

<Staff>

    <StaffMember type="FullTime">
        <Name>Richard Baskerville</Name>
        <Position>Professor</Position>
        <OfficePhone>(404) 413-7362</OfficePhone>
        <Building>Robinson College</Building>
        <Room>919</Room>
        <URL>www.cis.gsu.edu/~rbaskerv</URL>
        <Email>rbaskerville@cis.gsu.edu</Email>
        <DegreeInfo>Ph. D., M.S., B.S.</DegreeInfo>
        <Research> Information systems security, interaction of information systems and organizations, qualitative research methods,      diffusion of IT innovations, knowledge management</Research>
    </StaffMember>

    <StaffMember type ="FullTime">
        <Name>Michael Gallivan</Name>
        <Position>Associate Professor</Position>
        <OfficePhone>(404) 413-7363</OfficePhone>
        <Building>Robinson College</Building>
        <Room>935</Room>
        <URL>www.cis.gsu.edu/~mgalliva</URL>
        <Email>mgalliva@cis.gsu.edu</Email>
        <DegreeInfo>Ph. D., M.B.A., M.P.H., B.A.</DegreeInfo>
        <Research> IT human resource management, management of IT outsourcing, adoption and diffusion of innovations, organizational learning from innovations </Research>
    </StaffMember>

      <StaffMember type ="FullTime">
        <Name>Sidney Harris</Name>
        <Position>Professor</Position>
        <OfficePhone>(404) 413-7017</OfficePhone>
        <Building>Robinson College</Building>
        <Room>427</Room>
        <URL>www2.gsu.edu/~wwwseh/</URL>
        <Email>sidneyharris@gsu.edu</Email>
        <DegreeInfo>Ph. D., M.S., B.S.</DegreeInfo>
        <Research> Strategic management of technology, global practices in technological innovation and management, regional studies on China and Asia culture of high performance organization</Research>
    </StaffMember>

      <StaffMember type ="Adjunct">
        <Name>Arash Akhlaghi</Name>
        <Position>Adjunct Professor</Position>
        <OfficePhone></OfficePhone>
        <Building></Building>
        <Room></Room>
        <URL></URL>
        <Email>aakhlaghi1@student.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Adjunct">
        <Name>Catherine Baird</Name>
        <Position>Adjunct Professor</Position>
        <OfficePhone></OfficePhone>
        <Building></Building>
        <Room></Room>
        <URL></URL>
        <Email>cbaird@cis.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Adjunct">
        <Name>David Bloomquist</Name>
        <Position>Adjunct Professor</Position>
        <OfficePhone></OfficePhone>
        <Building></Building>
        <Room></Room>
        <URL></URL>
        <Email>dbloomquist@cis.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Staff">
        <Name>Desiree Plummer</Name>
        <Position>PC System Specialist</Position>
        <OfficePhone>(404) 413-7440></OfficePhone>
        <Building>Robinson College</Building>
        <Room>908</Room>
        <URL></URL>
        <Email>dplummer@cis.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Staff">
        <Name>Walter Rich</Name>
        <Position>Manager, CIS External Affairs</Position>
        <OfficePhone>(404) 413-7398></OfficePhone>
        <Building>Robinson College</Building>
        <Room>929</Room>
        <URL></URL>
        <Email>wrich@cis.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Staff">
        <Name>James Sneed</Name>
        <Position>Information Technology Department Manager</Position>
        <OfficePhone>(404) 413-7383></OfficePhone>
        <Building>Robinson College</Building>
        <Room>907</Room>
        <URL></URL>
        <Email>jsneed@cis.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

  <StaffMember type="Ph.D">
        <Name>Anouck Adrot</Name>
        <Position></Position>
        <OfficePhone>(404) 413-7389></OfficePhone>
        <Building>Robinson College</Building>
        <Room>910</Room>
        <URL></URL>
        <Email>aadrot1@student.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Ph.D">
        <Name>Chad Anderson</Name>
        <Position></Position>
        <OfficePhone>(404) 413-7389></OfficePhone>
        <Building>Robinson College</Building>
        <Room>910</Room>
        <URL></URL>
        <Email>canderson32@comcast.net</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

    <StaffMember type="Ph.D">
        <Name>Mathieu Chauvet</Name>
        <Position></Position>
        <OfficePhone>(404) 413-7389></OfficePhone>
        <Building>Robinson College</Building>
        <Room>910</Room>
        <URL></URL>
        <Email>mchauvet1@student.gsu.edu</Email>
        <DegreeInfo></DegreeInfo>
        <Research></Research>
    </StaffMember>

</Staff>

2 个答案:

答案 0 :(得分:0)

This XML validator不会对您的xml造成任何错误。

无论如何,如果使用模式或DTD进行验证,则可能会出错(如果它与规范不符)。

对于你的第二点,你可以拥有空节点,但是使用取决于你的需要,如果使用一个规范,则使用规范和使用这个xml的代码。如果您没有使用我怀疑的架构或DTD,或者之后解析它的代码会处理它,您可以删除它们。

答案 1 :(得分:0)

  

“验证在第2行,第2栏停止   8:没有找到元素的声明   '员工'。有谁知道这是为什么?

因为您尚未声明要验证的架构(XML架构,DTD,RNG等)。我不知道你正在使用什么XML编辑器......显然你告诉它要验证,并且它试图说它无法验证,因为没有架构可以验证。 意味着您的XML无效:相反,它意味着有效性对您的XML没有意义(直到您将模式与其关联)。