qexo-general
[Top][All Lists]
Advanced

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

Re: [Qexo-general] sequences and xml children


From: Per Bothner
Subject: Re: [Qexo-general] sequences and xml children
Date: Fri, 27 Jun 2003 00:30:38 -0700
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030612

fl wrote:

define function x(){<a><b x="1"/></a>}

let $x:=<a>{for $b in x()/b return $b}</a> return $x/b
does not return anything !

I checked in the attached patch. There is another hader-to-fix bug, but I think this patches works around it - and I think it makes sense anyway.

Please do submit bug reports, or questions is you're sure, but are puzzled!
--
        --Per Bothner
address@hidden   http://per.bothner.com/

Index: NodeType.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/xml/NodeType.java,v
retrieving revision 1.5
diff -u -r1.5 NodeType.java
--- NodeType.java       10 Jan 2003 04:52:49 -0000      1.5
+++ NodeType.java       27 Jun 2003 07:17:54 -0000
@@ -1,4 +1,4 @@
-// Copyright (c) 2001  Per M.A. Bothner and Brainfood Inc.
+// Copyright (c) 2001, 2003  Per M.A. Bothner and Brainfood Inc.
 // This is free software;  for terms and warranty disclaimer see ./COPYING.
 
 package gnu.kawa.xml;
@@ -45,6 +45,23 @@
   public Type getImplementationType()
   {
     return typeSeqPosition;
+  }
+
+  public boolean isInstance (Object obj)
+  { 
+    if (obj instanceof AbstractSequence)
+      {
+       AbstractSequence seq = (AbstractSequence) obj;
+       int start = seq.startPos();
+       return isInstancePos(seq, start)
+         && ! seq.hasNext(seq.nextPos(start));
+      }
+    else if (obj instanceof SeqPosition)
+      {
+       SeqPosition pos = (SeqPosition) obj;
+       return isInstancePos(pos.sequence, pos.getPos());
+      }
+    return false;
   }
 
   public boolean isInstancePos(AbstractSequence seq, int ipos)
Index: ElementType.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/xml/ElementType.java,v
retrieving revision 1.7
diff -u -r1.7 ElementType.java
--- ElementType.java    10 Jan 2003 04:52:49 -0000      1.7
+++ ElementType.java    27 Jun 2003 07:17:54 -0000
@@ -1,4 +1,4 @@
-// Copyright (c) 2001, 2002  Per M.A. Bothner and Brainfood Inc.
+// Copyright (c) 2001, 2002, 2003  Per M.A. Bothner and Brainfood Inc.
 // This is free software;  for terms and warranty disclaimer see ./COPYING.
 
 package gnu.kawa.xml;
@@ -48,8 +48,12 @@
 
   public boolean isInstancePos (AbstractSequence seq, int ipos)
   {
-    return seq.getNextKind(ipos) == Sequence.GROUP_VALUE
-      && isInstance(seq, ipos, seq.getNextTypeObject(ipos));
+    int kind = seq.getNextKind(ipos);
+    if (kind == Sequence.GROUP_VALUE)
+      return isInstance(seq, ipos, seq.getNextTypeObject(ipos));
+    if (kind == Sequence.OBJECT_VALUE)
+      return isInstance(seq.getPosNext(ipos));
+    return false;
   }
 
   public boolean isInstance(AbstractSequence seq, int ipos, Object groupType)

reply via email to

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