|
From: | Per Bothner |
Subject: | Re: [Qexo-general] question about sequence number |
Date: | Tue, 03 Feb 2004 13:43:19 -0800 |
User-agent: | Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113 |
Jun Yu wrote:
Here is my XQuery: let $i:=0 for $v in document("courses.xml"))/semester/lecture let $i:=$i+1 return ...
XQuery does not have assignments. You cannot modify an existing variable. In your example you have two variable that happen to have the same name. The outer $i has the value 0, and the inner $i has value 1. That is because the expression $i+1 is evaluated using the *outer* $i.
Instead use the 'at' clause: for $v at $i in document("courses.xml"))/semester/lecture return <table> <tr> <td>{$i}.</td> <td>{string($v/@type)}: </td> <td>{$v}.</td> </tr> </table> -- --Per Bothner address@hidden http://per.bothner.com/
[Prev in Thread] | Current Thread | [Next in Thread] |