W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2003

Re: Use Cases (TREE-Q1): wrong solution

From: MW <onlymails@gmx.net>
Date: Thu, 06 Mar 2003 05:43:16 +0100
Message-ID: <3E66D1E4.8070004@gmx.net>
To: public-qt-comments@w3.org

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 

{-- using local-name() --}
define function toc($e as element)
   as element*
   for $elt in $e/*
   let $n := local-name($elt)
     if ($n = "section")
     then <section>
              { $elt/@* }
              { toc($elt) }
     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
              	{ $section/@* , $title , toc($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 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:11 UTC