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/81424

Fix for lp: bug #867256 - test Steps-leading-lone-slash-8a is failing
-- 
https://code.launchpad.net/~nbrinza/zorba/bugs/+merge/81424
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2011-11-04 11:40:20 +0000
+++ ChangeLog	2011-11-07 02:12:25 +0000
@@ -1,7 +1,8 @@
 Zorba - The XQuery Processor
 
 version 2.x
-
+  
+  * Fixed bug #867256 (document-node(element(x)) types and tests were not working correctly)
   * Custom Full-text thesaurus.
   * Fixed bug #3401971 (node-by-reference on dynamic collections)
   * Optimization for positioned sequence access (e.g. $x[$x[1]] where $x is a

=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp	2011-07-01 05:22:12 +0000
+++ src/types/typeimpl.cpp	2011-11-07 02:12:25 +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,30 @@
     }
   }
 
-  if (m_node_kind != store::StoreConsts::elementNode && 
-      m_node_kind != store::StoreConsts::attributeNode)
+  // 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.
+  bool is_element_test = (
+      m_node_kind == store::StoreConsts::documentNode &&
+      m_content_type != NULL &&
+      m_content_type->type_kind() == XQType::NODE_TYPE_KIND &&
+      dynamic_cast<const NodeXQType*>(m_content_type.getp())->m_schema_test == false);
+
+  if (m_node_kind != store::StoreConsts::elementNode &&
+      m_node_kind != store::StoreConsts::attributeNode &&
+      !is_element_test)
     return true;
 
   if (m_content_type == NULL ||
       m_content_type->type_kind() == XQType::ANY_TYPE_KIND)
     return true;
 
+  if (is_element_test)
+  {
+    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