|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Just as the arrangement of the elements gives a logical structure, so the arrangement of the entities gives a physical structure. Now, suppose that an included entity also contains elements. On the face of it, this might not pose such a problem. It certainly does become a problem, however, if the included entity contains elements with the same element type name as elements already present in the document. This problem will be addressed by a mechanism called namespaces, which will be available in a future release of the XML specification. Element conflicts are one problem; there is another. Suppose that you had opened an element in the root entity (your XML document) and referenced an external entity. Again, its not a problem; rather, its a normal thing to do. Suppose, however, that the external entity contains an end tag for the element you just opened. Suddenly, your whole logical structure is ruined. To try and limit the occurrence of these problems, the logical and physical structures of XML entities must be synchronous; logical entities cannot span physical entity boundaries. When this isnt the case, it can cause a lot of problems. Markup DelimitersTable 12.2 identifies the parts of XMLs element tags. It is worth remembering that where HTML relies on recognizing pre-programmed tags, XML is triggered by these specific parts of the element tags and the XML processors behavior, and what it expects to see next is directly controlled by the named symbols.
Element MarkupXML is concerned with element markup. This might sound like an obvious point to make, but it is worth repeating because it indicates a deeply rooted conceptual difference between XML as a markup language and as an arbitrary tag language. As you have already seen, HTML often tends toward being a tag language rather than a markup language, which is a direct consequence of Web browsers being so intentionally lenient in accepting bad markup. Instead of XMLs tags being markers that indicate where a style should change or where a new line should begin, most of XMLs element markup should be considered as objects composed of three parts: a start tag, the contents, and the end tag, as shown in Table 12.3. The start tag and end tags should be treated like wrappers, and when you think of an element, you should have a mental picture of a piece of text with both tags in place.
Note that the element name that appears in the start tag must be the same as the name that appears in the end tag; the following would be wrong because XML is case sensitive: <simple.element>This element wont close!</simple.Element> Attribute MarkupAs you learned in the previous chapter, attributes are used to attach additional information to XML elements. The general form for using an attribute is <element_name property=value> or <element_name property=value> The technical description of the markup of this attribute specification is given in Table 12.4.
Note that an attribute value must be enclosed in quotation marks. You can use either single quotes (<lie size=big>) or double quotes (<lie size=massive>), but you cannot mix the two in the same specification. When you are working without a DTD (all the XML code shown in this chapter does not require you to associate a DTD with the XML documentwell discuss creating DTDs in Chapter 14), you can specify the attribute and its value when you use the element for the first time, as shown below. When you specify attributes for the same element more than once, the specifications are simply merged. For instance, in the following code, the second use of the para element adds the color attribute to the number attribute that is used in the first use: <?xml version=1.0"?> <home.page> <para number=first>This is the first paragraph.</para> <para number=second color=red>This is the second paragraph.</para> </home.page>
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |