qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qexo-general] string function in 1.7 beta1


From: Per Bothner
Subject: Re: [Qexo-general] string function in 1.7 beta1
Date: Sun, 18 May 2003 23:55:40 -0700
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4b) Gecko/20030507

Seshukumar Venkata Adiraju wrote:

I have an "books.xml"
as
<books>
<book id="book1"/>
<book id="book2"/>
</books>

and I have an xquery
<html>
{
        let $books := document("books.xml")/books
        for $book in $books/book
        return
        <p>{ string($book/@id)}</p>
}
</html>

this yields <html>
<p>book1</p><p>book2</p>
</html>

but when I remove "line feeds" in the xml as
<books><book id="book1"/><book id="book2"/></books>

the result is
<html>
<p>book1</p><p></p>
</html>

there seems to be some error in the parsing.

It's not a parsing error - it's an error in traversing
the TreeList "DOM".  The attached patch should fix it.
--
        --Per Bothner
address@hidden   http://per.bothner.com/

Index: NamedAttributes.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/xml/NamedAttributes.java,v
retrieving revision 1.6
diff -u -r1.6 NamedAttributes.java
--- NamedAttributes.java        10 Jan 2003 04:52:49 -0000      1.6
+++ NamedAttributes.java        19 May 2003 06:52:03 -0000
@@ -65,7 +65,12 @@
       {
        SeqPosition pos = (SeqPosition) node;
        if (pos.sequence instanceof TreeList)
-         namedAttributes(qname, (TreeList) pos.sequence, pos.ipos >> 1, 
consumer);
+         {
+           TreeList tlist = (TreeList) pos.sequence;
+           namedAttributes(qname, tlist,
+                           tlist.posToDataIndex(pos.ipos),
+                           consumer);
+         }
       }
   }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]