[xquery-talk] Computed element construct
Dave Pawson
dave.pawson at gmail.com
Fri Nov 18 12:52:17 PST 2005
http://www.w3.org/TR/xquery/#id-computedElements
[111] CompElemConstructor ::= "element" (QName | ("{" Expr
"}")) "{" ContentExpr? "}"
[112] ContentExpr ::= Expr
So,
element elem {
for $a in (1 to 2)
return $a
}
works fine to produce
<elem>1 2</elem>
How to add an attribute to that element?
element elem {
attribute {"attName"}{"attval"}
}
works fine to produce the empty element
with the attribute and value.
The syntax says...
(usual caveat)
that the element content is an expr
bit contraining, but
[31] Expr ::= ExprSingle ("," ExprSingle)*
[32] ExprSingle ::= FLWORExpr
| QuantifiedExpr
| TypeswitchExpr
| IfExpr
| OrExpr
So why can't I add the ifExpr inside the constructed element expression please?
element elem {
attribute {"attName"}{"attval"}
for $a in (1 to 2)
return $a
}
saxon reports:
Error on line 17 column 1 of file:///myjava/xquery/data/:
XPST0003: XQuery syntax error in #...e {"attName"}{"attval"} for $#:
expected "}", found "for"
TIA
--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk
More information about the talk
mailing list