- Shopping Bag ( 0 items )
Whether it is used for web development, creating documentation, or exchanging data between business partners, XML continues to grow in importance as a highly flexible document-design and data-modeling tool. Despite the limitations of using SGML Document Type Definitions (DTDs) to define document structures, XML has made inroads wherever data must flow among disparate platforms. The Schema specification has achieved W3C recommendation status, providing an alternative to DTDs that enables you to precisely structure...
Ships from: fallbrook, CA
Usually ships in 1-2 business days
Whether it is used for web development, creating documentation, or exchanging data between business partners, XML continues to grow in importance as a highly flexible document-design and data-modeling tool. Despite the limitations of using SGML Document Type Definitions (DTDs) to define document structures, XML has made inroads wherever data must flow among disparate platforms. The Schema specification has achieved W3C recommendation status, providing an alternative to DTDs that enables you to precisely structure XML data. But using the Schema Language does more than provide a more powerful way of defining data; it's also a better way because it uses XML's structure, syntax, and namespaces, instead of those derived from the complex SGML. XML Schemas introduces you to this elegant new technology, which brings the power of data modeling and data structuring to XML. A truly practical book has to give you more than just the details on syntax and semantics, examples of constructs and datatypes, and instruction in standard procedures. You get all that, but you'll also find lots of expert tips and techniques for document modeling, all reinforced with practical, real-world examples. Even as you're discovering the advantages of XML Schema, you'll learn about the continuing use of DTDs. In some situations — when designing document-oriented XML, for example — DTDs might still be the way to go. You'll learn about visual XML Schema tools, but you'll also see how setting out armed with just a text editor gives you insights you might not acquire otherwise. It won't be long before you're developing your own XML Schema documents, using the power of XML to structure data for seamless, cross-platform exchange.
This is not to say that DTDs have outlived their usefulness;however,schemas are giving them a run for their money.As developers,we now have options for validation.Two options come from the W3C:XML Schema and XML DTDs.However,you ’re not limited to only those two options.In addition to XML Schema and XML DTDs,there are several other schema languages that are circulating throughout the XML community.Two worth noting are REgular LAnguage description for XML Next Generation (RELAX NG)and Schema- tron,which are both lightweight schema languages that offer functionality similar to the functionality XML Schema offers.Find out more about RELAX NG and Schematron in Chapter 12.
In this chapter,we focus on basic underlying concepts of XML Schema and XML DTDs. It ’s important to understand the strengths and weaknesses of both approaches before you choose the appropriate validation tool for your application.
There are several reasons you might want to use a validation mechanism:
TIP As you probably know, DTD validation is no longer the only option for defining document models. XML Schema offers a flexible solution to the preceding scenarios.
element declarations Identify the names of elements and the nature of their content. DTDs do not allow for complex content model definitions.Rather,DTDs allow authors to provide information about element hierarchy.The only datatype you can define for ele- ment content is parsed character data (PCDATA ).
attribute declarations Identify which elements may have attributes,what attributes they may have,what values the attributes may hold,and what the default value is.
entity declarations Allow you to associate a name with some other fragment of content. That construct can be a chunk of regular text,a chunk of the document type declaration, or a reference to an external file containing either text or binary data.
notation declarations Identify specific types of external binary data.This information is passed to the processing application.
When defining DTD declarations,you have to follow a few rules governing the order of their occurrence.If multiple declarations exist for the same element,entity,attribute,or notation,the first one defined takes precedence (the other redundant declarations are then ignored).You also have to be careful when defining entities.Parameter entities (entities defined and used within the DTD)must be declared before they can be referenced.
The syntax used to create declarations allows for white space anywhere within the declara- tions,but there are a few delimiters that have to be written accurately (such as the exclama- tion point in !ELEMENT .The follow declarations are all correct:
<!ELEMENT book (title,author)> <!ELEMENT book (title,author)> <!ELEMENT book ( title, author)>
Declarations can reside inside the XML document or can be defined as a stand-alone doc- ument.If defined as a part of an XML document,the collection of declarations is referred to as the internal subset .If the declarations are defined externally in a separate file,that file is referred to as an external subset .Many times,you ’ll find that you need to use both internal and external subsets.The collection of all subsets is known as the DTD.Listing 2.1 provides an example of a small collection of DTD declarations defined as a part of the internal DTD subset.
.Listing 2.1 An XML Document Containing an Internal DTD Subset
<?xml version=”1.0 ”?> <!DOCTYPE publications [ <!ELEMENT publications (book+)> <!ELEMENT book (title,author)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> ]> <publications> <book> <title>Mastering XHTML</title> <author>Ed Tittel</author> </book> <book> <title>Java Developer ’s Guide to E-Commerce with XML and JSP</title> <author>William Brogden</author> </book> </publications>
This example defines only element type declarations.In most cases,your document model would be more complex,also allowing for attributes,notations,and entities.For each ele- ment,there ’s a corresponding content model defined.For example,the book element is allowed to contain only a title element followed by an author element.
There are a couple of restrictions placed on internal subsets:
|Ch. 1||Introducing Metadata||1|
|Ch. 2||Of DTDs and Schemas||23|
|Ch. 3||The Document Design Process||47|
|Ch. 4||The Role of DTDs in XML||77|
|Ch. 5||Understanding XML Schema||111|
|Ch. 6||Understanding Schemas: Structures and Components||159|
|Ch. 7||Understanding Schema Datatypes||213|
|Ch. 8||Designing XML Schema Documents||269|
|Ch. 9||Converting DTDs to Schemas||301|
|Ch. 10||Important XML Schemas||339|
|Ch. 11||Using Appropriate Metadata||361|
|Ch. 12||Other Schema Languages||383|
|Ch. 13||Schema-Based Initiatives||439|
|Ch. 14||Schema and Related Tools||475|
|App. A: Important Specifications and Standards||501|
|App. B||DTD for XML Schema: Structures||507|
|App. C||XML Schema Components and Datatypes||517|