在 XML 复合文档(架构)中出现特定错误 |很难找到它们是什么

Getting specifc errors in XML compound document (Schema) | Have had trouble finding what they are

当我验证我的 compound document (compound.xml) 时,它给了我这些特定的错误。我正在使用 ( http://validator.w3.org/check )

**Namespace prefix gr on grant is not defined** - xsi:schemaLocation="http://tutorialone.com/test/grant/ns grant.xsd">

 **Namespace prefix gr on title is not defined** -   <gr:title>NIH Clinical Cancer Basic Research Grant</gr:title>

大多数元素都会出现这些错误...我不知道到底是什么问题!如果你要验证它,你会得到上面的列表 prefix erros 我是新手,不知道很多。为了您的方便,我列出了所有文件!

我试过了

我尝试在 http://.... 之前添加 gr: 但这没有用!我已经非常仔细地查看了它,但无法确定问题所在。

xsi:schemaLocation="http://tutorialone.com/test/grant/ns grant.xsd"

compound.xml

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

    <!--
        Date:       20/3/2015
        Filename:   compound.xml
        Supporting Files: grant.xsd
    -->

    <gr:grant grantNum="NIHCCC-4481-05" funding="federal"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:crs="http://tutorialone.com/test/grant/ns"
            xsi:schemaLocation="http://tutorialone.com/test/grant/ns grant.xsd">

        <gr:title>NIH Clinical Cancer Basic Research Grant</gr:title>
        <gr:agency>National Institute of Health</gr:agency>
        <gr:department>University Hospital Clinical Cancer Center</gr:department>
        <gr:summary>
            Basic NIH support funding for current and future Phase 1 through Phase 3 cancer clinical trials.
        </gr:summary>
        <gr:initiated>2006-07-01</gr:initiated>
        <gr:expires>2010-06-30</gr:expires>
        <gr:coordinator>Alice Walters</gr:coordinator>  


        <stu:studies xmlns:stu="http://tutorialone.com/test/studies/ns"
                xsi:schemaLocation = "http://tutorialone.com/test/studies/ns studies.xsd">

            <stu:study studyID="CCC-501-24">
                <stu:title>Treatment of Radiation Firbrosis</stu:title>
                <stu:summary>
                    This study is investigating whether two drugs, vitamin E(Alpha-tocopherol), and
                    Oxpentifylline, may help to heal body tissues damaged by radiotheraphy.
                </stu:summary>
                <stu:pi>Richard Tunney</stu:pi>
                <stu:startDate>15/08/2006</stu:startDate>
                <stu:stopDate>22/01/2008</stu:stopDate>
                <stu:enrollment>24</stu:enrollment>
                <stu:gender>female</stu:gender>
                <stu:phase>3</stu:phase>
                <stu:site>University Hospital</stu:site>
            </stu:study>

            <stu:study studyID="CCC-510-43">
                <stu:title>Tamoxifen for Early Stage Breast Cancer</stu:title>
                <stu:summary>
                    This study is to discover whether taking Tamoxifen for longer than
                    five years will reduce the risk of recurrence without additional side effects.
                </stu:summary>
                <stu:pi>Alice Walters</stu:pi>
                <stu:startDate>12/1/2006</stu:startDate>
                <stu:stopDate>11/30/2012</stu:stopDate>
                <stu:enrollment>100</stu:enrollment>
                <stu:gender>female</stu:gender>
                <stu:phase>3</stu:phase>
                <stu:site>University Hospital</stu:site>
                <stu:site>St. Thomas Vianney Hospital</stu:site>
                <stu:site>Ohio Cancer Clinic</stu:site>
            </stu:study>

            <stu:study studyID="CCC-510-48">
                <stu:title>Taxoprexin for Advanced Breast Cancer</stu:title>
                <stu:summary>
                    This study seeks to dicover the effacy of of Taxoprexin in treating
                    advanced stage breast cancer, to determine the side effects of
                    Taxoprexin, and to determine how quickly the body gets rid of Taxoprexin.
                </stu:summary>
                <stu:pi>Chandaskar Rao</stu:pi>
                <stu:startDate>15/04/2006</stu:startDate>
                <stu:stopDate>15/04/2007</stu:stopDate>
                <stu:enrollment>15</stu:enrollment>
                <stu:gender>female</stu:gender>
                <stu:phase>2</stu:phase>
                <stu:site>University Hospital</stu:site>
            </stu:study>

            <stu:study studyID="CCC-425-08">
                <stu:title>CT Scanning in Early Stage Testicular Cancer</stu:title>
                <stu:summary>
                    This study tests whether giving CT scans more often will detect
                    the recurrence of testicular cancer earlier.
                </stu:summary>
                <stu:pi>Dennis Lehman</stu:pi>
                <stu:startDate>15/11/2006</stu:startDate>
                <stu:stopDate>14/11/2009</stu:stopDate>
                <stu:enrollment>48</stu:enrollment>
                <stu:gender>woman</stu:gender>
                <stu:phase>3</stu:phase>
                <stu:site>University Hospital</stu:site>
                <stu:site>Ohio Cancer Clinic</stu:site>
            </stu:study>

            <stu:study studyID="CCC-805-88">
                <stu:title>Chemotheraphy with Cisplatin and Irintecan in Advanced Pancreatic Cancer</stu:title>
                <stu:summary>
                    This study test whether giving patients of combination of chemotheraphy
                    with Cisplatin and Irinotecan will control the symptons of advanced
                    pancreatic cancer.
                </stu:summary>
                <stu:pi>Michael Siudzinski</stu:pi>
                <stu:startDate>01/09/2006</stu:startDate>
                <stu:stopDate>31/05/2009</stu:stopDate>
                <stu:enrollment>12</stu:enrollment>
                <stu:gender>all</stu:gender>
                <stu:phase>2</stu:phase>
                <stu:site>Unversity Hospital</stu:site>
            </stu:study>

            <stu:study studyID="CCC-718-14">
                <stu:title>Encrecolomab in Post-Surgical Colon Cancer</stu:title>
                <stu:pi>Linda Sanchez</stu:pi>
                <stu:startDate>15/01/2007</stu:startDate>
                <stu:stopDate>31/12/2012</stu:stopDate>
                <stu:enrollment>1000</stu:enrollment>
                <stu:gender>all</stu:gender>
                <stu:phase>3</stu:phase>
                <stu:site>Univeristy Hospital</stu:site>
                <stu:site>Ohio Cancer Clinic</stu:site>
                <stu:site>St. Thomas Vianney Hospitstu:al</stu:site>
                <stu:site>Midwest Cancer Center</stu:site>
                <stu:site>Methodist Hospital</stu:site>
            </stu:study>

            <stu:study studyID="CCC-330-21">
                <stu:title>Cisplatin in the Treatment of Mesothelioma</stu:title>
                <stu:summary>
                    This study examines the effacy of Cisplatin in the treatment of
                    mesothelioma using a standard randomized clinical trial.
                </stu:summary>
                <stu:pi>Karen Cho</stu:pi>
                <stu:startDate>01/07/2006</stu:startDate>
                <stu:stopDate>31/03/2009</stu:stopDate>
                <stu:enrollment>240 patients</stu:enrollment>
                <stu:gender>all</stu:gender>
                <stu:phase>3</stu:phase>
                <stu:site>University Hospital</stu:site>
                <stu:site>Ohio Cancer Clinic</stu:site>
            </stu:study>
        </stu:studies>

    </gr:grant>

为了让大家更好地了解我的文件,这里是我的 xsd 资助和研究文件 -

grant.xsd

<?xml version="1.0" encoding="UTF-8" ?>
<!--
    Author:            James Wainwright
    Date:              20/3/2015
    Filename:          grant.xsd
    Supporting Files:  grant.xml
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns="http://tutorialone.com/test/grant/ns"
        targetNamespace="http://tutorialone.com/test/grant/ns"
        xmlns:stu="http://tutorialone.com/test/studies/ns"
        elementFormDefault="qualified" attributeFormDefault="unqualified" >

   <xs:import namespace="http://tutorialone.com/test/grant/ns" schemaLocation="studies.xsd" />



<!-- Elements -->
    <xs:element name='agency' type='xs:string' />
    <xs:element name='summary' type='xs:string' />
    <xs:element name='department' type='xs:string' />
    <xs:element name='summary' type='xs:string' />
    <xs:element name='initiated' type='xs:date' />
    <xs:element name='expires' type='xs:date' />
    <xs:element name='coordinator' type='xs:string' />

<!-- Attributes -->
    <xs:attribute name='grantNum' type='xs:grantNumFormat' />
    <xs:attribute name='funding' type='xs:fundingFormat' />


<!-- Simple Type -->
    <xs:simpleType name='grantNumFormat'>
        <xs:restriction base='xs:ID'>
            <xs:pattern value='[A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z]-d{4}-d{2}' />
        </xs:restriction>
    </xs:simpleType>

    <!-- Wasn't sure if the DTD would do this or not - So I added this anyway -->
    <xs:simpleType name='fundingFormat'>
        <xs:restriction base="xs:string">
            <xs:enumeration value="federal" />
            <xs:enumeration value="state" />
            <xs:enumeration value="local" />
            <xs:enumeration value="private" />

        </xs:restriction>
    </xs:simpleType>


<!-- Complex Type -->

    <xs:element name="grant"> <!-- 4. declare the complex type -->
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="title" />
                <xs:element ref="agency" />
                <xs:element ref="department" />
                <xs:element ref="summary" />
                <xs:element ref="initiated" />
                <xs:element ref="expires" />
                <xs:element ref="coordinator" />
            </xs:sequence>
             <xs:attribute ref="grantNum" use="required" />
             <xs:attribute ref="funding" use="required" />
        </xs:complexType>
            </xs:complexType>
    </xs:element>

</xs:schema>

studies.xsd

<?xml version="1.0" encoding="UTF-8" ?>
<!--
    Tutorial:   1
    Stu ID:     
    Author:     James Wainwright
    Date:       20/3/2015
    Filename:          studies.xsd
    Supporting Files:  studies.xml
-->

<xsi:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema"
        xmlns="http://tutorialone.com/test/studies/ns"
        targetNamespace="http://tutorialone.com/test/studies/ns"
        elementFormDefault="qualified"            attributeFormDefault="unqualified" >

    <xs:attribute name="studyID" type="studyIdType" />

    <xs:simpleType name="studyIdType">
        <xs:restriction base="xs:ID">
            <xs:pattern value="CCC-\d{3}-\d\d" />
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="title" type="xs:string" />
    <xs:element name="summary" type="xs:string" />
    <xs:element name="pi" type="xs:string" />
    <xs:element name="startDate" type="xs:date" />
    <xs:element name="stopDate" type="xs:date" />
    <xs:element name="site" type="xs:string" />

    <xs:element name="enrollment" type="xs:intType" />

<!-- Simple Types -->
    <xs:simpleType name="intType">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1" />
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="phase" type="xs:phaseRestrict" />
    <xs:simpleType name="phaseRestrict">
        <xs:restriction base="xs:integer">
            <xs:minExclusive value="1" />
            <xs:minInclusive value="3" />
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="gender" type="xs:genderRestrict" />
    <xs:simpleType name="genderRestrict">
        <xs:restriction base="xs:string">
            <xs:enumeration value="male" />
            <xs:enumeration value="female" />
            <xs:enumeration value="all" />
        </xs:restriction>
    </xs:simpleType>

<!-- Complex types -->

        <!-- Main Element sequence -->
    <xs:element name="study">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="title" />
                <xs:element ref="summary" minOccurs="0" maxOccurs="unbounded" />
                <xs:element ref="pi" />
                <xs:element ref="startDate" />
                <xs:element ref="stopDate" /> 
                <xs:element ref="enrollment" />
                <xs:element ref="gender" /> 
                <xs:element ref="phase" />
                <xs:element ref="site" minOccurs="1" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:attribute ref="studyID" use="required" />
        </xs:complexType>
    </xs:element>

            <!-- Root Element -->
    <xs:element name="studies">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="study" minOccurs="1" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xsi:schema>

我也在 XML 验证器中收到警告:

No DOCTYPE found! Checking XML syntax only.

我不确定这是否会发生,因为我已将其指定为 XML 文档。

添加此 xmlns:gr="http://tutorialone.com/test/grant/ns" 并删除 xmlns:crs="http://tutorialone.com/test/grant/ns"

I.E

<gr:grant grantNum="NIHCCC-4481-05" funding="federal"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:gr="http://tutorialone.com/test/grant/ns"
            xsi:schemaLocation="http://tutorialone.com/test/grant/ns grant.xsd">