BN.com Gift Guide

Beginning XML Databases

Overview

  • Supported by all major database systems, XML provides an easy, standardized method of transferring data between databases and to and from the Web, independent of the software in use
  • Offers database programmers and data-driven Web developers detailed guidance on how to understand and work with XML as data
  • Numerous hands-on, step-by-step examples help readers learn to simplify...
See more details below
Other sellers (Paperback)
  • All (20) from $1.99   
  • New (8) from $9.96   
  • Used (12) from $1.99   
Sending request ...

Overview

  • Supported by all major database systems, XML provides an easy, standardized method of transferring data between databases and to and from the Web, independent of the software in use
  • Offers database programmers and data-driven Web developers detailed guidance on how to understand and work with XML as data
  • Numerous hands-on, step-by-step examples help readers learn to simplify database work using XML
  • Shows how to use XML to exchange data between multiple databases either internally or with external customers and partners
  • Covers XML in popular databases including Oracle Database, SQL Server, and brief coverage of DB2 Database
  • Covers basic syntax for XML, the XML DOM, and XSL – with an emphasis on database use, and native XML databases
  • Additional topics covered include Native XML databases, XPath, XQuery, XLink, XPointer, DTDs, XML Schemas, among others
Read More Show Less

Editorial Reviews

From the Publisher
“The book can be used as a very good introductory text for students and practitioners eager to acquire knowledge...” (Zentralblatt MATH, Vol. 1118 2007/20)
Read More Show Less

Product Details

  • ISBN-13: 9780471791201
  • Publisher: Wiley
  • Publication date: 11/13/2006
  • Series: Wrox Beginning Guides
  • Edition number: 1
  • Pages: 470
  • Sales rank: 1,306,612
  • Product dimensions: 7.40 (w) x 9.24 (h) x 1.05 (d)

Meet the Author

Gavin Powell has a BSc. in Computer Science, along with numerous professional accreditations and skills. He has had a lot of practice with things like XML, Oracle, Ingres, and MSAccess, as well as a multitude of application development languages and platforms. He has almost 20 years of contracting, consulting, and hands-on educating experience—in both software development and database administration roles. He has lived, studied, and worked on three different continents, and is now scratching a living as a writer, musician, and family man. He can be contacted at creativemusician@bellsouth.net or info@oracledbaexpert.com.

Read More Show Less

Read an Excerpt

Beginning XML Databases


By Gavin Powell

John Wiley & Sons

Copyright © 2007 John Wiley & Sons, Ltd
All right reserved.

ISBN: 978-0-471-79120-1


Chapter One

What Is XML?

This chapter provides a brief summary of what XML is. The abbreviation "XML" refers to eXtensible Markup Language, which means that XML is extensible or changeable. HTML (Hypertext Markup Language), on the contrary, is a non-extensible language and is the default language that sits behind many of the web pages in your web browser, along with numerous other languages.

HTML does not allow changes to web pages. HTML web pages are effectively frozen in time when they are built and cannot be changed when viewed in a browser.

Internet Explorer and Netscape are browsers used for viewing websites on the Internet.

XML, on the other hand, allows generation of web pages on the fly. XML allows storage of changeable data into web pages that can be altered at any time besides runtime. XML pages can also be tailored in look, feel, and content, and they can be tailored to any specific user looking at a web page at any point in time.

In this chapter you learn:

What XML is

What XSL is

The differences between XML and HTML

Basic XML syntax

The basics of the XML DOM

Details about different browsers and XML

The basics ofthe DTD (Document Type Definition)

How to construct an XML document

Reserved characters in XML

How to ignore the XML parser

What XML namespaces are

How to handle XML for multiple languages

Let's begin by comparing XML with HTML, the Hypertext Markup Language.

Comparing HTML and XML

XML can, in some respects, be considered an extensible form of HTML. This is because HTML is restrictive in terms of the tags it is allowed to use. In the following sample HTML document, all tags, such as , are predefined:

This is a simple HMTL page

Once more unto the breach, dear friends, once more; or close the wall up with our English dead. In peace there's nothing so becomes a man as modest stillness and humility; but when th' blast of war blows in our ears, then imitate the action of the tiger: stiffen the sinews, summon up the blood, disguise fair nature with hard-favour'd rage; then lend the eye a terrible aspect.

Cry 'Havoc !' and let slip the dogs of war, that this foul deed shall smell above the earth with carrion men, groaning for burial.

Figure 1-1 shows the execution of this script in a browser. You can see in the figure that none of the tags appear in the browser, only the text between the tags. In the preceding sample HTML page code, the tags are all predefined and enclosed within angle brackets (< ... >). An HTML document will always begin with the tag and end with the corresponding closing tag . Other tags shown in the above script are , , <BODY>, and <P>. The <P> tag is used for paragraphs. <p> Unlike HTML, XML is extensible and thus is capable of being extended or modified by changing or adding features. XML can have tags of its own created (customized) that are unique to every XML document created. An XML document when embedded into an HTML page needs the predefined tag that an HTML page does, such as <HTML> and <P>, but XML can also make up its own tags as it goes along. <p> <i>An important restriction with respect to the construction of XML documents that is not strictly applied in HTML code is that all tags must be contained within other tags. The root node tag is the only exception. Examine the previous HTML coding example and you will see that in the source code the first paragraph does not have a terminating </P> tag (using the / or forward slash character). HTML does not care about this. XML does!</i> <p> <p> <b>What Is XML Capable Of?</b> <p> So, XML is not limited to a predefined set of tags as HTML is, but allows the creation of customized tags. The advantages of using XML could loosely be stated as follows: <p> <b>Flexibility with data:</b> Any information can be placed into an XML page. The XML page becomes the data rather than the definitional container for data, as shown in Figure 1-1. <p> <b>Web page integration:</b> This becomes easier because building those web pages becomes more generic. Web pages are data driven (based on content in the web page) rather than relying on the definition of the tags (programming language-driven) and where the tags are placed. <p> <b>Open standards:</b> XML is completely flexible. No single software company can control and define what tags are created, what each tag means, and where in a document tags should appear. XML is a little like a completely generic programming language. <p> <b>Enhanced scalability and compression:</b> When sending web pages over the Internet, XML pages can contain just data. All the coded programming tags required for HTML are not needed. <p> <b>Irrelevant order of data:</b> The order in which data appears in an XML page is unimportant because it is data. Data can have things applied to it at the client site (in a browser) to change it, if you use something like eXtensible Style Sheets (XSL). <p> <p> <b>What Is XSL?</b> <p> XSL is a formatting language that applies templating to consistent data repetitions inside XML documents. For example, an XML page containing a listing of clients and their addresses could be formatted into a nice looking table field using an XSL style sheet that showed each different client on a single row in the table, as shown in Figure 1-2. <p> <i>The HTML equivalent of XSL is cascading style sheets (CSS).</i> <p> <p> <b>Creating and Displaying a Simple XML Document</b> <p> Following is a sample XML document. The only required predefined tag is on the first line, which describes that the version of the XML parser used is version 1.0: <p> <?xmlversion="1.0"?> <WeatherForecast date="2/1/2004"> <city> <name>Frankfurt</name> <temperature> <min>43</min> <max>52</max> </temperature> </city> <city> <name>London</name> <temperature> <min>31</min> <max>45</max> </temperature> </city> <city> <name>Paris</name> <temperature> <min>620</min> <max>74</max> </temperature> </city> </WeatherForecast> <p> <p> <i>A parser is a program that analyzes and verifies the syntax of the coding of a programming language. An XML- capable browser parses XML code to ensure that is syntactically correct. As already mentioned, one parser function is to ensure that all starting and ending tags exist, and that there is no interlocking of XML tags within the document. Interlocking implies that a new tag of the same type, such as <city>, cannot be started, until the ending tag of the previous city (</city>), has been found.</i> <p> <p> In a browser, the XML document looks as shown in Figure 1-3. The callouts in Figure 1-3 show that in addition to being flexible for a web pages programmer, XML is even flexible to the end user. End users are unlikely to see an XML document in this raw state, but Figure 1-3 helps to demonstrate the flexibility of XML. <p> The primary purpose of HTML is for display of data. XML is intended to describe data. XML is the data and thus describes itself. When HTML pages contain data, they must be explicitly generated. For every web page weather report written in HTML, a new HTML page must be created. This includes both the weather report data and all HTML tags. When regenerating an XML-based weather report, only the data is regenerated. Any templates using something like XSL remain the same. And those templates are probably only downloaded once. The result is that XML occupies less network bandwidth and involves less processing power. <p> XML is also a very capable medium for bulk data transfers that are platform and database independent. This is because XML is a universal standard. In short, XML does not do as much processing as HTML does. XML is structure applied to data. Effectively XML complements HTML rather than replaces it. XML was built to store and exchange data; HTML is designed to display data. XSL, on the other hand, is designed to format data. <p> <p> <b>Try It Out <p> Creating a Simple XML Document</b> <p> The data shown below represents three regions containing six countries: <p> Africa Zambia Africa Zimbabwe Asia Burma Burma Australasia Australia Caribbean Bahamas Caribbean Barbados <p> <p> Here, you are going to create a single hierarchy XML document. The example shown in Figure 1-3, and its preceding matching XML data, gives you an example to base this task on. <p> Create the XML document as follows: <p> <b>1.</b> Use an appropriate editor to create the XML document text file (Notepad in Windows). <p> <b>2.</b> Create the XML tag: <p> <?xml version="1.0"?> <p> <b>3.</b> Create the root tag first. The data is divided up as countries listed within continents (regions). Countries are contained within regions. There are multiple regions so there has to be a tag, which is a parent tag of the multiple regions. If there was a single region there could be a single <region> tag as the root node. So create a root node such as <regions>, indicating multiple regions. The XML document now looks something like this: <p> <?xml version="1.0"?> <regions> </regions> <p> <b>4.</b> Now add each region in as a child of the <regions> tag. It should look something like this: <p> <?xml version="1.0"?> <regions> <region>Africa</region> <region>Asia</region> <region>Australasia</region> <region>Caribbean</region> </regions> <p> <b>5.</b> Next you can add the individual countries into their respective regions by creating individual <country> tags: <p> <?xml version="1.0"?> <regions> <region>Africa</region> <country>Zambia</country> <country>Zimbabwe</country> <region>Asia</region> <country>Burma</country> <region>Australasia</region> <country>Australia</country> <region>Caribbean</region> <country>Bahamas</country> <country>Barbados</country> </regions> <p> <b>6.</b> When executed in a browser, the result will look as shown in Figure 1-4. <p> <p> <b>How It Works</b> <p> You opened a text editor and created an XML document file. The XML document begins with the XML tag, identifying the version of XML is use. Next you added the root node called <regions>. All XML documents must have a single root node. Next you added four <region> nodes representing four regions into the root node. Next you added countries into the four different regions. Last, you viewed the XML document in your browser. <p> <p> <b><i>Embedding XML in HTML Pages (Data Islands)</i></b> <p> XML documents can also be displayed in a browser using an XML data island. An <i>XML data island</i> is an XML document (with its data) directly or indirectly embedded inside an HTML page. An XML document can be embedded inline inside an HTML page using the HTML <XML> tag. It can also be referenced with an HTML SRC attribute. <p> This first example uses the XML tag to embed XML document data within an HTML page: <p> <HTML><BODY> <p> <XML ID="xmlParts"> <?xml version="1.0" ?> <parts> <part> <partnumber>X12334-125</partnumber> <description>Oil Filter</description> <quantity>$24.99</quantity> </part> <part> <partnumber>X44562-001</partnumber> <description>Brake Hose</description> <quantity>$22.45</quantity> </part> <part> <partnumber>Y00023-12A</partnumber> <description>Transmission</description> <quantity>$8000.00</quantity> </part> </parts> </XML> <p> <TABLE DATASRC=#xmlParts> <TR> <p> <TD><DIV DATAFLD="partnumber"></DIV></TD> <TD><DIV DATAFLD="$text"></DIV></TD> </TR> </TABLE> <p> </BODY></HTML> <p> <p> <i>HTML and XML tags can have attributes or descriptive values. In the HTML code</i> <IMG SRC= "image.jpg" BORDER="1"> <i>the tag is an</i> <IMG> <i>or image tag for referencing an image. The</i> SRC <i>attribute tells the HTML</i> <IMG> <i>tag where to find the image, and the</i> BORDER <i>tag tells HTML to put a "1" pixel wide border around the image.</i> <p> <p> The second example allows a reference to a separate XML file using the SRC attribute of the XML tag. <p> The XML source file is stored externally to the HTML page. In this case, the parts.xml file is stored in the operating system and not stored within the HTML file as in the previous example: <p> <HTML><BODY> <p> <XML ID="xmlParts" SRC="parts.xml"></XML> <p> <TABLE DATASRC=#xmlParts> <TR><TD><DIV DATAFLD="partnumber"></DIV></TD> <TD><DIV DATAFLD="$text"></DIV></TD> </TR> </TABLE> <p> </BODY></HTML> <p> <p> Both of these examples look as the screen does in Figure 1-5. <p> There are always different ways to do things. <p> <p> <b>Try It Out <p> XML Data Islands</b> <p> The XML document that follows represents the three regions and six countries created in the Try It Out exercise presented earlier in this chapter: <p> <?xml version="1.0"?> <regions> <region>Africa</region> <country>Zambia</country> <country>Zimbabwe</country> <region>Asia</region> <country>Burma</country> <region>Australasia</region> <country>Australia</country> <region>Caribbean</region> <country>Bahamas</country> <country>Barbados</country> </regions> <p> <p> Here we will create a simple HTML page, containing the preceding XML document as a data island. Assume that the XML document is called countries.xml. Don't worry about a full path name. The example shown in Figure 1-5 and its preceding matching XML data island HTML pages give you an example to base this task on. <p> Create the HTML page as follows: <p> <b>1.</b> Use an appropriate editor to create a text file. <p> <b>2.</b> Begin by creating the <HTML> tags for the start and end of the HTML page: <p> <HTML> </HTML> <p> <b>3.</b> You could add a <HEAD> tag, allowing inclusion of a title into the browser. Begin by creating the <HTML> tags for the start and end of the HTML page: <p> <HTML> <HEAD><TITLE>Regions and Countries

4. Add the body section for the HTML page by enclosing it between the tags:

Regions and Countries

5. Now add the tag into the body of the HTML page, which references the externally stored XML document:

Regions and Countries

6. Add a table field (

tag) to the HTML page. The table field references the tag, by the ID attribute, as shown in the code that follows. The SRC in the tag allows direct access from the HTML page to XML tags as stored in the countries.xml file. In other words, the countries.xml file is referenced from the HTML page as a referenced data island:

Regions and Countries

7. The result will look as shown in Figure 1-6, when executed in a browser.

How It Works

You created an HTML page that referenced an XML document from the HTML page as a data island. The data island is referenced from the HTML page, to the XML document, using the XML tag as defined in the HTML page. Data is scrolled through in the HTML page using an HTML table field, using the DATASRC attribute of the HTML

tag.

(Continues...)



Excerpted from Beginning XML Databases by Gavin Powell Copyright © 2007 by John Wiley & Sons, Ltd. Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Introduction.

Chapter 1: What Is XML?

Comparing HTML and XML.

What Is XML Capable Of?

What Is XSL?

Creating and Displaying a Simple XML Document.

Embedding XML in HTML Pages (Data Islands).

Introducing the XML Document Object Model.

XML Browsers and Different Internet Browsers.

The Document Type Definition.

XML Syntax.

Elements.

Attributes.

Reserved Characters in XML.

Ignoring the XML Parser with CDATA.

What Are XML Namespaces?

XML in Many Languages.

Summary.

Exercises.

Chapter 2: The XML Document Object Model.

Basic XML DOM Structure.

The Primary XML DOM Classes.

The Node Class.

The Document Class.

The Element Class.

The Attr Class.

The Text Class.

More Obscure XML DOM Classes.

The parseError Class.

HTTPRequest Class.

Other Classes.

Generating XML Using ASP.

Summary.

Exercises.

Chapter 3: Extending the Power of XML with XSL.

What Is XSL?

The Roots of XSL.

Basic XSL Elements Syntax.

Processing Instruction Elements.

Transformation Elements.

Node Creation Elements.

Data Retrieval Elements.

Control Structure Elements.

Advanced XSL Syntax.

Function Versus Method.

XSL Function Syntax.

XSL Method Syntax.

XSL Pattern Matching Syntax.

Combining the XML DOM and XSL.

Summary.

Exercises.

Chapter 4: Relational Database Tables and XML.

Using SQL for Database Access.

Queries.

Changing Data in a Database.

Generating XML Pages Using Basic SQL.

Summary.

Exercises.

Chapter 5: Oracle Database and XML.

The Oracle XMLType Data Type.

Oracle XMLType Data Type Methods.

Implementing XML in an Oracle Database.

Creating XML Documents from an Oracle Database.

XML and the Database.

New XML Documents.

Retrieving from XML Documents.

Using XMLType Methods to Read XML Documents.

Changing and Removing XML Document Content.

Summary.

Exercises.

Chapter 6: SQL Server and XML.

The SQL Server XML Data Type.

SQL Server XML Data Type Methods.

Generating XML: The FOR XML Clause.

FOR XML RAW Mode.

FOR XML AUTO Mode.

FOR XML EXPLICIT Mode.

FOR XML PATH Mode.

Generating Tuples from XML: OPENXML.

Working with XML Data Types.

Adding XML Documents to SQL Server.

Retrieving and Modifying XML Data Types.

Defining XML Content with XSD Schemas.

Strongly Typing XML Documents with XSD.

Mapping an XSD Schema to a Table.

Annotating the XSD Script to Enforce Relationships.

Storing XSD as a Schema Collection.

Creating Indexes on XML Data Types.

Summary.

Exercises.

Chapter 7: XML in Heterogeneous Environments.

Basic XML Document Transfer.

Sharing XML with Web Services.

The HTTP Protocol.

Transformation Processing.

Web Services Protocol.

Applying Semantics to XML Transfers.

Simple Object Access Protocol.

External Data and XML.

B2B Data Transfer.

Summary.

Exercises.

Chapter 8: Understanding XML Documents as Objects.

Why Explain the Object Model Here?

XML Data as a Relational Structure.

The Basics of the Object Data Model.

Creating an Object Model from a Relational Model.

XML Data as an Object Structure.

Summary.

Exercises.

Chapter 9: What Is a Native XML Database?

An XML Document Is a Database.

Defining a Native XML Database.

Creating a Native XML Database.

Schema-Less Native XML Database Collections.

What Is Indexing?

What About Using XSL and the XML DOM?

Classify Native XML Databases by Content.

Document-Centric XML.

Data-Centric XML.

Using a Native XML Database.

Summary.

Exercises.

Chapter 10: Navigating XML Documents Using XPath.

What Is XPath?

Absolute and Relative Paths.

XPath Nodes.

XPath Node Relationships.

XPath Expression Syntax.

Simple Expressions to Find Nodes.

Find Specific Values Using Predicates.

Use Wildcards to Find Unknown Nodes.

Expressions on Multiple Paths.

XPath Axes.

XPath Functions.

Accessor Functions.

Errors and Tracing.

Constructor Functions.

Numeric Functions.

String Functions.

URI Functions.

Boolean Functions.

Functions on Durations, Dates, and Times.

QName Functions.

Node Functions.

Sequence Functions.

Context Functions.

Summary.

Exercises.

Chapter 11: Reading XML Documents Using XQuery.

What Is XQuery?

Shared Components.

The Basics of XQuery.

Executing XQuery Queries.

Embedding XQuery Code into HTML.

XQuery Terminology.

XQuery Syntax.

Functions in XQuery.

XQuery FLWOR.

FLWOR: The Basic for Loop and Return Clause.

FLWOR: Adding a where Clause.

FLWOR: Adding an Order By Clause.

FLWOR: Declaring Variables with the Let Clause.

FLWOR: Embedded for Loops and Communication.

XQuery in Oracle XML DB.

What Is XQueryX?

Summary.

Exercises.

Chapter 12: Some Advanced XML Standards.

XLink and XPointer.

What Is XLink?

Simple XLinks.

Extended XLinks.

What Is XPointer?

XForms and HTML Form Generation.

The XForms Model.

XForms Namespaces.

Other XForms Input Types.

Data Types in XForms.

Restricting Values with XForms Properties.

XForms Object Actions.

Built-in and User-Defined Functions.

Binding Data Using XPath.

Embedding XML Documents with XInclude.

Formatting XML Output Using XML-FO.

Summary.

Exercises.

Chapter 13: Data Modeling and XML.

The Document Type Definition.

DTD Elements.

DTD Attributes.

DTD Entities.

The XML Schema Definition.

Global and Local Types.

Basic XSD Structures.

Substitution.

Summary.

Exercises.

Chapter 14: Applying XML Databases in Industry.

What Can XML Do?

Managing Complex Data with XML.

Does Database Size Matter?

Are Schema Changes Easier with XML?

Native XML Databases.

Specific XML Vocabularies.

XML Vocabularies.

Commercial Implementation of XML.

When to Use a Native XML Database.

Summary.

Glossary.

Appendix A: Exercise Answers.

Appendix B: The Sample Database.

Appendix C: Syntax Conventions.

Appendix D: XML Technology.

Appendix E: XML Relational Database Technology.

Index.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

We're sorry, but penname is already taken.

Please select one of the following:
 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

penname is available!

By visiting the BN.com website or marking a purchase on BN.com, a User is deemed to have accepted the Terms of Use.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)