Flylib.com

Books Software

 
 
 

Embedding XML Documents with XInclude

Embedding XML Documents with XInclude

The W3C definition of XInclude is available at http://www.w3.org/TR/xinclude. Essentially, you can include one script within another. The following script should merge two included XML regional documents into a single demographics document containing a collection of regions (this does not function in Internet Explorer 6):



<?xml version="1.0"?>
<demographics xmlns:xi="http://www.w3.org/2001/XInclude">
   <xi:include href="./Africa.xml"/>
   <xi:include href="./Asia.xml"/>
</demographics>


Formatting XML Output Using XML-FO

XML-FO or XML Format is used to format and beautify the output of XML for output display to the user . In reality, XML-FO is the formatting part of XSL (as opposed to XSLT). Both of these have already been covered extensively in this book.

This chapter has expanded more into the realm of front-end applications rather than specific database activity. Still, XLink, XPointer, and XForms are important XML technologies, even if only partially database-driven in nature. The next chapter examines Document Type Definitions (DTD) and XML Schemas both of which are used to form a direct mapping between XML document data and relational database table structures.

This chapter has no Try It Out sections because a large majority of this functionality is not released for general use and may depend on browser type and version.

Summary

In this chapter you learned that:

  • XLink allows for generation of generic links into web pages, based on XML document content.

  • XLink links to entire XML documents and XPointer links to fragments within XML documents.

  • Simple type XLinks link one XML document to another.

  • Extended type XLinks can link many XML documents to many other XML documents.

  • XForms is a model used to generate entry screens based on XML document content.

  • XForms allows anything and more than HTML does.

  • XForms includes a basic model, namespaces, input fields, data types, actions, and constraints.

  • XForms can bind form objects directly to the content of an XML document.

An XML document is a native XML database.

  • XInclude can be used to merge multiple XML documents into one XML document.

  • XML-FO is the formatting part of eXtensible Style Sheets (XSL).

Exercises

1. 

How many XML documents are linked to this XML document sample?



<?xml version="1.0"?>
<websites xmlns:xlink="http://www.w3.org/TR/xlink/">
   <website xlink:type="simple" xlink:href="http://www.ws1.com">Yahoo</website>
   <website xlink:type="simple" xlink:href="http://www.ws2.com">Google</website>
   <website xlink:type="simple" xlink:href="http://www.ws3">EBay</website>
</websites>


  1. None

  2. 1

  3. 2

  4. 3

  5. 4

  6. 5

image from book

2. 

Attribute xlink:from and xlink:to apply to what type of an XLink?

  1. simple

  2. extended

  3. resource

  4. locator

  5. arc

  6. None of the above

image from book

3. 

XLink links to entire XML documents and XPointer links to fragments within individual XML documents. True or False?

image from book

4. 

How is XForms more powerful than HTML?

  1. XForms has greater functionality.

  2. XForms has more flexibility based on its generation from XML document content.

  3. XForms has all the capabilities of HTML.

  4. XForms is far more complex to use than HTML.

  5. All of the above.

  6. None of the above.

image from book

Answers

1.  

Exercise 1 solution

d. 3 is the correct answer because the XLinks are all simple types links (one source to one target). There are three XLink definitions from the current document and thus the current document is excluded because it is not linked back to.

2.  

Exercise 2 solution

e. arc is the correct answer. An arc XLink type describes the route between two resource links, and thus the arc proceeds from one resource link to another resource link.

3.  

Exercise 3 solution

The answer is True. XPointer points to an address, whereas XLink only links to a file.

4.  

Exercise 4 solution

f. None of the above is probably the best answer. XForms does have greater functionality, but only in the form of a few more built-in functions. However, look at the functionality and flexibility in HTML and XForms becomes solely data centric. HTML encompasses much, much more than just data-driven display. XForms absolutely does not have all the functionality of HTML because there is much more to HTML than just forms. It might be debatable as to whether XForms is more complex than HTML or not. From a programmers perspective, the flexibility of XForms, and the rigidity and coding intensity of HTML, XForms is much easier to deal with.