[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Grand Challenge: the same query, independent of how datarelationships ar

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Thu, 20 Feb 2014 13:46:22 +0000

Grand Challenge: the same query
Michael Kay wrote:

	There are actually three basic ways of modelling 
	relationship in XML: use of the XML containment 
	hierarchy, use of intra-document links, and use of 
	cross-document links; and the way you write queries 
	is totally dependent on which representation has 
	been chosen.

Let's illustrate each of the 3 types of relationships:

--------------------
XML Hierarchy
--------------------
This models the relationship between a Book and a Title using the XML containment hierarchy:

<Books>
    <Book>
        <Title>Illusions</Title>
        <Author>Richard Bach</Author>
    </Book>
    <Book>
        <Title>The First and Last Freedom</Title>
        <Author>J. Krishnamurti</Author>
    </Book>
</Books>

The query for retrieving the Title of the Book written by Richard Bach is:

	//Book[Author eq 'Richard Bach']/Title

-----------------------------
Intra-document Links
-----------------------------
This models the relationship between a Book and a Title using intra-document links:

<Books>
    <Book idref="RB">
        <Author>Richard Bach</Author>
    </Book>
    <Book idref="JK">
        <Author>J. Krishnamurti</Author>
    </Book>
    <Titles>
        <Title id="RB">Illusions</Title>
        <Title id="JK">The First and Last Freedom</Title>
    </Titles>
</Books>

The query for retrieving the Title of the Book written by Richard Bach is:

	//Book[Author eq 'Richard Bach']/id(@idref)

-----------------------------
Cross-document Links
-----------------------------
This models the relationship between a Book and a Title using cross-document links:

<Books xmlns:xlink="http://www.w3.org/1999/xlink/namespace">
    <Book idref="RB" xlink:href="Titles.xml">
        <Author>Richard Bach</Author>
    </Book>
    <Book  idref="JK" xlink:href="Titles.xml">
        <Author>J. Krishnamurti</Author>
    </Book>
</Books>

Here is the XML document that is being linked to (Titles.xml):

<Titles>
    <Title id="RB">Illusions</Title>
    <Title id="JK">The First and Last Freedom</Title>
</Titles>

The query for retrieving the Title of the Book written by Richard Bach is:

    //Book[Author = 'Richard Bach']/doc(@xlink:href)//Title[@id eq 'RB']

Michael then goes on to say:

	Ideally, the choice of document boundaries shouldn't 
	make much difference; queries should work the same 
	way regardless of where the document boundaries are. 

	... queries that are totally dependent on which 
	representation has been chosen ... violates the basic 
	principles of data independence.

Fascinating!

So, we want to be able to express:

	Give me the Title of the Book that was written by 
	Richard Bach.

and that should give us the correct answer, regardless of how the Book/Title relationship is modeled. 

Right?

How do we achieve this?

Is it a matter of changing XML?

Is it a matter of changing XPath/XQuery?

/Roger




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.