[tmql-wg] Result set requirements
Rani Pinchuk
Rani.Pinchuk@spaceapplications.com
Fri, 20 Feb 2004 23:38:48 +0100
>
> In AsTMa? we do not allow to "generate arbitrary text". We only allow
>
> - lists
> - XML as an internal representation, and
> - TM data (again in internal representation)
>
> The only way to get text directly is to have it as part of the list.
Indeed I was thinking that the idea is to create any textual format and
not only the three formats you pointed out.
But when looking at the example in the the tutorial of AsTMa?:
function test (map $m) as xml return
<albums group="garbage">{
forall [ $a (album)
bn: $bn ] in $m
return
<album id="{$a}">{$bn}</album>
}</albums>
I cannot avoid from thinking about similar example like generating html:
function test2 (map $m) as text return
<table><tr>{
forall [ $a (album)
bn: $bn ] in $m
return
<td>{$a}</td><td>{$bn}</td></tr><tr>
}</tr></table>
or generating comma separated records:
function test3 (map $m) as text return
{
forall [ $a (album)
bn: $bn ] in $m
return
{$a},{$bn}
}
I mean - unless I missed something, the _syntax_ of AsTMa? does not limit
the output only to XML (apart from "as xml" declaration) and if there
is such a limitation, I find it maybe a bit artificial.
If, for example, XML is generated by the defining DTD and tying the result
set to different elements, the language is really built to generate only
XML and in my opinion, is also simpler because the fact that we narrowing
down to XML only is used to make it simpler for the user. Example (totally
imaginary extension to Toma which probably is not that consistent, but
hopefully will make sense):
# define dtd for the xml to be produced:
define dtd 'albums':
<?xml version="1.0"?>
<!DOCTYPE albums [
<!ELEMENT albums (album)*>
<!ATTLIST albums group CDATA #REQUIRED>
<!ELEMENT album (#PCDATA)>
<!ATTLIST album id CDATA #REQUIRED>
]>
;
# for clarity: without the presentation, the query looks like:
# select $a.id, $a.bn where exists $a;
#
select 'garbage' as attribute(albums, group),
$a.id as attribute(album, id),
$a.bn as element_data(album)
with dtd 'albums'
where exists $a;
Here there the fact that we use DTD, means that build in the syntax we
limit the language to produce XML. Hopefully this lead to simpler code
(mmm... suppose you have different queries that create the same XML, you
can use the same DTD, etc)?
I wonder if you find it the above reasonable...
Rani