Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
4363f541
Commit
4363f541
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2004-11-08 20:59:46 by vbenzake] Veo add more queries
Original author: vbenzake Date: 2004-11-08 20:59:46+00:00
parent
6ccb2392
Changes
1
Hide whitespace changes
Inline
Side-by-side
web/tutorial/queries.xml
View file @
4363f541
...
...
@@ -369,6 +369,71 @@ where t1=t2
</section>
<section
title=
"More complex Queries: on the power of patterns"
>
<sample>
<![CDATA[
<bib>
select
<book
(a)
>
x
from
<book
(a)
>
[ (x::(Any\Editor)|_ )* ] in bib
]]>
</sample>
<p>
This expression returns all book in bib but removoing the editor element.
If one wants to write more explicitly:
</p>
<sample>
<![CDATA[
select <book (a)>
x
from
<book
(a)
>
[ (x::(Any\
<editor>
_)|_ )* ] in bib
]]>
</sample>
<p>
Or even:
</p>
<sample>
<![CDATA[
select <book (a)>
x
from
<book
(a)
>
[ (x::(
<
(_\`editor)>_)|_ )* ] in bib
]]>
</sample>
<p>
Back to the first one:
</p>
<sample>
<![CDATA[
<bib>
select
<book
(a)
>
x
from
<
(book) (a)>[ (x::(Any\Editor)|_ )* ] in bib
]]>
</sample>
<p>
This query takes any element in bib, tranforms it in a book element and
removes sub-elements editor (but you will get a warning as capture variable book in the from is never used.
</p>
<sample>
<![CDATA[
select <(book) (a)>
x
from
<
(book) (a)>[ (x::(Any\Editor)|_ )* ] in bib
]]
</sample>
<p>
Same thing but without tranforming tag to "book".
More interestingly:
</p>
<sample>
<![CDATA[
select <(b) (a\id)>
x
from
<
(b) (a)>[ (x::(Any\Editor)|_ )* ] in bib
]]>
</sample>
<p>
removes all "id" attribute (if any) from the attributes of the element in bib.
</p>
<sample>
<![CDATA[
select <(b) (a\id+{bing=a.id})>
x
from
<
(b) (a)>[ (x::(Any\Editor)|_ )* ] in bib
]]>
</sample>
<p>
Changes attribute id=x into bing=x
However, one must be shure that each element in bib has an "id" attribute
if such is not the case the expression is ill-typed. If one wants to perform this only for those elements which certainly have an "id" attribute then:
</p>
<sample>
<![CDATA[
select <(b) (a\id+{bing=a.id})>
x
from
<
(b) (a
&
{id=_}))>[ (x::(Any\Editor)|_ )* ] in bib
]]>
</sample>
</section>
<section
title=
"An unorthodox query: Formatted table generation"
>
<p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment