O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required