...collaborate on

Project Report

This report presents the developed work on the project "Strategic Querying of XML Documents".

The results of this project are based on two generic traversal functions, based on Strafunski. One of this functions traverses the child nodes, while the other is a deep traversal function.

One Level Traversal Deep Traversal
One level traversal collection Deep Traversal collection
XPath: /X/A XPath: /X//A
Yellow circles represent collected 'A' items.

Mapping from XPATH, we have "/" as child traversing, and "//" as a deep traversal function. What as done was to create haskell functions (using Strafunski) to represent "/" and "//".

Traversal Functions

As explained before, the solution of te problem was mostly obtained defining twa major functions, as show next:

One Level Traversal Function

taagg cond a= maybe [] id (applyTU strategy a)
                strategy = allTU (++) [] (adhocTU (constTU []) flp)
                flp x = if (cond x) then (return [x]) else (mzero)

Deep Traversal Function

deep::  (Term a, Term [a]) => (Element -> Bool) -> [a] -> [Element]
deep cond = runIdentity.applyTU strategy
                strategy= collect (adhocTU (constTU []) flp)
                flp x=if (cond x) then (return [x]) else (return [])

Query Types

As you can see on the traversal functions defitinion, we only have to define the filtering function for each datatype that a Query can have. The filtering function behaves according to the Query data type received. Query datatypes are defined as follows:

data Query =    Tag String
                | PrefTag String
                | PostTag String
                | Attr [Attrib]
                | PredTag String SFilter
                | AttrTag String [Attrib]
                | PosTag Query [Posicoes]

The possible queries have different means, as explained in next table:

Query Description
Tag Name get an element with the name 'Name'
Attr [Atts] get an element if it has all attributes in the list '[Atts]'
PosTag T [Pos] returns the positions '[Pos]' of the result of querying T
PredTag Name Pred returns all elements with name 'Name' and wich query Pred returns with success
PrefTag Name returns elements started by the string 'Name'
PrefTag Name returns elements that end with the string 'Name'
AttrTag Name [Atts] returns elements of name 'Name' with attributes '[Atts]'

The function function gives us the filter we need to apply to each of the Element intercepted in the traversal function. An example of a filter is:

function (Tag str) x@(Elem n a c) = (str=="*" || n==str)

As you can see, function returns a boolean, and it is applied as a filter on traversing functions (cond parameter on traversal functions).

Examples of queries:

The next examples show the mapping between Haskell+Strafunski queries and XPath queries:
Haskell+Strafunski XPath
(-/) Tag "alunos" / Tag "curso" /alunos/curso
(-/) Tag "curso" // PosTag (Attr "sobrenome") [pos 3] /curso//@sobrenome[3]
(-//) PrefTag "al" / Tag "nome" //al*/nome
(-/) Tag "curso" // PredTag "aluno" ((./) Tag "nome") /curso//aluno[./nome]

Future Work:

  • improve context based selection
  • implement text value selections
  • implement attribute value operations

Go back to StrategicXMLQueryingAFPProject

-- VitorRodrigues? - 27 Feb 2005

r3 - 28 Feb 2005 - 06:40:53 - VitorRodrigues?
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Syndicate this site RSSATOM