Microsoft Word Applied xml a toolkit for Programmers Wiley doc




Download 2,96 Mb.
Pdf ko'rish
bet93/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   89   90   91   92   93   94   95   96   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

General Points
Here are some general points of discussion about this example and namespaces:

When you use a namespace prefix, you are telling the parser to validate the markup 
against the DTD or schema to which the prefix points. Thus you can create complex 
structures that use components described from several sources. Just as we made up 
the E-commerce Organization, real organizations (for example the ISO and W3C) 
could publish similar standard definitions for XML markup terms like date, time, and 
measurement units (miles versus kilometers and pounds versus kilograms).

Namespace prefixes are inherited from parent elements to child elements by default. 
Once you declare a namespace for a parent, you don’t need to turn it on again (that is, 
restate the xmlns: statement). To turn off the default namespace that a child inherits 
from its parents, simply add an xmlns: attribute to the child and set the attribute value 
to null. For example, 
...
turns off the default namespace it inherited from its parent.

Using namespaces, you can include information from many different sources—even 
sources that use the same element and attribute names to describe different data. For 


- 99 -
example, Title may refer to a book’s name or describe how to address a person (Mr., 
Mrs., or Ms.).

Namespaces are easy to use; however, they are not necessarily less verbose. Recall 
the W3C’s intentions behind XML: “Terseness in XML markup is of minimal 
importance.”

Namespaces give you a unique way for naming each attribute and element. This feature 
gives you a great amount of control over manipulating the values of attributes and 
elements for unique formatting purposes or for taking the values and performing further 
processing.
Summary
In this chapter, we went through a lot of effort trying to describe the basics and underlying 
semantics of the XML syntax as well as how to go about making DTDs for describing the 
structure of your data. These basics are useful as they help you create XML applications. 
Nothing is worse than making an application for something whose specs are not well 
understood. We hope that after reading this chapter, you’ve eliminated that problem.
We also made many references to what the parser’s reaction to syntax is like. These are 
important to you as a programmer because the parser can do a lot of the grunt work 
associated with making applications. The parser can take care of basic error-checking 
functions—checking that the markup is well formed and that it is valid against the DTD or 
schema—which often make up more than half the code of an application. You can 
bypass a lot of this by using a standard parser, which is why we spent so much time 
describing the parser’s reactions to different scenarios. 
Finally, all the information in this chapter is a building block to help you on your way to 
creating the next generation of applications across the Web. Now that you’ve got the 
basics nailed down, you can move on to the more challenging aspects of creating 
applications with XML.

Download 2,96 Mb.
1   ...   89   90   91   92   93   94   95   96   ...   131




Download 2,96 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Microsoft Word Applied xml a toolkit for Programmers Wiley doc

Download 2,96 Mb.
Pdf ko'rish