Declaring Elements
In W3C XML Schema terminology, elements and attributes are declared. Both elements and attributes can occur in an instance document.
Listing 19.1 shows a simple example of an XML instance document. Listing 19.2 shows a W3C XML Schema document against which Listing 19.1 can be validated.
Listing 19.1. BasicDocument.xml: A Short XML Instance Document
<?xml version="1.0"?> <basicDocument> Some text content. </basicDocument> |
Listing 19.2. BasicDocument.xsd: A Schema for Listing 19.1
<?xml version='1.0'?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="basicDocument" type="xsd:string" /> </xsd:schema> |
The indicative namespace prefix in the W3C XML Schema document is xsd. The namespace declaration ...
Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.