在XML复合文档(Schema)中获取特定错误(Getting specifc errors in XML compound document (Schema)

编程入门 行业动态 更新时间:2024-10-28 04:21:12
在XML复合文档(Schema)中获取特定错误(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>

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>

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.

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>

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>

I'm also getting a warning in the XML validator:

No DOCTYPE found! Checking XML syntax only.

I'm not sure if this is suppose to happen or not, as I have specified it as an XML document.

最满意答案

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

IE

<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">

Add this xmlns:gr="http://tutorialone.com/test/grant/ns" and remove 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">

更多推荐

本文发布于:2023-07-08 19:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1079988.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   文档   Schema   XML   document

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!