Database Reference
In-Depth Information
Algorithm 1 translates a mapping into an appropriate XQuery program. By x , y , v (possibly with
subscripts) we denote variables, while $ x , $ y , $ v are the corresponding XQuery variables.
Algorithm 1. ( translating a mapping m ST to XQuery program )
Input : A mapping x ( S ( x ) y T ( x' , y )), where:
S := / if [ E' ], T := / l [ E ], y = ( y 1 , ..., y m ).
Output : Query in XQuery over S transforming an instance of S into the corre-
sponding
canonical instance of T .
mappingToXQuery ( x (/ if [ E' ] y 1 , ..., y m / l [ E ]) =
< l >{ let $ y 1 : = “ null ”, ..., $ y m := “ null
for $ v in doc(“...”)/ if ,
τ($ v , E' )
return
ρ( E )}
</ l >
where:
1. τ($ v , l = x ) = $ x in if ($ v [ l ]) then $ v / l / text() else null ”,
2. τ($ v , l [ E ]) = $ v' in if ($ v [ l ]) then $ v / l else /, τ($ v' , E ),
3. τ($ v , E 1 , ..., E k ) = τ($ v , E 1 ), ..., τ($ v , E k ),
and
4. ρ( l = x ) = < l >{$ x }</ l >
5. ρ( l [ E ]) = < l >ρ( E )</ l >
6. ρ( E 1 , ..., E k ) = ρ( E 1 ) ... ρ( E k )
For the mapping from Example 4, Algorithm 1 generates the following XQuery program:
Query 1:
<pubs>{
let $x4:=”null”
for $_v in doc(“I3.xml”)/authors,
$_v1 in if ($_v[author]) then $_v/author else /,
$x1 in if ($_v1[name]) then $_v1/name/text() else “null”,
$_v2 in if ($_v1[paper]) then $_v1/paper else /,
$x2 in if ($_v2[title]) then $_v2/title/text() else “null”,
$x3 in if ($_v2[year]) then $_v2/year/text() else “null”
return
<pub>
<title>{$x2}</title>
Search WWH ::




Custom Search