You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by vi...@apache.org on 2012/07/04 10:48:47 UTC

svn commit: r1357173 - in /incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery: compiler/algebricks/ datamodel/accessors/ datamodel/accessors/atomic/ datamodel/accessors/nodes/ datamodel/builders/base/ datamodel/...

Author: vinayakb
Date: Wed Jul  4 08:48:45 2012
New Revision: 1357173

URL: http://svn.apache.org/viewvc?rev=1357173&view=rev
Log:
Added XML serializer

Added:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointableCache.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePool.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
Removed:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java
Modified:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryPrinterFactory.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/TaggedValuePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/CodedQNamePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/AttributeNodePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/DocumentNodePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/ElementNodePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/PINodePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/TextOrCommentNodePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/ElementNodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryPrinterFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryPrinterFactory.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryPrinterFactory.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryPrinterFactory.java Wed Jul  4 08:48:45 2012
@@ -1,95 +1,15 @@
 package org.apache.vxquery.compiler.algebricks;
 
-import java.io.PrintStream;
+import org.apache.vxquery.serializer.XMLSerializer;
 
-import org.apache.vxquery.datamodel.accessors.SequencePointable;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.values.ValueTag;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.data.IPrinter;
 import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
-import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
-import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
-import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
-import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 public class VXQueryPrinterFactory implements IPrinterFactory {
     private static final long serialVersionUID = 1L;
 
     @Override
     public IPrinter createPrinter() {
-        return new IPrinter() {
-            private final TaggedValuePointable tvp = new TaggedValuePointable();
-
-            private final UTF8StringPointable utf8sp = (UTF8StringPointable) UTF8StringPointable.FACTORY
-                    .createPointable();
-
-            private final LongPointable lp = (LongPointable) LongPointable.FACTORY.createPointable();
-
-            private final DoublePointable dp = (DoublePointable) DoublePointable.FACTORY.createPointable();
-
-            private final BooleanPointable bp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
-
-            private final SequencePointable seqp = new SequencePointable();
-
-            private final VoidPointable vp = (VoidPointable) VoidPointable.FACTORY.createPointable();
-
-            @Override
-            public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-                tvp.set(b, s, l);
-                byte tag = tvp.getTag();
-                switch ((int) tag) {
-                    case ValueTag.XS_STRING_TAG: {
-                        tvp.getValue(utf8sp);
-                        int utfLen = utf8sp.getUTFLength();
-                        int offset = 2;
-                        while (utfLen > 0) {
-                            char c = utf8sp.charAt(offset);
-                            ps.append(c);
-                            int cLen = UTF8StringPointable.getModifiedUTF8Len(c);
-                            offset += cLen;
-                            utfLen -= cLen;
-                        }
-                        break;
-                    }
-
-                    case ValueTag.XS_INTEGER_TAG: {
-                        tvp.getValue(lp);
-                        ps.print(lp.longValue());
-                        break;
-                    }
-
-                    case ValueTag.XS_DOUBLE_TAG: {
-                        tvp.getValue(dp);
-                        ps.print(dp.doubleValue());
-                        break;
-                    }
-
-                    case ValueTag.XS_BOOLEAN_TAG: {
-                        tvp.getValue(bp);
-                        ps.print(bp.getBoolean());
-                        break;
-                    }
-
-                    case ValueTag.SEQUENCE_TAG: {
-                        tvp.getValue(seqp);
-                        int len = seqp.getEntryCount();
-                        for (int i = 0; i < len; ++i) {
-                            if (i > 0) {
-                                ps.append(' ');
-                            }
-                            seqp.getEntry(i, vp);
-                            print(vp.getByteArray(), vp.getStartOffset(), vp.getLength(), ps);
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void init() throws AlgebricksException {
-            }
-        };
+        return new XMLSerializer();
     }
 }
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointableCache.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointableCache.java?rev=1357173&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointableCache.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointableCache.java Wed Jul  4 08:48:45 2012
@@ -0,0 +1,25 @@
+package org.apache.vxquery.datamodel.accessors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class PointableCache<T extends IPointable> {
+    private final List<T> list;
+
+    public PointableCache() {
+        list = new ArrayList<T>();
+    }
+
+    public T takeOne() {
+        if (list.isEmpty()) {
+            return null;
+        }
+        return list.remove(list.size() - 1);
+    }
+
+    public void giveBack(T pointable) {
+        list.add(pointable);
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePool.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePool.java?rev=1357173&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePool.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePool.java Wed Jul  4 08:48:45 2012
@@ -0,0 +1,40 @@
+package org.apache.vxquery.datamodel.accessors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
+
+public class PointablePool {
+    private final Map<Class<? extends IPointable>, IPointableFactory> pfMap;
+
+    private final Map<Class<? extends IPointable>, PointableCache<? extends IPointable>> pcMap;
+
+    public PointablePool() {
+        pfMap = new HashMap<Class<? extends IPointable>, IPointableFactory>();
+        pcMap = new HashMap<Class<? extends IPointable>, PointableCache<? extends IPointable>>();
+    }
+
+    public <T extends IPointable> void register(Class<T> klass, IPointableFactory factory) {
+        pfMap.put(klass, factory);
+        pcMap.put(klass, new PointableCache<T>());
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T extends IPointable> T takeOne(Class<T> klass) {
+        PointableCache<T> pc = (PointableCache<T>) pcMap.get(klass);
+        T p = pc.takeOne();
+        if (p != null) {
+            return p;
+        }
+        IPointableFactory pf = pfMap.get(klass);
+        return (T) pf.createPointable();
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T extends IPointable> void giveBack(T pointable) {
+        PointableCache<T> pc = (PointableCache<T>) pcMap.get(pointable.getClass());
+        pc.giveBack(pointable);
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java?rev=1357173&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java Wed Jul  4 08:48:45 2012
@@ -0,0 +1,52 @@
+package org.apache.vxquery.datamodel.accessors;
+
+import org.apache.vxquery.datamodel.accessors.atomic.CodedQNamePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.AttributeNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.PINodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.TextOrCommentNodePointable;
+
+import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
+import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
+import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
+import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
+import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
+import edu.uci.ics.hyracks.data.std.primitive.ShortPointable;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
+
+public class PointablePoolFactory {
+    public static final PointablePoolFactory INSTANCE = new PointablePoolFactory();
+
+    private PointablePoolFactory() {
+    }
+
+    public PointablePool createPointablePool() {
+        PointablePool pp = new PointablePool();
+
+        pp.register(TaggedValuePointable.class, TaggedValuePointable.FACTORY);
+        pp.register(BooleanPointable.class, BooleanPointable.FACTORY);
+        pp.register(BytePointable.class, BytePointable.FACTORY);
+        pp.register(ShortPointable.class, ShortPointable.FACTORY);
+        pp.register(IntegerPointable.class, IntegerPointable.FACTORY);
+        pp.register(LongPointable.class, LongPointable.FACTORY);
+        pp.register(FloatPointable.class, FloatPointable.FACTORY);
+        pp.register(DoublePointable.class, DoublePointable.FACTORY);
+        pp.register(UTF8StringPointable.class, UTF8StringPointable.FACTORY);
+        pp.register(SequencePointable.class, SequencePointable.FACTORY);
+        pp.register(VoidPointable.class, VoidPointable.FACTORY);
+        pp.register(CodedQNamePointable.class, CodedQNamePointable.FACTORY);
+
+        pp.register(NodeTreePointable.class, NodeTreePointable.FACTORY);
+        pp.register(DocumentNodePointable.class, DocumentNodePointable.FACTORY);
+        pp.register(ElementNodePointable.class, ElementNodePointable.FACTORY);
+        pp.register(AttributeNodePointable.class, AttributeNodePointable.FACTORY);
+        pp.register(TextOrCommentNodePointable.class, TextOrCommentNodePointable.FACTORY);
+        pp.register(PINodePointable.class, PINodePointable.FACTORY);
+
+        return pp;
+    }
+}
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java Wed Jul  4 08:48:45 2012
@@ -1,12 +1,28 @@
 package org.apache.vxquery.datamodel.accessors;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
 import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 public class SequencePointable extends AbstractPointable {
     private static final int ENTRY_COUNT_SIZE = 4;
     private static final int SLOT_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new SequencePointable();
+        }
+    };
 
     public static int getSequenceLength(byte[] bytes, int start) {
         int entryCount = getEntryCount(bytes, start);

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/TaggedValuePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/TaggedValuePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/TaggedValuePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/TaggedValuePointable.java Wed Jul  4 08:48:45 2012
@@ -1,10 +1,27 @@
 package org.apache.vxquery.datamodel.accessors;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
 import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 public class TaggedValuePointable extends AbstractPointable {
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new TaggedValuePointable();
+        }
+    };
+
     public byte getTag() {
         return BytePointable.getByte(bytes, start);
     }

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/CodedQNamePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/CodedQNamePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/CodedQNamePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/CodedQNamePointable.java Wed Jul  4 08:48:45 2012
@@ -1,6 +1,9 @@
 package org.apache.vxquery.datamodel.accessors.atomic;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 
 public class CodedQNamePointable extends AbstractPointable {
@@ -10,6 +13,34 @@ public class CodedQNamePointable extends
     private static final int OFF_NS = 4;
     private static final int OFF_LOCAL = 8;
 
+    public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public boolean isFixedLength() {
+            return true;
+        }
+
+        @Override
+        public int getFixedLength() {
+            return SIZE;
+        }
+    };
+
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new CodedQNamePointable();
+        }
+    };
+
     public int getPrefixCode() {
         return IntegerPointable.getInteger(bytes, start + OFF_PREFIX);
     }

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/AttributeNodePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/AttributeNodePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/AttributeNodePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/AttributeNodePointable.java Wed Jul  4 08:48:45 2012
@@ -3,8 +3,12 @@ package org.apache.vxquery.datamodel.acc
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.CodedQNamePointable;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 /*
  * Attribute {
@@ -16,6 +20,19 @@ import edu.uci.ics.hyracks.data.std.prim
  */
 public class AttributeNodePointable extends AbstractPointable {
     private static final int LOCAL_NODE_ID_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new AttributeNodePointable();
+        }
+    };
 
     public void getName(CodedQNamePointable name) {
         name.set(bytes, getNameOffset(), getNameSize());

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/DocumentNodePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/DocumentNodePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/DocumentNodePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/DocumentNodePointable.java Wed Jul  4 08:48:45 2012
@@ -2,8 +2,12 @@ package org.apache.vxquery.datamodel.acc
 
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 /*
  * Document {
@@ -13,6 +17,19 @@ import edu.uci.ics.hyracks.data.std.prim
  */
 public class DocumentNodePointable extends AbstractPointable {
     private static final int LOCAL_NODE_ID_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new DocumentNodePointable();
+        }
+    };
 
     public int getLocalNodeId(NodeTreePointable nodeTree) {
         return nodeTree.nodeIdExists() ? IntegerPointable.getInteger(bytes, getLocalNodeIdOffset()) : -1;

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/ElementNodePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/ElementNodePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/ElementNodePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/ElementNodePointable.java Wed Jul  4 08:48:45 2012
@@ -3,9 +3,13 @@ package org.apache.vxquery.datamodel.acc
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.CodedQNamePointable;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 /*
  * Element {
@@ -46,6 +50,19 @@ public class ElementNodePointable extend
     private static final int LOCAL_NODE_ID_SIZE = 4;
     private static final int NS_ENTRY_SIZE = 4 * 2;
     private static final int NS_CHUNK_SIZE_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new ElementNodePointable();
+        }
+    };
 
     public boolean nsChunkExists() {
         return (getHeader() & NS_CHUNK_EXISTS_MASK) != 0;

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java Wed Jul  4 08:48:45 2012
@@ -2,18 +2,22 @@ package org.apache.vxquery.datamodel.acc
 
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.algorithms.BinarySearchAlgorithm;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.collections.api.IValueReferenceVector;
 import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
 import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 public class NodeTreePointable extends AbstractPointable {
-    public static final int HEADER_NODEID_EXISTS_MASK = 0x01;
-    public static final int HEADER_DICTIONARY_EXISTS_MASK = 0x02;
-    public static final int HEADER_TYPE_EXISTS_MASK = 0x03;
+    public static final int HEADER_NODEID_EXISTS_MASK = (1 << 0);
+    public static final int HEADER_DICTIONARY_EXISTS_MASK = (1 << 1);
+    public static final int HEADER_TYPE_EXISTS_MASK = (1 << 2);
 
     private static final int HEADER_OFFSET = 0;
     private static final int HEADER_SIZE = 1;
@@ -24,6 +28,20 @@ public class NodeTreePointable extends A
     private static final int IDX_PTR_SLOT_SIZE = 4;
     private static final int SORTED_PTR_SLOT_SIZE = 4;
 
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new NodeTreePointable();
+        }
+    };
+
     private final IValueReferenceVector sortedStringVector = new IValueReferenceVector() {
         @Override
         public int getSize() {
@@ -78,8 +96,8 @@ public class NodeTreePointable extends A
             throw new IllegalArgumentException(idx + " not within [0, " + nEntries + ")");
         }
         int dataAreaStart = getDictionaryDataAreaStartOffset();
-        int idxSlotValue = IntegerPointable.getInteger(bytes, getDictionaryIndexPointerArrayOffset() + idx
-                * IDX_PTR_SLOT_SIZE);
+        int idxSlotValue = idx == 0 ? 0 : IntegerPointable.getInteger(bytes, getDictionaryIndexPointerArrayOffset()
+                + (idx - 1) * IDX_PTR_SLOT_SIZE);
         int strLen = UTF8StringPointable.getUTFLength(bytes, dataAreaStart + idxSlotValue);
         string.set(bytes, dataAreaStart + idxSlotValue, strLen + 2);
     }

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/PINodePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/PINodePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/PINodePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/PINodePointable.java Wed Jul  4 08:48:45 2012
@@ -1,8 +1,12 @@
 package org.apache.vxquery.datamodel.accessors.nodes;
 
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 /*
  * PI {
@@ -13,6 +17,19 @@ import edu.uci.ics.hyracks.data.std.prim
  */
 public class PINodePointable extends AbstractPointable {
     private static final int LOCAL_NODE_ID_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new PINodePointable();
+        }
+    };
 
     public int getLocalNodeId(NodeTreePointable nodeTree) {
         return nodeTree.nodeIdExists() ? IntegerPointable.getInteger(bytes, getLocalNodeIdOffset()) : -1;
@@ -22,7 +39,7 @@ public class PINodePointable extends Abs
         target.set(bytes, getTargetOffset(nodeTree), getTargetSize(nodeTree));
     }
 
-    public void getContentCode(NodeTreePointable nodeTree, UTF8StringPointable content) {
+    public void getContent(NodeTreePointable nodeTree, UTF8StringPointable content) {
         content.set(bytes, getContentOffset(nodeTree), getContentSize(nodeTree));
     }
 

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/TextOrCommentNodePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/TextOrCommentNodePointable.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/TextOrCommentNodePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/TextOrCommentNodePointable.java Wed Jul  4 08:48:45 2012
@@ -1,24 +1,39 @@
 package org.apache.vxquery.datamodel.accessors.nodes;
 
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-
+import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
 
 /*
  * Text | Comment {
  *  NodeId nodeId?;
- *  TaggedValue value;
+ *  UTF8String value;
  * }
  */
 public class TextOrCommentNodePointable extends AbstractPointable {
     private static final int LOCAL_NODE_ID_SIZE = 4;
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new TextOrCommentNodePointable();
+        }
+    };
 
     public int getLocalNodeId(NodeTreePointable nodeTree) {
         return nodeTree.nodeIdExists() ? IntegerPointable.getInteger(bytes, getLocalNodeIdOffset()) : -1;
     }
 
-    public void getValue(NodeTreePointable nodeTree, TaggedValuePointable value) {
+    public void getValue(NodeTreePointable nodeTree, IPointable value) {
         value.set(bytes, getValueOffset(nodeTree), getValueSize(nodeTree));
     }
 

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/ElementNodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/ElementNodeBuilder.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/ElementNodeBuilder.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/ElementNodeBuilder.java Wed Jul  4 08:48:45 2012
@@ -45,8 +45,8 @@ public class ElementNodeBuilder extends 
     public void reset(ArrayBackedValueStorage abvs) throws IOException {
         this.abvs = abvs;
         out = abvs.getDataOutput();
-        headerOffset = abvs.getLength();
         out.write(ValueTag.ELEMENT_NODE_TAG);
+        headerOffset = abvs.getLength();
         out.write(0);
     }
 

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java?rev=1357173&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java Wed Jul  4 08:48:45 2012
@@ -0,0 +1,358 @@
+package org.apache.vxquery.serializer;
+
+import java.io.PrintStream;
+
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.PointablePoolFactory;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.CodedQNamePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.AttributeNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.PINodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.TextOrCommentNodePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinter;
+import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
+import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
+import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
+
+public class XMLSerializer implements IPrinter {
+    private final PointablePool pp;
+
+    private NodeTreePointable ntp;
+
+    public XMLSerializer() {
+        pp = PointablePoolFactory.INSTANCE.createPointablePool();
+    }
+
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) {
+        TaggedValuePointable tvp = pp.takeOne(TaggedValuePointable.class);
+        try {
+            tvp.set(b, s, l);
+            printTaggedValuePointable(ps, tvp);
+        } finally {
+            pp.giveBack(tvp);
+        }
+    }
+
+    private void printTaggedValuePointable(PrintStream ps, TaggedValuePointable tvp) {
+        byte tag = tvp.getTag();
+        switch ((int) tag) {
+            case ValueTag.XS_STRING_TAG:
+                printString(ps, tvp);
+                break;
+
+            case ValueTag.XS_UNTYPED_ATOMIC_TAG:
+                printString(ps, tvp);
+                break;
+
+            case ValueTag.XS_INTEGER_TAG:
+                printInteger(ps, tvp);
+                break;
+
+            case ValueTag.XS_DOUBLE_TAG:
+                printDouble(ps, tvp);
+                break;
+
+            case ValueTag.XS_BOOLEAN_TAG:
+                printBoolean(ps, tvp);
+                break;
+
+            case ValueTag.SEQUENCE_TAG:
+                printSequence(ps, tvp);
+                break;
+
+            case ValueTag.NODE_TREE_TAG:
+                printNodeTree(ps, tvp);
+                break;
+
+            case ValueTag.DOCUMENT_NODE_TAG:
+                printDocumentNode(ps, tvp);
+                break;
+
+            case ValueTag.ELEMENT_NODE_TAG:
+                printElementNode(ps, tvp);
+                break;
+
+            case ValueTag.ATTRIBUTE_NODE_TAG:
+                printAttributeNode(ps, tvp);
+                break;
+
+            case ValueTag.TEXT_NODE_TAG:
+                printTextNode(ps, tvp);
+                break;
+
+            case ValueTag.COMMENT_NODE_TAG:
+                printCommentNode(ps, tvp);
+                break;
+
+            case ValueTag.PI_NODE_TAG:
+                printPINode(ps, tvp);
+                break;
+
+            default:
+                throw new UnsupportedOperationException("Encountered tag: " + tvp.getTag());
+        }
+    }
+
+    private void printNodeTree(PrintStream ps, TaggedValuePointable tvp) {
+        ntp = pp.takeOne(NodeTreePointable.class);
+        TaggedValuePointable rootTVP = pp.takeOne(TaggedValuePointable.class);
+        try {
+            tvp.getValue(ntp);
+            ntp.getRootNode(rootTVP);
+            printTaggedValuePointable(ps, rootTVP);
+        } finally {
+            pp.giveBack(rootTVP);
+            pp.giveBack(ntp);
+            ntp = null;
+        }
+    }
+
+    private void printPINode(PrintStream ps, TaggedValuePointable tvp) {
+        PINodePointable pnp = pp.takeOne(PINodePointable.class);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        try {
+            tvp.getValue(pnp);
+            ps.append("<?");
+            pnp.getTarget(ntp, utf8sp);
+            printString(ps, utf8sp);
+            ps.append(' ');
+            pnp.getContent(ntp, utf8sp);
+            printString(ps, utf8sp);
+            ps.append("?>");
+        } finally {
+            pp.giveBack(pnp);
+            pp.giveBack(utf8sp);
+        }
+    }
+
+    private void printCommentNode(PrintStream ps, TaggedValuePointable tvp) {
+        TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        try {
+            tvp.getValue(tcnp);
+            tcnp.getValue(ntp, utf8sp);
+            ps.append("<!--");
+            printString(ps, utf8sp);
+            ps.append("-->");
+        } finally {
+            pp.giveBack(tcnp);
+            pp.giveBack(utf8sp);
+        }
+    }
+
+    private void printTextNode(PrintStream ps, TaggedValuePointable tvp) {
+        TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        try {
+            tvp.getValue(tcnp);
+            tcnp.getValue(ntp, utf8sp);
+            printString(ps, utf8sp);
+        } finally {
+            pp.giveBack(tcnp);
+            pp.giveBack(utf8sp);
+        }
+    }
+
+    private void printAttributeNode(PrintStream ps, TaggedValuePointable tvp) {
+        AttributeNodePointable anp = pp.takeOne(AttributeNodePointable.class);
+        CodedQNamePointable cqp = pp.takeOne(CodedQNamePointable.class);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        TaggedValuePointable valueTVP = pp.takeOne(TaggedValuePointable.class);
+        try {
+            tvp.getValue(anp);
+            anp.getName(cqp);
+            printPrefixedQName(ps, cqp, utf8sp);
+            ps.append("=\"");
+            anp.getValue(ntp, valueTVP);
+            printTaggedValuePointable(ps, valueTVP);
+            ps.append('"');
+        } finally {
+            pp.giveBack(valueTVP);
+            pp.giveBack(utf8sp);
+            pp.giveBack(anp);
+            pp.giveBack(cqp);
+        }
+    }
+
+    private void printElementNode(PrintStream ps, TaggedValuePointable tvp) {
+        ElementNodePointable enp = pp.takeOne(ElementNodePointable.class);
+        CodedQNamePointable cqp = pp.takeOne(CodedQNamePointable.class);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        SequencePointable seqp = pp.takeOne(SequencePointable.class);
+        try {
+            tvp.getValue(enp);
+            enp.getName(cqp);
+            ps.append('<');
+            printPrefixedQName(ps, cqp, utf8sp);
+
+            int nsCount = enp.getNamespaceEntryCount(ntp);
+            for (int i = 0; i < nsCount; ++i) {
+                ps.append(" xmlns:");
+                ntp.getString(enp.getNamespacePrefixCode(ntp, i), utf8sp);
+                printString(ps, utf8sp);
+                ps.append("=\"");
+                ntp.getString(enp.getNamespaceURICode(ntp, i), utf8sp);
+                printString(ps, utf8sp);
+                ps.append("\"");
+            }
+
+            enp.getAttributeSequence(ntp, seqp);
+            if (seqp.getByteArray() != null && seqp.getEntryCount() > 0) {
+                ps.append(' ');
+                printSequence(ps, seqp);
+            }
+
+            ps.append('>');
+            enp.getChildrenSequence(ntp, seqp);
+            if (seqp.getByteArray() != null) {
+                printSequence(ps, seqp);
+            }
+            ps.append("</");
+            printPrefixedQName(ps, cqp, utf8sp);
+            ps.append('>');
+        } finally {
+            pp.giveBack(seqp);
+            pp.giveBack(utf8sp);
+            pp.giveBack(cqp);
+            pp.giveBack(enp);
+        }
+    }
+
+    private void printPrefixedQName(PrintStream ps, CodedQNamePointable cqp, UTF8StringPointable utf8sp) {
+        ntp.getString(cqp.getPrefixCode(), utf8sp);
+        if (utf8sp.getStringLength() > 0) {
+            printString(ps, utf8sp);
+            ps.append(':');
+        }
+        ntp.getString(cqp.getLocalCode(), utf8sp);
+        printString(ps, utf8sp);
+    }
+
+    private void printDocumentNode(PrintStream ps, TaggedValuePointable tvp) {
+        DocumentNodePointable dnp = pp.takeOne(DocumentNodePointable.class);
+        SequencePointable seqp = pp.takeOne(SequencePointable.class);
+        try {
+            ps.append("<?xml version=\"1.0\"?>\n");
+            tvp.getValue(dnp);
+            dnp.getContent(ntp, seqp);
+            printSequence(ps, seqp);
+        } finally {
+            pp.giveBack(dnp);
+        }
+    }
+
+    private void printSequence(PrintStream ps, TaggedValuePointable tvp) {
+        SequencePointable seqp = pp.takeOne(SequencePointable.class);
+        try {
+            printSequence(ps, seqp);
+        } finally {
+            pp.giveBack(seqp);
+        }
+    }
+
+    private void printSequence(PrintStream ps, SequencePointable seqp) {
+        VoidPointable vp = pp.takeOne(VoidPointable.class);
+        try {
+            int len = seqp.getEntryCount();
+            for (int i = 0; i < len; ++i) {
+                if (i > 0) {
+                    ps.append(' ');
+                }
+                seqp.getEntry(i, vp);
+                print(vp.getByteArray(), vp.getStartOffset(), vp.getLength(), ps);
+            }
+        } finally {
+            pp.giveBack(vp);
+        }
+    }
+
+    private void printBoolean(PrintStream ps, TaggedValuePointable tvp) {
+        BooleanPointable bp = pp.takeOne(BooleanPointable.class);
+        try {
+            tvp.getValue(bp);
+            ps.print(bp.getBoolean());
+        } finally {
+            pp.giveBack(bp);
+        }
+    }
+
+    private void printDouble(PrintStream ps, TaggedValuePointable tvp) {
+        DoublePointable dp = pp.takeOne(DoublePointable.class);
+        try {
+            tvp.getValue(dp);
+            ps.print(dp.doubleValue());
+        } finally {
+            pp.giveBack(dp);
+        }
+    }
+
+    private void printInteger(PrintStream ps, TaggedValuePointable tvp) {
+        LongPointable lp = pp.takeOne(LongPointable.class);
+        try {
+            tvp.getValue(lp);
+            ps.print(lp.longValue());
+        } finally {
+            pp.giveBack(lp);
+        }
+    }
+
+    private void printString(PrintStream ps, TaggedValuePointable tvp) {
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        try {
+            tvp.getValue(utf8sp);
+            printString(ps, utf8sp);
+        } finally {
+            pp.giveBack(utf8sp);
+        }
+    }
+
+    private void printString(PrintStream ps, UTF8StringPointable utf8sp) {
+        int utfLen = utf8sp.getUTFLength();
+        int offset = 2;
+        while (utfLen > 0) {
+            char c = utf8sp.charAt(offset);
+            switch (c) {
+                case '<':
+                    ps.append("&lt;");
+                    break;
+
+                case '>':
+                    ps.append("&gt;");
+                    break;
+
+                case '&':
+                    ps.append("&amp;");
+                    break;
+
+                case '"':
+                    ps.append("&quot;");
+                    break;
+
+                case '\'':
+                    ps.append("&apos;");
+                    break;
+
+                default:
+                    ps.append(c);
+                    break;
+            }
+            int cLen = UTF8StringPointable.getModifiedUTF8Len(c);
+            offset += cLen;
+            utfLen -= cLen;
+        }
+    }
+
+    @Override
+    public void init() throws AlgebricksException {
+    }
+}
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java?rev=1357173&r1=1357172&r2=1357173&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java Wed Jul  4 08:48:45 2012
@@ -186,7 +186,9 @@ public class SAXContentHandler implement
                 int aUriCode = db.lookup(atts.getURI(i));
                 String aValue = atts.getValue(i);
                 tempABVS.reset();
-                tempABVS.getDataOutput().writeUTF(aValue);
+                DataOutput tempOut = tempABVS.getDataOutput();
+                tempOut.write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
+                tempOut.writeUTF(aValue);
                 enb.startAttribute(anb);
                 anb.setName(aUriCode, aLocalNameCode, aPrefixCode);
                 if (attachTypes) {