tailieunhanh - Advanced Java 2 Platform HOW TO PROGRAM phần 10

Trong hình. , hai yếu tố tập tin khác nhau được phân biệt bằng cách sử dụng không gian tên. Dòng 6 - 7 sử dụng xmlns không gian tên XML từ khóa để tạo ra hai không gian tên tiền tố: văn bản và hình ảnh. | Appendix A Creating Markup with XML 1621 9 text file filename 10 text description A book list text description 11 text file 12 13 image file filename 14 image description A funny picture image description 15 image size width 200 height 100 16 image file 17 18 text directory xml version encoding UTF-8 -- Fig. -- -- Namespaces -- text directory xmlns text urn deitel textInfo xmlns image urn dei-tel imageInfo text file filename text description A book list text description text file image file filename image description A funny picture image description image size width 200 height 100 image file text directory Fig. Demonstrating XML namespaces part 2 of 2 . In Fig. two distinct file elements are differentiated using namespaces. Lines 67 use the XML namespace keyword xmlns to create two namespace prefixes text and image. The values assigned to attributes xmlns text and xmlns image are called Uniform Resource Identifiers URIs . By definition a URI is a series of characters used to differentiate names. To ensure that a namespace is unique the document author must provide a unique URI. Here we use the text urn deitel textInfo and urn deitel imageInfo as URIs. A common practice is to use Universal Resource Locators URLs for URIs because the domain names . used in URLs are guaranteed to be unique. For example lines 6-7 could have been written as directory xmlns text http xmlns-text xmlns image http xmlns-image where we use URLs related to the Deitel Associates Inc. domain name . com . These URLs are never visited by the parser they only represent a series of characters for differentiating names and nothing more. The URLs need not even exist or be properly formed. Lines 9-11 use the namespace prefix text to describe elements file and description. Notice that end tags have the namespace prefix text applied to them as well. Lines 13-16 apply namespace .

TỪ KHÓA LIÊN QUAN