XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Grand Challenge: the same query, independent of how datarelationships are modeled

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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS