难以理解“=>”在进行考试练习时使用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>
]>
当编辑到何时,这显然是讲师的错字。
答案 0 :(得分:1)
在XQuery规范(1.0或3.0)中未定义语法=>
。两者都不是WHEN
。