Nicolae Brinza has proposed merging lp:~nbrinza/zorba/bugs into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #867256 in Zorba: ""instance of document-node(element(x))" in predicate"
  https://bugs.launchpad.net/zorba/+bug/867256

For more details, see:
https://code.launchpad.net/~nbrinza/zorba/bugs/+merge/81095

Fix for lp: bug #867256 - test Steps-leading-lone-slash-8a is failing
-- 
https://code.launchpad.net/~nbrinza/zorba/bugs/+merge/81095
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/types/typeimpl.cpp' (properties changed: -x to +x)
--- src/types/typeimpl.cpp	2011-07-01 05:22:12 +0000
+++ src/types/typeimpl.cpp	2011-11-02 23:24:29 +0000
@@ -361,7 +361,7 @@
 
 
 bool NodeXQType::is_subtype(
-    const TypeManager* tm, 
+    const TypeManager* tm,
     const NodeXQType& supertype,
     const QueryLoc& loc) const
 {
@@ -443,7 +443,7 @@
 
 
 bool NodeXQType::is_supertype(
-    const TypeManager* tm, 
+    const TypeManager* tm,
     const store::Item* subitem,
     const QueryLoc& loc) const
 {
@@ -488,14 +488,28 @@
     }
   }
 
-  if (m_node_kind != store::StoreConsts::elementNode && 
-      m_node_kind != store::StoreConsts::attributeNode)
+  if (m_node_kind != store::StoreConsts::elementNode &&
+      m_node_kind != store::StoreConsts::attributeNode &&
+      (m_content_type == NULL
+      ||
+      m_node_kind != store::StoreConsts::documentNode))
     return true;
 
   if (m_content_type == NULL ||
       m_content_type->type_kind() == XQType::ANY_TYPE_KIND)
     return true;
 
+  // document-node( E ) matches any document node that contains exactly one element 
+  // node, optionally accompanied by one or more comment and processing instruction 
+  // nodes, if E is an ElementTest or SchemaElementTest that matches the element node.
+  if (m_node_kind == store::StoreConsts::documentNode &&
+      m_content_type != NULL &&
+      m_content_type->type_kind() == XQType::NODE_TYPE_KIND)
+  {
+    xqtref_t documentNodeType = tm->create_value_type(subitem, loc);
+    return TypeOps::is_subtype(tm, *documentNodeType, *this);
+  }
+
   xqtref_t subContentType = tm->create_named_type(subitem->getType(),
                                                   TypeConstants::QUANT_ONE,
                                                   loc,

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to