<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 08/20/2015 07:54 PM, Stefan Scott
wrote:<br>
</div>
<blockquote
cite="mid:CAFwK6auqs5kacV7Phoum8qTARtYivUvXBrUNuTDcYf3G=4wY0Q@mail.gmail.com"
type="cite">
<div dir="ltr"><font face="monospace, monospace" size="4">I'm
attempting create a simple demo using this syntax.</font>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4">The demo should
define a function (eg `table_to_xml aTable aField`) which
accepts a table name and a field name.</font></div>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4">Then this
function is called using different table names and field
names, to run some SQL queries and generate some XML. </font></div>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4">I haven't found
any concrete examples of this sort of thing in the manual or
online, so the following is just a wild guess:</font></div>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4"> (*
INCORRECT/tableToXml.ur *)</font></div>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4"> table t1 : {
F1 : string }</font></div>
<div><font face="monospace, monospace" size="4"> table t2 : {
F2 : string }</font></div>
<div><font face="monospace, monospace" size="4"><br>
</font></div>
<div><font face="monospace, monospace" size="4"> fun
table_to_xml </font></div>
<div><font face="monospace, monospace" size="4"> aTable
(** OK? **)</font></div>
<div><font face="monospace, monospace" size="4"> aField
(** OK? **)</font></div>
</div>
</blockquote>
<br>
The basic problem here is that both of these should be
constructor-level parameters, enclosed in square brackets, not
value-level parameters, as they are defined above.<br>
<br>
The less basic problem is that you will need to provide more
involved annotations, including a disjointness constraint and a
value-level parameter for the table, to get it all to type check. I
do believe that Chapter 2 of the official Ur/Web tutorial goes into
sufficient detail on those concepts.<br>
<br>
<blockquote
cite="mid:CAFwK6auqs5kacV7Phoum8qTARtYivUvXBrUNuTDcYf3G=4wY0Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><font face="monospace, monospace" size="4"> = </font></div>
<div><font face="monospace, monospace" size="4"> queryX1 </font></div>
<div><font face="monospace, monospace" size="4"> ( SELECT
{aField} (** OK? **)</font></div>
</div>
</blockquote>
<br>
Every field projection in a query needs an explicit 'table.' part.<br>
<br>
<blockquote
cite="mid:CAFwK6auqs5kacV7Phoum8qTARtYivUvXBrUNuTDcYf3G=4wY0Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><font face="monospace, monospace" size="4"> FROM
{{aTable}} ) (** OK? **)</font></div>
</div>
</blockquote>
<br>
I believe this needs an explicit 'AS' clause.<br>
<br>
<blockquote
cite="mid:CAFwK6auqs5kacV7Phoum8qTARtYivUvXBrUNuTDcYf3G=4wY0Q@mail.gmail.com"
type="cite">
<div dir="ltr"><font face="monospace, monospace" size="4">
{[r.{aField}]} (** Q (1) **)</font></div>
</blockquote>
<br>
Looks fine here.<br>
<br>
<blockquote
cite="mid:CAFwK6auqs5kacV7Phoum8qTARtYivUvXBrUNuTDcYf3G=4wY0Q@mail.gmail.com"
type="cite">
<div dir="ltr"><font face="monospace, monospace" size="4"> t1x
<- table_to_xml t1 #F1 (** Q (2) **)</font>
<div><font face="monospace, monospace" size="4"> ;</font></div>
<div><font face="monospace, monospace" size="4"> t2x <-
table_to_xml t2 #F2 (** Q (2) **)</font></div>
<div><font face="monospace, monospace" size="4"> ;</font></div>
</div>
</blockquote>
<br>
You'll need to enclose the actual parameters in square brackets,
too.<br>
</body>
</html>