Hi Alberto! I agree with you. TREE-Q1 is absolutely wrong! But I don't think that your function will produce the expected output. The ouutput must not contain the title of the book - only the titles of the sections. Therefore you have to check if the parent of the title is a section! If have written 2 working versions of the function: The first one uses the 'local-name()'-function. The second one makes no use of the 'local-name()'-function and is more advanced. {-- using local-name() --} define function toc($e as element) as element* { for $elt in $e/* let $n := local-name($elt) return if ($n = "section") then <section> { $elt/@* } { toc($elt) } </section> else if ($n = "title" and local-name($elt/..) = "section") then $elt else () } {-- not using local-name() --} define function toc($book as element) as element* { for $section in $book/section, $title in $section/title return <section> { $section/@* , $title , toc($section) } </section> } I hope, somebody will read this post and will remove this big, fat BUG ;-) Michael W.Received on Thursday, 6 March 2003 09:01:47 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:24 GMT