[xquery-talk] Multiple computed attributes in Saxon 8.9
John Snelson
john.snelson at oracle.com
Tue May 15 17:04:51 PDT 2007
Hi Claus,
Interestingly, this exact situation has come up a number of times
recently on this mailing list. You are having problems with operator
precedence - and need to enclose all of your attribute constructors in
parentheses for them to be treated as part of the return expression.
John
Claus wrote:
> Hi list,
>
> I'm using Saxon 8.9.0.3J and I get the following error that puzzles me:
>
> Error on line 33 column 37 of file:/c:/work/pue-get-vehicle.xq:
> XPST0008: XQuery static error in #...ute pg {data($pg/v:Description#:
> Variable $pg has not been declared
> Static error(s) in query
>
> Here is part of the source where the error occurs - line #33 in the error
> message is line #14 below:
>
> [...]
> 1 <models>
> 2 {
> 3 for $model in
> doc("pue_current/pue-vehicleModelList.xml")//v:VehicleModel
> 4 let $br :=
> doc("pue_current/pue-stamm-br.xml")//v:Series[@ID=$model/@SeriesID]
> 5 where some $modelbm in $model/v:DesignNumber satisfies
> ($modelbm/@ID = $bm/@ID)part of the source where the error occurs - line #33 in the error
message is line #14 below:
[...]
> 6 return
> 7 <vehiclemodel>
> 8 {
> 9 (: TODO: make use of WHC and Plant attributes as well :)
> 10 let $pg :=
> doc("pue_current/pue-stamm-prod.xml")//v:ProductGroup[@ID=$br/@ProductGroupID]
>
> 11 let $brand :=
> doc("pue_current/pue-stamm-marken.xml")//v:Brand[@ID=$br/@BrandID]
> 12 return
> 13 attribute brand {data($brand/v:Description[@language="deu"])},
> 14 attribute pg {data($pg/v:Description[@language="deu"])},
> 15 attribute series {data($br/v:Description[@language="deu"])}
> 16 }
> 17 </vehiclemodel>
> 18 }
> 19 </models>
> [...]
>
> What really irritates me is that I can resolve the error by either deleting
> line #14 (which seems reasonable) *or* by deleting line #13 (!!).
>
> The error message says I haven't declared variable $pg, but I thought I did
> in line #10. Removing line #14 obviously works, but so does removing line
> #13. Looks like XQuery won't allow me to have more than two computed
> attributes following each other.
>
> What am I missing here?
>
> Thanks,
> Claus
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list