我想知道您是否可以指出我的架构有什么问题?我使用http://www.utilities-online.info/xsdvalidation/#.VQkt1BCUfA4XML
检查了我的文档格式是否正确——格式正确。但是当我检查我的文件时,它会显示很多错误。我真的不知道我在架构中做错了什么!如果有人可以帮我一把,那就太好了。schema
xml
grant.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE grant [
<!ELEMENT grant (title, agency, department, summary, initiated, expires, coordinator)>
<!ATTLIST grant grantNum ID #REQUIRED>
<!ATTLIST grant funding (federal|state|local|private) #REQUIRED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT agency (#PCDATA)>
<!ELEMENT department (#PCDATA)>
<!ELEMENT summary (#PCDATA)>
<!ELEMENT initiated (#PCDATA)>
<!ELEMENT expires (#PCDATA)>
<!ELEMENT coordinator (#PCDATA)>
]>
<grant xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com grant.xsd"
grantNum="NIHCCC-4481-05" funding="federal">
<title>NIH Clinical Cancer Basic Research Grant</title>
<agency>National Institute of Health</agency>
<department>University Hospital Clinical Cancer Center</department>
<summary>
Basic NIH support funding for current and future Phase 1 through Phase 3 cancer
clinical trials.
</summary>
<initiated>2006-07-01</initiated>
<expires>2010-06-30</expires>
<coordinator>Alice Walters</coordinator>
</grant>
授予.xsd 文件:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- 1. root element for a schema -->
<!-- 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:date' />
<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='Lu(6)-d(4)-d(2)' />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name='fundingFormat'>
<xs:restriction base="xs:string">
<xs:enumeration value="male" />
<xs:enumeration value="female" />
<xs:enumeration value="all" />
</xs:restriction>
</xs:simpleType>
<!-- Complex Type -->
<xs:element name="grant"> <!-- 4. declare the complex type -->
<xs:complexType>
<xs:sequence>
<xs:element ref="agency" />
<xs:element ref="summary" />
<xs:element ref="department" />
<xs:element ref="summary" />
<xs:element ref="initiated" /> <!-- 7. can have many comments -->
<xs:element ref="expires" />
<xs:element ref='coordinator' />
</xs:sequence>
<xs:attribute ref="grantNum" use="required" /> <!-- 6. attribute specify the use -->
<xs:attribute ref="funding" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
如果我做错了架构,请告诉我!