home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


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, it’s not a problem; rather, it’s 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 isn’t the case, it can cause a lot of problems.

Markup Delimiters

Table 12.2 identifies the parts of XML’s 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 processor’s behavior, and what it expects to see next is directly controlled by the named symbols.

Table 12.2 The Parts of an XML Element Tag

Symbol Description

< start tag open delimiter
</ end tag open delimiter
foo example of an XML element name
> tag close delimiter
/> empty tag close delimiter

Element Markup

XML 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 XML’s tags being markers that indicate where a style should change or where a new line should begin, most of XML’s 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.

Table 12.3 The Parts of an XML Element

Symbol Name Description

<foo> start tag at the start of an element, the opening tag
text content in the middle of an element, its content
</foo> end tag at the end of an element, the closing tag

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 won’t close!</simple.Element>

Attribute Markup

As 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.

Table 12.4 Specifying an Attribute

Symbol Description

< start tag open delimiter
element_name element name
property attribute name
= value indicator
literal string delimiter
alternative literal string delimiter
value value of the attribute
literal string delimiter
alternative literal string delimiter
> start tag close delimiter

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 document—we’ll 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>


Previous Table of Contents Next


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.