NOTE: ParenthesizedSequenceType replaces ParenthesizedItemType in the ItemType EBNF symbol.
let $c as complex := (xs:double("1"), xs:double("2"));
let ($re, $im) := $c; (: error if there are not 2 items in the sequence :)
let ($heading as array(xs:string), $rows as array(xs:string)*) := load-csv("test.csv");
let ($heading, $rows*) := load-csv("test.csv");
Hi Reece,
Interesting stuff. I can see some use for some of these myself. In
terms of syntax extensions, ideally we would want to get those into an
XPath spec at the W3C, that Working Group is on hiatus at the moment.
However, if we could argue the case that there is enough stuff and
enough interest, it may be possible to get something up and going,
preferably with the aim of standardising a few known things quickly.
Personally there are some other things I would also like to see, I
have been calling these my "XQuery 3.2 Wishlist":
** Default values for parameters in function signatures
1. When specifying a function, e.g declare function local:my-fn($x,
$y := "default", $z := map{ "a" : "Monday", "b" : "Tuesday" })
2. When calling a function, default values may be omitted.
** Named parameters when passing arguments to functions, this can help
with code readability
1. e.g. when calling function, e.g. local:my-fn($x := "xx", $y := "other")
** Ternary operator
1. e.g. $a eq $b ? "hello" : "goodbye"
** Record Type
1. Similar to map in someways but fixed length and statically checked names
2. Basically allows you to create a union record of types
3. e.g. declare variable $v as record { $a as xs:string := "hello",
$b := <b/> }
I guess in some ways the Record Type is similar to your tuple and union types.
I wonder if we should find somewhere to collect all of these ideas
together? Perhaps a project under the EXPath repo is enough, where we
collate proposals with attribution. Perhaps if we get enough stuff
together we could do something...
I would love to see template literals implemented in XQuery. ATVs are similar, but being able to do something like:
let $person := <person><name>Jane Doe</name><age>25</age></person>
let $msg := `%{$person/name} is %{$person/age} years old.`
return $msg
would be REALLY powerful, especially with context operators:
let $msgTemplate = function($person as node()) as string* { `%{$person/name} is %{$person/age} years old.`}
let $persons := <persons>
<person><name>Mike Myers</name><age>55</age></person>
<person><name>Shannon Lee</name><age>17</age></person>
<persons>
return $persons/person!$msgTemplate(.)
Sent from Mail for Windows 10
--
On Oct 15, 2018, at 4:00 PM, Loren Cahlander <loren.c...@gmail.com> wrote:
My apologies. The view does not include the annotations. here is the XSD for xqDoc.
<xqdoc-1.0.01132014.xsd>
On Oct 15, 2018, at 3:52 PM, Loren Cahlander <loren.c...@gmail.com> wrote:
Here is the view of the xqDoc schema:
<PastedGraphic-1.png>