xquery return line number
Added by Anonymous almost 16 years ago
Legacy ID: #6111711 Legacy Poster: pvallone (pvallone)
Hi, In the below expression I am trying to check for missing idrefs in a document. I want to also return the line number of the context node with saxon:line-number. I can not seem to get the syntax correct. xquery version "1.0"; (:find missing xrefs:) declare namespace f = "http://somewhere.com/"; declare namespace saxon = "http://saxon.sf.net/;"; declare function f:name-and-position($n as element()) as xs:string { concat(name($n), '[', 1+count($n/preceding-sibling::[node-name(.) = node-name($n)]), ']') }; for $h in //xref/@href let $xpath := $h/string-join(ancestor-or-self:: /f:name-and-position(.), '/') let $base := $h/base-uri() let $line := $h/saxon:line-number(.); return if (//@id[.=$h]) then <ok/> else <not-found id="{$h}" file="{$base}" line="{$line}">/{$xpath}</not-found> command line: Query -q:missingXrefs-base-uri().xq -s:C:\sandbox\myfile.xml -l:on Thanks for the help Phil
Replies (3)
Please register to reply
RE: xquery return line number - Added by Anonymous almost 16 years ago
Legacy ID: #6111727 Legacy Poster: pvallone (pvallone)
oh... Here is the error: Error on line 11 column 34 of missingXrefs-base-uri().xq: XPST0003: XQuery syntax error in #...= saxon:line-number(.); return#: expected "return", found ";" Static error(s) in query
RE: xquery return line number - Added by Anonymous almost 16 years ago
Legacy ID: #6122107 Legacy Poster: Michael Kay (mhkay)
>expected "return", found ";" Just delete the semicolon.
RE: xquery return line number - Added by Anonymous almost 16 years ago
Legacy ID: #6132026 Legacy Poster: pvallone (pvallone)
Ahhh! Nice catch. Thanks for the help.
Please register to reply