Internet and World Wide Web Resources

Contains a description of the historical uses of DTDs, including a description of SGML and the HTML DTD. A repository of DTDs for XML documents. www.xml101.com dtd Contains tutorials and explanations on creating DTDs. index3.html Contains DTD tutorials and examples. A DTD repository with XML links and resources. sample.asp Download page for Microsoft's XML Validator. Document Type Definitions (DTDs) define an XML document's structure (e.g., what elements, attributes, etc. are permitted in the...

Creating and Using Image Maps

We have seen that images can be used as links to other places on your site or elsewhere on the Internet. We now discuss how to create image maps (Fig. 3.7), which allow you to designate certain sections of the image as hotspots and then use these hotspots as links. All elements of an image map are contained inside the < map> < map> tags. The required attribute for the map element is name (line 17) < map name picture> As we will see, this attribute is needed for referencing purposes....

Welcome to Our Web Site

We have designed this site to teach about the wonders of HTML. We have been using HTML since version 2.0, and we enjoy the features that have been added recently. It seems only a short time ago that we read our first HTML book. Soon you will know about many of the great new features of HTML 4.01. Fig. 3.9 Web site using two frames navigation and content (part 2 of 2). On lines 1 and 2 < DOCTYPE HTML PUBLIC - W3C DTD HTML 4.01 Frameset EN .dtd > 70 Introduction to HyperText Markup Language 4...

Microsoft XML Schema Describing Elements

Elements are the primary building blocks used to create XML documents. In Microsoft XML Schema, element ElementType defines an element. ElementType contains attributes that describe the element's content, data type, name, etc. Portability Tip 7.1 To use Microsoft XML Schema, Microsoft's XML parser (msxml) is required this parser is part of Internet Explorer 5. Fig. 7.1 presents a complete schema. This schema describes the structure for an XML document that marks up messages passed between...

Conditional Processing

In the previous section, we discussed iteration of a node set. XSLT also provides elements to perform conditional processing, such as if statements. Figure 12.11 provides an XSLT document used to transform the day planner created in previous chapters into an HTML document. < xml version 1.0 > < -- Fig. 12.11 conditional.xsl < -- xsl choose, xsl when, and xsl otherwise < xsl stylesheet version 1.0 xmlns xsl < xsl template match > < html> < xsl apply-templates select planner...

Other HTML Documents

In this section, we present two other documents used in the case study. Figure 15.11 lists the HTML document that displays error messages (invalid.html). 1 < LANGUAGE VBScript > 412 Case Study Message Forum with Active Server Pages Dim xmlFile, xmlRoot, xmlNode Dim strTitle, strError, strPath If Request( submit ) < > Empty Then If Request( file ) < > Empty And _ Request( user ) < > Empty And _ Request( title ) < > Empty And _ Request( text ) < > Empty Then 1 Lock...

Nested and Ordered Lists

Figure 2.9 demonstrates nested lists (i.e., one list inside another list). This feature is useful for displaying information in outline form. < DOCTYPE HTML PUBLIC - W3C DTD HTML 4.01 EN < -- Fig. 2.9 list.html --> < -- Advanced Lists nested and ordered --> < title> XML How to Program - Lists< title> < head> < h1> The Best Features of the Internet< h1> < ul> < li> You can meet new people from countries around the world.< li> < li> You have access to...

Implementation Client Side of Xml Messenger

In this section, we discuss the client-side of XmlMessenger. Figure 10.9 contains the source code for MessengerClient.java, which manages the connection with the server Fig. 10.10 contains the source code for ClientStatus .java, which creates the status window for the user after login, and Fig. 10.11 contains the source code for Con-versation.java, which implements an individual conversation with another user. Fig. 10.8 User1's updated GUI after User4 logs in. 380 Fig. 10.9 MessengerClient.java...

Combining Stylesheets

XSLT allows for modularity in stylesheets. This feature enables XSLT documents to import other XSLT documents. Figure 12.16 lists an XSLT document that is imported into the XSLT document in Fig. 12.17 using element import. 1 < xml version 1.0 encoding UTF-8 > 2 < -- The following XML tree has been copied into output. 4 < message> Welcome to XSLT < message> < -- Fig. 12.16 usage2.xsl < -- xsl import example < xsl stylesheet version 1.0 xmlns xsl < xsl template match book>...

Nested framesets

Nested Framesets

You can use the frameset element to create more complex layouts in a framed Web site by nesting frameset areas as in Fig. 3.10. The first level of frameset tags is on lines 21 and 22 frameset cols 110, gt frame name navsrc nav.html gt The frameset and frame elements here are constructed in the same manner as in Fig. 3.9. We have one frame that extends over the first 110 pixels starting at the left edge. The second nested level of the frameset element covers only the remaining frame area that...

Example Tree Diagram

Figure 9.3 is a program that parses an XML document with a SAX-based parser and outputs the document's data as a tree diagram. Using the SAX Parser to generate a tree diagram, import java.io. import org.xml.sax. for HandlerBase class import javax.xml.parsers.SAXParserFactory import import javax.xml.parsers.SAXParser public class Tree extends HandlerBase private int indent 0 indentation counter returns the spaces needed for indenting private String spacer int count for int i 0 i lt count i temp...

Markup

This section elaborates on elements and their attributes as well as how they are used to construct proper XML markup. XML element markup consists of a start tag, content and an end tag. Unlike HTML, all XML start tags must have a corresponding end tag. For example, lt img src img.gif gt is correct HTML, but in XML, the ending tag must also be supplied, as in lt img src img.gif gt lt img gt This type of element is called an empty element , because it does not contain content i.e., character data...

Good Programming Practice

Rlz Identifier

By convention, Microsoft XML Schema authors use namespace prefix dt when referring to the URI urn schemas-microsoft-com datatypes. char A single character e.g., D . string A series of characters e.g., Deitel . Fig. 7.12 Some Microsoft XML Schema data types part 1 of 2 . float A real number e.g., 123 .4567890 . date A date formatted as YYYY-MM-DD e.g., 2000-04-25 . time A time formatted as HH-MM-SS e.g., 14 30 00 . id Text that uniquely identifies an element or attribute. enumeration A series of...

DOM Components

In this section, we will use Java, JAXP and the XML-related Java packages described in Fig. 8.4 to manipulate an XML document. Before discussing our first Java-based example, we summarize several important DOM classes, interfaces and methods. Due to the number of DOM objects and methods available, we provide only a partial list of these objects and methods. For a complete list of DOM classes and interfaces, browse the HTML documentation index.html in the api folder included with JAXP. Node...

Using Unicode in an XML Document

This section demonstrates XML's Unicode support. Figure 5.4 lists an XML document that displays Arabic words. Each Arabic character is represented by an entity reference for a Unicode character. Each line that contains a series of entity references represents one Arabic word. When translated to English, element from line 9-17 contains Deitel and Associates and element subject lines 19-29 contains Welcome to the world of Unicode. Fig. 5.4 XML document that contains Arabic words part 1 of 2 ....

Case Study Writing a Microsoft XML Schema for the Day Planner Application

Figure 7.20 is a Microsoft XML Schema for the day planner introduced in Chapter 5. lt xml version 1.0 gt lt -- Fig. 7.2 0 planner-schema.xml -- gt lt -- Microsoft XML Schema for day planner -- gt lt Schema xmlns xmlns dt lt ElementType name planner content eltOnly model closed gt lt element type year minOccurs 0 maxOccurs gt lt ElementType gt lt ElementType name year content eltOnly model closed gt lt AttributeType name value dt type int gt lt attribute type value gt lt element type date...

Case Study A Wireless Online Bookstore

In this section we present a case study that uses XML and XSL with Java servlets and the Wireless Applications Protocol WAP to build a wireless online bookstore. WAP uses the Wireless Markup Language WML , which adheres to the XML 1.0 recommendation from the World Wide Web Consortium W3C . Many digital cellular phones now support WAP for browsing the Web, reading e-mail and shopping online. Using WAP will allow customers to purchase books from our store using these devices. The wireless...

XML Linking Language XLink

In Chapter 2, we discussed HTML's a element and href attribute for linking to documents on the Web. The W3C has been actively developing a specification, called the XML Linking Language XLink , for linking to resources from an XML document. As we will soon discover, XLink goes far beyond HTML linking. XLink is currently a W3C Candidate Recommendation i.e., one step away from becoming a W3C Recommendation . XLink was designed using ideas from other linking standards HTML, HyTime and the Text...

Iteration and Sorting

XSLT also allows for iteration through a node set returned by an XPath expression. The node set can also be sorted. Figure 12.8 shows an XML document we introduced in Chapter 5. At the time we introduced this XML document, we briefly introduced the concept of an XSL stylesheet. Figure 12.9 shows the XML stylesheet used to render the document. Figure 12.9 lists an XSLT document for transforming this XML document into an HTML document. 1 lt xml version 1.0 gt 3 lt -- Fig. 12.8 usage.xml -- gt 4...

Creating Elements and Attributes

In the previous section, we demonstrated the use of XSLT for simple element matching. This section discuss the creation of new elements and attributes within an XSLT document. Figure 12.4 lists an XML document that marks up various sports. _ 1 lt xml version 1.0 gt 3 lt -- Fig. 12.2 intro.xml -- gt 4 lt -- Simple introduction to XML markup -- gt 6 lt xml stylesheet type text xsl href intro.xsl gt 9 lt message gt Welcome to XSLT lt message gt 10 lt myMessage gt 1 lt html gt lt body gt Welcome to...

Summary

SAX was developed by the members of the XML-DEV mailing list and is an alternative model for parsing XML documents that uses an event-based model notifications called events are raised as the document is parsed. DOM is a tree-based model, which stores the document's data in a hierarchy of nodes. Because all the document's data is in memory, data can be quickly accessed. DOM also provides facilities for adding or removing nodes i.e., modifying the document . SAX-based parsers invoke methods...

Case Study Writing a DTD for the Day Planner Application

In this section, we build upon the case study introduced in Chapter 5. Figure 6.15 lists the external subset of the DTD for the day planner XML document, planner.xml. The following document type declaration is inserted into the day planner XML document lt DOCTYPE planner SYSTEM planner.dtd gt 1 lt -- Fig. 6.15 planner.dtd -- gt 2 lt -- DTD for day planner -- gt 4 lt ELEMENT planner year gt 6 lt ELEMENT year date gt 7 lt ATTLIST year value CDATA REQUIRED gt 9 lt ELEMENT date note gt 10 lt...

Exercises

5.5 Create an XML document that marks up the nutrition facts for a package of Grandma Deitel's Cookies. A package of Grandma Deitel's Cookies has a serving size of 1 package and the following nutritional value per serving 260 calories, 100 fat calories, 11 grams of fat, 2 grams of saturated fat, 5 milligrams of cholesterol, 210 milligrams of sodium, 36 grams of total carbohydrates, 2 grams of fiber, 15 grams of sugars and 5 grams of protein.Render the XML documents in Internet Explorer 5. Hint...

Introduction

An XSL stylesheet can be used to transform an XML document into a variety of formats Fig. 13.1 . In Chapter 12, we used XSLT to transform XML documents into HTML, which is perhaps the most common use of XSLT. In this chapter, we introduce another aspect of XSL called formatting objects used to format XML documents for presentation. Formatting objects constitute the vast majority of XSL features. We present only a small subset of formatting-object features in this chapter. The latest XSL Working...

Case Study XSLT and XPath

XPath and XSL are intimately related. The examples in this chapter used simple XPath expressions to locate elements, attributes and text in XML documents. In this section, we present a more substantial example that uses more complex XPath expressions. Figure 12.25 marks up information about Deitel amp Associates, Inc.'s complete training course and Web-based training products. The document contains root element product, which has three child elements completeTrainingCourses, books and...

XML Pointer Language XPointer

The XML Pointer Language XPointer is used to reference fragments of an XML document via a URI. In Chapter 11, we discussed XPath, which allowed for selecting specific nodes in an XML document. XPointer uses XPath expressions to provide a means for referencing an XML document's nodes from a URI. The XPointer specification is currently a W3C Candidate Recommendation. For the latest XPointer specification, visit www.w3.org TR xptr. In Section 14.2, we discussed XLink, which links resources. By...

Images

We have thus far dealt exclusively with text. We now show how to incorporate images into Web pages Fig. 2.5 . lt DOCTYPE HTML PUBLIC - W3C DTD HTML 4.01 EN lt -- Fig. 2.5 picture.html -- gt lt -- Adding images with HTML -- gt lt title gt XML How to Program - Welcome lt title gt lt head gt lt p gt lt img src xmlhtp.jpg height 238 width 183 alt Demonstration of the alt attribute gt lt p gt The image in this code example is inserted in lines 14 and 15 lt p gt lt img src xmlhtp.jpg height 238 width...

Case Study A Day Planner Application

In this section, we discuss markup used by a day planner application for scheduling appointments. This case study will be enhanced in later chapters. When scheduling appointments and tasks, the date, time and appointment type are required. An XML document that marks up appointments is shown in Fig. 5.10. Line 6 is the root element planner, which holds all of the appointments. Within element planner, we have a year element, which has attribute value for storing the year being planned. If we make...