Commit 4363f541 authored by Pietro Abate's avatar 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
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment