DTD and XSD
Define allowed structure and validate documents against it.
What you will be able to do
- DTDs are simple but limited.
- XSD supports types and namespaces.
- Validate at ingestion boundaries.
- Schema errors are data errors, not code errors.
In plain English
A DTD is the older, simpler schema language. XSD is typed and supports namespaces, cardinality and datatypes. Validation catches structural errors before code consumes a document.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="course">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>Your turn
EasyMake an attribute required
Set an XSD attribute named id to required.
HTML · starter
<xs:attribute name="id" type="xs:string" />Check your understanding before moving on.
Knowledge checkQuestion 1
Which schema language supports datatypes and namespaces?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.