Rawa
Rawa

Reputation: 13936

What does => syntax mean in XQuery?

Having troubles understanding the "=>" syntax in XML while doing a exam exercise. Searched the web for it but cant find the meaning of it. Here is the example from a exam which the syntax is used in:

FOR $b IN //Brand
LET $cars :=
    (FOR $c IN //Car
    LET $cb := $c/@model => //Model/..
    WHERE $cb/@name = $b/@name
    RETURN $c)
LET $nr := COUNT($cars)
RETURN <Brand name={$b/@name}>{$nr}</Brand>

It is goal is to count all cars for each brand.

This was my try:

FOR $b IN //Brand
LET $cars := (
   FOR $c IN //Car
   WHERE $c/@Model = $b/Model/@name //Might not work to match against all models this way?
   RETURN ({c})
RETURN <Brand name={$b/@name}>COUNT($cars)</Brand>

And this is the XML document:

<!DOCTYPE CarsNStars [
<!ELEMENT CarsNStars (Brand*, Car*)>
<!ELEMENT Brand (Model*)>
<!ELEMENT Model (Year+)>
<!ELEMENT Year (#EMPTY)>
<!ELEMENT Car (#EMPTY)>
<!ATTLIST Brand
   name ID #REQUIRED
   country CDATA #IMPLIED>
<!ATTLIST Model
   name ID #REQUIRED>
<!ATTLIST Year
   year CDATA #REQUIRED
   horsePower CDATA #IMPLIED>
<!ATTLIST Car
   regNr ID #REQUIRED
   model IDREF #REQUIRED
   miles CDATA #REQUIRED>
]>

Edited WHEN to WHERE, this must obviously been a typo from the lecturer.

Upvotes: 1

Views: 253

Answers (1)

wst
wst

Reputation: 11771

The syntax => isn't defined in either XQuery spec (1.0 or 3.0). Neither is WHEN.

Upvotes: 1

Related Questions