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/06/15 04:00:36 UTC

svn commit: r1350443 [2/2] - in /incubator/vxquery/branches/vxquery_algebricks: vxquery-cli/src/main/java/org/apache/vxquery/cli/ vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/ vxquery-core/src/main/java/org/apache/vxquery/context/ ...

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinAtomicType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinAtomicType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinAtomicType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinAtomicType.java Fri Jun 15 02:00:34 2012
@@ -61,4 +61,23 @@ final class BuiltinAtomicType implements
     public String toString() {
         return String.valueOf(BuiltinTypeRegistry.INSTANCE.getTypeName(id));
     }
+
+    @Override
+    public int hashCode() {
+        return id;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        BuiltinAtomicType other = (BuiltinAtomicType) obj;
+        if (id != other.id)
+            return false;
+        return true;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java Fri Jun 15 02:00:34 2012
@@ -72,7 +72,5 @@ public class BuiltinTypeConstants {
     public static final int XS_NMTOKENS_TYPE_ID = 50;
     public static final int XS_ENTITIES_TYPE_ID = 51;
 
-    public static final int XSEXT_TYPE_TYPE_ID = 52;
-
-    public static final int BUILTIN_TYPE_COUNT = 53;
+    public static final int BUILTIN_TYPE_COUNT = 52;
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeRegistry.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeRegistry.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeRegistry.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeRegistry.java Fri Jun 15 02:00:34 2012
@@ -17,7 +17,7 @@
 package org.apache.vxquery.types;
 
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
@@ -161,9 +161,6 @@ public final class BuiltinTypeRegistry {
     public static final BuiltinAtomicType XS_NOTATION = new BuiltinAtomicType(BuiltinTypeConstants.XS_NOTATION_TYPE_ID,
             XS_ANY_ATOMIC, DerivationProcess.RESTRICTION);
 
-    public static final BuiltinAtomicType XSEXT_TYPE = new BuiltinAtomicType(BuiltinTypeConstants.XSEXT_TYPE_TYPE_ID,
-            XS_ANY_ATOMIC, DerivationProcess.RESTRICTION);
-
     public static final BuiltinTypeRegistry INSTANCE = new BuiltinTypeRegistry();
 
     private final SchemaType[] types;
@@ -219,7 +216,6 @@ public final class BuiltinTypeRegistry {
         types[BuiltinTypeConstants.XS_ANY_URI_TYPE_ID] = XS_ANY_URI;
         types[BuiltinTypeConstants.XS_QNAME_TYPE_ID] = XS_QNAME;
         types[BuiltinTypeConstants.XS_NOTATION_TYPE_ID] = XS_NOTATION;
-        types[BuiltinTypeConstants.XSEXT_TYPE_TYPE_ID] = XSEXT_TYPE;
 
         typeNames = new QName[BuiltinTypeConstants.BUILTIN_TYPE_COUNT];
         typeNames[BuiltinTypeConstants.XS_ANY_SIMPLE_TYPE_ID] = BuiltinTypeQNames.XS_ANY_SIMPLE_TYPE_QNAME;
@@ -269,7 +265,6 @@ public final class BuiltinTypeRegistry {
         typeNames[BuiltinTypeConstants.XS_ANY_URI_TYPE_ID] = BuiltinTypeQNames.XS_ANY_URI_TYPE_QNAME;
         typeNames[BuiltinTypeConstants.XS_QNAME_TYPE_ID] = BuiltinTypeQNames.XS_QNAME_TYPE_QNAME;
         typeNames[BuiltinTypeConstants.XS_NOTATION_TYPE_ID] = BuiltinTypeQNames.XS_NOTATION_TYPE_QNAME;
-        typeNames[BuiltinTypeConstants.XSEXT_TYPE_TYPE_ID] = BuiltinTypeQNames.XSEXT_TYPE_TYPE_QNAME;
     }
 
     public SchemaType getSchemaTypeById(int id) {
@@ -294,7 +289,7 @@ public final class BuiltinTypeRegistry {
     public static final Map<QName, SchemaType> TYPE_MAP;
 
     static {
-        Map<QName, SchemaType> typeMap = new HashMap<QName, SchemaType>();
+        Map<QName, SchemaType> typeMap = new LinkedHashMap<QName, SchemaType>();
         typeMap.put(BuiltinTypeQNames.XS_ANY_SIMPLE_TYPE_QNAME, AnySimpleType.INSTANCE);
         typeMap.put(BuiltinTypeQNames.XS_ANY_ATOMIC_TYPE_QNAME, XS_ANY_ATOMIC);
         typeMap.put(BuiltinTypeQNames.XS_STRING_TYPE_QNAME, XS_STRING);
@@ -342,7 +337,6 @@ public final class BuiltinTypeRegistry {
         typeMap.put(BuiltinTypeQNames.XS_ANY_URI_TYPE_QNAME, XS_ANY_URI);
         typeMap.put(BuiltinTypeQNames.XS_QNAME_TYPE_QNAME, XS_QNAME);
         typeMap.put(BuiltinTypeQNames.XS_NOTATION_TYPE_QNAME, XS_NOTATION);
-        typeMap.put(BuiltinTypeQNames.XSEXT_TYPE_TYPE_QNAME, XSEXT_TYPE);
         TYPE_MAP = Collections.unmodifiableMap(typeMap);
     }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java Fri Jun 15 02:00:34 2012
@@ -26,4 +26,14 @@ public final class CommentType extends A
     public NodeKind getNodeKind() {
         return NodeKind.COMMENT;
     }
+
+    @Override
+    public int hashCode() {
+        return CommentType.class.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        return other instanceof CommentType;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java Fri Jun 15 02:00:34 2012
@@ -33,4 +33,29 @@ public final class DocumentType extends 
     public ElementType getElementType() {
         return elementType;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((elementType == null) ? 0 : elementType.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DocumentType other = (DocumentType) obj;
+        if (elementType == null) {
+            if (other.elementType != null)
+                return false;
+        } else if (!elementType.equals(other.elementType))
+            return false;
+        return true;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java Fri Jun 15 02:00:34 2012
@@ -47,6 +47,40 @@ public final class ElementType extends A
     }
 
     @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((contentType == null) ? 0 : contentType.hashCode());
+        result = prime * result + ((nameTest == null) ? 0 : nameTest.hashCode());
+        result = prime * result + (nilled ? 1231 : 1237);
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ElementType other = (ElementType) obj;
+        if (contentType == null) {
+            if (other.contentType != null)
+                return false;
+        } else if (!contentType.equals(other.contentType))
+            return false;
+        if (nameTest == null) {
+            if (other.nameTest != null)
+                return false;
+        } else if (!nameTest.equals(other.nameTest))
+            return false;
+        if (nilled != other.nilled)
+            return false;
+        return true;
+    }
+
+    @Override
     public String toString() {
         return "NodeTest(" + nameTest + ", " + contentType + ", nilled = " + nilled + ")";
     }

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java Fri Jun 15 02:00:34 2012
@@ -26,4 +26,14 @@ public final class EmptySequenceType imp
     public boolean isAtomicType() {
         return false;
     }
+
+    @Override
+    public int hashCode() {
+        return EmptySequenceType.class.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        return other instanceof EmptySequenceType;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NameTest.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NameTest.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NameTest.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NameTest.java Fri Jun 15 02:00:34 2012
@@ -50,4 +50,35 @@ public final class NameTest {
     public String toString() {
         return "NameTest(" + asQName() + ")";
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((localName == null) ? 0 : localName.hashCode());
+        result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        NameTest other = (NameTest) obj;
+        if (localName == null) {
+            if (other.localName != null)
+                return false;
+        } else if (!localName.equals(other.localName))
+            return false;
+        if (uri == null) {
+            if (other.uri != null)
+                return false;
+        } else if (!uri.equals(other.uri))
+            return false;
+        return true;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java Fri Jun 15 02:00:34 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.vxquery.types;
 
-public class NoneType implements ItemType {
+public final class NoneType implements ItemType {
     public static final NoneType INSTANCE = new NoneType();
 
     private NoneType() {
@@ -26,4 +26,14 @@ public class NoneType implements ItemTyp
     public boolean isAtomicType() {
         return false;
     }
+
+    @Override
+    public int hashCode() {
+        return NoneType.class.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        return other instanceof NoneType;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java Fri Jun 15 02:00:34 2012
@@ -33,4 +33,29 @@ public final class ProcessingInstruction
     public String getTarget() {
         return target;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((target == null) ? 0 : target.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ProcessingInstructionType other = (ProcessingInstructionType) obj;
+        if (target == null) {
+            if (other.target != null)
+                return false;
+        } else if (!target.equals(other.target))
+            return false;
+        return true;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/SequenceType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/SequenceType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/SequenceType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/SequenceType.java Fri Jun 15 02:00:34 2012
@@ -17,17 +17,17 @@
 package org.apache.vxquery.types;
 
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 public final class SequenceType {
-    private static final Map<ItemType, SequenceType[]> BUILTIN_SEQ_TYPES;
+    public static final Map<ItemType, SequenceType[]> BUILTIN_SEQ_TYPES;
 
     private ItemType itemType;
     private Quantifier quantifier;
 
     static {
-        Map<ItemType, SequenceType[]> types = new HashMap<ItemType, SequenceType[]>();
+        Map<ItemType, SequenceType[]> types = new LinkedHashMap<ItemType, SequenceType[]>();
 
         createBuiltinEntry(types, BuiltinTypeRegistry.XS_ANY_ATOMIC);
         createBuiltinEntry(types, BuiltinTypeRegistry.XS_STRING);
@@ -116,8 +116,32 @@ public final class SequenceType {
         return quantifier;
     }
 
-    public XQType toXQType() {
-        return TypeOperations.quantified(itemType, quantifier);
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((itemType == null) ? 0 : itemType.hashCode());
+        result = prime * result + ((quantifier == null) ? 0 : quantifier.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SequenceType other = (SequenceType) obj;
+        if (itemType == null) {
+            if (other.itemType != null)
+                return false;
+        } else if (!itemType.equals(other.itemType))
+            return false;
+        if (quantifier != other.quantifier)
+            return false;
+        return true;
     }
 
     public String toString() {

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java Fri Jun 15 02:00:34 2012
@@ -26,4 +26,14 @@ public final class TextType extends Abst
     public NodeKind getNodeKind() {
         return NodeKind.TEXT;
     }
+
+    @Override
+    public int hashCode() {
+        return TextType.class.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        return other instanceof TextType;
+    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java?rev=1350443&r1=1350442&r2=1350443&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java Fri Jun 15 02:00:34 2012
@@ -1426,9 +1426,10 @@ public class XMLQueryTranslator {
                     }
                     Function axisFn = translateAxis(axis);
                     NodeType nt = translateNodeTest(axis, axisNode.getNodeTest());
+                    int ntCode = currCtx.lookupSequenceType(SequenceType.create(nt, Quantifier.QUANT_ONE));
                     ctxExpr = sfce(axisFn,
                             treat(ctxExpr, SequenceType.create(AnyNodeType.INSTANCE, Quantifier.QUANT_STAR)),
-                            ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), nt));
+                            ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), ntCode));
                     asc = isForwardAxis(axis);
                 } else if (ASTTag.FILTER_EXPRESSION.equals(pathNode.getTag())) {
                     FilterExprNode filterNode = (FilterExprNode) pathNode;
@@ -1811,41 +1812,41 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
-                case BuiltinTypeConstants.XS_INTEGER_TYPE_ID: {
+                case BuiltinTypeConstants.XS_INT_TYPE_ID: {
                     baaos.reset();
                     try {
-                        dOut.write((byte) BuiltinTypeConstants.XS_INTEGER_TYPE_ID);
-                        dOut.writeLong(((Long) value).longValue());
+                        dOut.write((byte) BuiltinTypeConstants.XS_INT_TYPE_ID);
+                        dOut.writeInt(((Number) value).intValue());
                     } catch (IOException e) {
                         throw new SystemException(ErrorCode.SYSE0001, e);
                     }
                     break;
                 }
-                case BuiltinTypeConstants.XS_DOUBLE_TYPE_ID: {
+                case BuiltinTypeConstants.XS_INTEGER_TYPE_ID: {
                     baaos.reset();
                     try {
-                        dOut.write((byte) BuiltinTypeConstants.XS_DOUBLE_TYPE_ID);
-                        dOut.writeDouble(((Double) value).doubleValue());
+                        dOut.write((byte) BuiltinTypeConstants.XS_INTEGER_TYPE_ID);
+                        dOut.writeLong(((Number) value).longValue());
                     } catch (IOException e) {
                         throw new SystemException(ErrorCode.SYSE0001, e);
                     }
                     break;
                 }
-                case BuiltinTypeConstants.XS_STRING_TYPE_ID: {
+                case BuiltinTypeConstants.XS_DOUBLE_TYPE_ID: {
                     baaos.reset();
                     try {
-                        dOut.write((byte) BuiltinTypeConstants.XS_STRING_TYPE_ID);
-                        stringVB.write((CharSequence) value, dOut);
+                        dOut.write((byte) BuiltinTypeConstants.XS_DOUBLE_TYPE_ID);
+                        dOut.writeDouble(((Number) value).doubleValue());
                     } catch (IOException e) {
                         throw new SystemException(ErrorCode.SYSE0001, e);
                     }
                     break;
                 }
-                case BuiltinTypeConstants.XSEXT_TYPE_TYPE_ID: {
-                    SequenceType st = (SequenceType) value;
+                case BuiltinTypeConstants.XS_STRING_TYPE_ID: {
                     baaos.reset();
                     try {
-                        dOut.write((byte) BuiltinTypeConstants.XSEXT_TYPE_TYPE_ID);
+                        dOut.write((byte) BuiltinTypeConstants.XS_STRING_TYPE_ID);
+                        stringVB.write((CharSequence) value, dOut);
                     } catch (IOException e) {
                         throw new SystemException(ErrorCode.SYSE0001, e);
                     }
@@ -1913,28 +1914,33 @@ public class XMLQueryTranslator {
     }
 
     private ILogicalExpression promote(ILogicalExpression expr, SequenceType type) throws SystemException {
+        int typeCode = currCtx.lookupSequenceType(type);
         return sfce(BuiltinOperators.PROMOTE, expr,
-                ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), type));
+                ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), typeCode));
     }
 
     private ILogicalExpression treat(ILogicalExpression expr, SequenceType type) throws SystemException {
+        int typeCode = currCtx.lookupSequenceType(type);
         return sfce(BuiltinOperators.TREAT, expr,
-                ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), type));
+                ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), typeCode));
     }
 
     private ILogicalExpression cast(ILogicalExpression expr, SequenceType type) throws SystemException {
+        int typeCode = currCtx.lookupSequenceType(type);
         return sfce(BuiltinOperators.CAST, expr,
-                ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), type));
+                ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), typeCode));
     }
 
     private ILogicalExpression castable(ILogicalExpression expr, SequenceType type) throws SystemException {
+        int typeCode = currCtx.lookupSequenceType(type);
         return sfce(BuiltinOperators.CASTABLE, expr,
-                ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), type));
+                ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), typeCode));
     }
 
     private ILogicalExpression instanceOf(ILogicalExpression expr, SequenceType type) throws SystemException {
+        int typeCode = currCtx.lookupSequenceType(type);
         return sfce(BuiltinOperators.INSTANCE_OF, expr,
-                ce(SequenceType.create(BuiltinTypeRegistry.XSEXT_TYPE, Quantifier.QUANT_ONE), type));
+                ce(SequenceType.create(BuiltinTypeRegistry.XS_INT, Quantifier.QUANT_ONE), typeCode));
     }
 
     private List<LogicalVariable> translateExpressionList(List<ASTNode> expressions, TranslationContext tCtx)