TAILIEUCHUNG - XML Step by Step- P6
XML Step by Step- P6:Extensible Markup Language, or XML, is currently the most promising language for storing and exchanging information on the World Wide Web. Although Hypertext Markup Language (HTML) is presently the most common language used to create Web pages, HTML has a limited capacity for storing information. In contrast, because XML allows you to create your own elements, attributes, and document structure, you can use it to describe virtually any kind of information from a simple recipe to a complex database | 74 XML Step by Step note You can use a namespace prefix to qualify the name of the element in which the namespace is declared even though the prefix is used before it s declared. In the example document if you declared the cd namespace within a TITLE element rather than within the COLLECTION element you could still apply that prefix to the element name cd TITLE xmlns cd http cds Violin Concerto in D cd TITLE As an alternative to creating a namespace prefix and using it to explicitly qualify individual names you can declare a default namespace within an element which will apply to the element in which it is declared if that element has no namespace prefix and to all elements with no prefix within the content of that element. Listing 3-5 shows the XML document from Listing 3-4 but with the book namespace http books declared as a default namespace so that it doesn t have to be explicitly applied to each of the book-related elements. You ll find a copy of this listing on the companion CD under the filename Collection . Collection xml version -- File Name Collection -- COLLECTION xmlns http books xmlns cd http cds ITEM Status in TITLE The Adventures of Huckleberry Finn TITLE AUTHOR Mark Twain AUTHOR PRICE PRICE ITEM cd ITEM cd TITLE Violin Concerto in D cd TITLE cd COMPOSER Beethoven cd COMPOSER cd PRICE cd PRICE cd ITEM ITEM Status out Chapter 3 Creating Well-Formed XML Documents 75 TITLE Leaves of Grass TITLE AUTHOR Walt Whitman AUTHOR PRICE PRICE ITEM cd ITEM cd TITLE Violin Concertos Numbers 1 2 and 3 cd TITLE cd COMPOSER Mozart cd COMPOSER cd PRICE cd PRICE cd ITEM ITEM Status out TITLE The Legend of Sleepy Hollow TITLE AUTHOR Washington Irving AUTHOR PRICE PRICE ITEM ITEM Status in TITLE The Marble Faun TITLE AUTHOR Nathaniel Hawthorne AUTHOR PRICE PRICE ITEM COLLECTION Listing 3-5. You declare a default namespace by .
đang nạp các trang xem trước