什么=> XQuery中的语法意味着什么?

时间:2013-03-14 16:50:02

标签: xml xquery

难以理解“=>”在进行考试练习时使用XML语法。在网上搜索它但无法找到它的含义。以下是检查中使用语法的示例:

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>

目标是计算每个品牌的所有汽车。

这是我的尝试:

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>

这是XML文档:

<!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>
]>

当编辑到何时,这显然是讲师的错字。

1 个答案:

答案 0 :(得分:1)

在XQuery规范(1.0或3.0)中未定义语法=>。两者都不是WHEN