qq_35927590 2016-12-30 15:39 采纳率: 33.3%
浏览 1343

XML 问题: must refer to an existing element. 关于前缀

刚写了这样一个XML,始终不是valid。
捣鼓半天,把所有的xs:加上了,结果还真通过了,这个是什么原因呢?
报错信息是 '学生' must refer to an existing element.

 <?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

    <element name="姓名" type="string"/>

    <element name="性别">
        <simpleType>
            <restriction base="string">
                <pattern value="(男|女)"/>
            </restriction>
        </simpleType>
    </element>
    <element name="年龄">
        <simpleType>
            <restriction base="integer">
                <minExclusive value="0"/>
                <maxExclusive value="150"/>
            </restriction>
        </simpleType>
    </element>

    <attribute name="学号" type="integer"/>

    <complexType name="stu">
        <sequence maxOccurs="1">
            <element ref="姓名"/>
            <element ref="性别"/>
            <element ref="年龄"/>
        </sequence>
        <attribute ref="学号" use="required"/>
    </complexType>


    <element name="学生" type="stu"/>

        <complexType name="myT">
        <sequence>
            <element ref="学生" maxOccurs="unbounded"/>
        </sequence>     
    </complexType>




        <element name="学生名册" type="myT"/>

这个是后来加上的,没问题

 <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element  name="学生名册" type="myT"/>
    <xs:complexType name="myT">
        <xs:sequence maxOccurs="unbounded">
            <xs:element ref="学生"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="学生" type="stu"/>

    <xs:element name="姓名" type="xs:string"/>

    <xs:element name="性别">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:pattern value="(男|女)"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="年龄">
        <xs:simpleType>
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxExclusive value="150"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:attribute name="学号" type="xs:integer"/>

    <xs:complexType name="stu">
        <xs:sequence maxOccurs="1">
            <xs:element ref="姓名"/>
            <xs:element ref="性别"/>
            <xs:element ref="年龄"/>
        </xs:sequence>
        <xs:attribute ref="学号" use="required"/>
    </xs:complexType>




</xs:schema>
  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog