I was wondering if you could point out whats wrong with my schema? I have checked that my XML
document is well formed using - http://www.utilities-online.info/xsdvalidation/#.VQkt1BCUfA4 - It's well formed. But when I check my schema
against my xml
document it will display a whole lot of erros. I don't really know what I'm doing wrong in my schema! If someone could give me a hand that would be great.
grant.xml File:
<?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>
grant.xsd File:
<?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>
If I'm doing my schema wrong please let me know!