** Changed in: zorba
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Zorba
Coders, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/859968

Title:
  Using put on an attribute produces an invalid Xdm instance and a
  segmentation fault

Status in Zorba - The XQuery Processor:
  Fix Released

Bug description:
  The following query creates an element node with a single children
  (not attribute). The attribute is then retrievable using child::node()
  but not attribute::*

  import module namespace doc = "http://www.zorba-
  xquery.com/modules/store/dynamic/documents";

  declare function local:dump-types($nodes as node()*) as element()*
  {
  for $node in $nodes
  return
   if ($node instance of text()) then ()
   else
   (
   element
   {
   if ($node instance of element()) then node-name($node)
   else if ($node instance of attribute()) then 
concat("attr-",string(node-name($node)))
   else if ($node instance of text()) then 'text'
   else if ($node instance of document-node()) then 'document-node'
   else if ($node instance of comment()) then 'comment'
   else if ($node instance of processing-instruction()) then 
'processing-instruction'
   else 'unknown'
   }
   {
    for $attr in $node/@*
     return <attributes>{local:dump-types($attr)}</attributes>,
    for $elem in $node/node()
     return <children>{local:dump-types($elem)}</children>
   }
   )
  };

  put(attribute {"test"}{"test"},"http://www.zorba-xquery.com/b";);
  count(doc:document("http://www.zorba-xquery.com/b";)/child::node()),
  local:dump-types(doc:document("http://www.zorba-xquery.com/b";))

  Returns:

  <?xml version="1.0" encoding="UTF-8"?>
  1<document-node><children><attr-test/></children></document-node>

  Segmentation faults then are easy:

  import module namespace doc = "http://www.zorba-
  xquery.com/modules/store/dynamic/documents";

  declare function local:dump-types($nodes as node()*) as element()*
  {
  for $node in $nodes
  return
        if ($node instance of text()) then ()
        else
        (
        element 
        {
        if ($node instance of element()) then node-name($node)
        else if ($node instance of attribute()) then 
concat("attr-",string(node-name($node)))
        else if ($node instance of text()) then 'text'
        else if ($node instance of document-node()) then 'document-node'
        else if ($node instance of comment()) then 'comment'
        else if ($node instance of processing-instruction()) then 
'processing-instruction'
        else 'unknown'   
        }       
        {
                for $attr in $node/@*
                        return 
<attributes>{local:dump-types($attr)}</attributes>,
                for $elem in $node/node()
                        return <children>{local:dump-types($elem)}</children>   
                
        }
        )
  };

  put(attribute {"test"}{"test"},"http://www.zorba-xquery.com/b";);
  replace node doc:document("http://www.zorba-xquery.com/b";)/child::node() with 
attribute{"aaa"}{"xxx"};

To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/859968/+subscriptions

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