Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23940/algebra

Modified Files:
        builtins.c logical.c 
Log Message:

Implementation for ``fn:node-name($arg as node()?) as xs:QName?'',
which forms the backbone of 
  - fn:name (),
  - fn:local_name() and
  - fn:namespace_uri ().

doc_access-operator now has another accessor ``doc_QName'',
which supports access to the QName. ``doc_QName'' is not supported
by the MIL translation, yet.


U logical.c
Index: logical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/logical.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- logical.c   30 May 2008 09:40:50 -0000      1.99
+++ logical.c   30 May 2008 12:42:31 -0000      1.100
@@ -3022,7 +3022,12 @@
         ret->schema.items[i] = n->schema.items[i];
 
     ret->schema.items[i]
-        = (struct PFalg_schm_item_t) { .type = aat_str, .name = res };
+        = (struct PFalg_schm_item_t) {
+                               .type = (doc_col != doc_qname)
+                                               ? aat_str
+                                               : aat_qname,
+                               .name = res
+                       };
 
     ret->sem.doc_access.res = res;
     ret->sem.doc_access.att = col;

U builtins.c
Index: builtins.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- builtins.c  30 May 2008 09:40:48 -0000      1.96
+++ builtins.c  30 May 2008 12:42:30 -0000      1.97
@@ -344,6 +344,169 @@
 /* ------------ */
 /* 2. ACCESSORS */
 /* ------------ */
+
+/* ----------------- */
+/* 2.1. fn:node-name */
+/* ----------------- */
+
+/* The fn:node-name function returns an expanded for 
+ * node kinds that can have names.
+ * Among them obviously elements and attributes. 
+ */
+
+static struct PFla_pair_t
+fn_bui_node_name (struct PFla_pair_t
+                    (*nodes)
+                    (const PFla_op_t *, bool, PFla_pair_t *args),
+                  const PFla_op_t *loop,
+                  bool ordering,
+                  struct PFla_pair_t *args)
+{
+    PFla_op_t *qnames = project (
+                            doc_access (
+                                PFla_set_to_la (args[0].frag),
+                                nodes (loop, ordering, args).rel,
+                                att_res, att_item, doc_qname),
+                            proj (att_iter, att_iter),
+                            proj (att_pos, att_pos),
+                            proj (att_item, att_res));
+
+    return (struct PFla_pair_t) {
+                    .rel = qnames,
+                    .frag = PFla_empty_set ()
+                };
+}
+
+static struct PFla_pair_t
+fn_bui_node_name_attr_ (const PFla_op_t* loop,
+                        bool ordering,
+                        struct PFla_pair_t *args)
+{
+    (void)ordering; (void)loop;
+    return args[0];
+}
+
+static struct PFla_pair_t
+fn_bui_node_name_elem_ (const PFla_op_t *loop,
+                        bool ordering,
+                        struct PFla_pair_t *args)
+{
+    (void)ordering; (void)loop;
+    return args[0];
+}
+
+/* filter attributes only */
+static struct PFla_pair_t
+fn_bui_node_name_attr_filter (const PFla_op_t* loop,
+                              bool ordering,
+                              struct PFla_pair_t *args)
+{
+    (void)loop; (void)ordering;
+    
+    PFla_op_t *attributes = NULL;
+    PFalg_step_spec_t self_attr_spec;
+    self_attr_spec.axis = alg_self;
+    self_attr_spec.kind = node_kind_attr;
+    
+    /* just find every attribute  */
+    self_attr_spec.qname = PFqname (PFns_wild, NULL); 
+    
+    attributes = attach (
+                    PFla_step_simple (
+                        PFla_set_to_la (args[0].frag),
+                        project (args[0].rel,
+                                 proj (att_iter, att_iter),
+                                 proj (att_item, att_item)),
+                        self_attr_spec,
+                        att_iter, att_item, att_item),
+                    att_pos, lit_int(1));
+
+    return (struct PFla_pair_t) {
+                    .rel = attributes,
+                    .frag = args[0].frag
+                };
+}
+
+/* filter elements only */
+static struct PFla_pair_t
+fn_bui_node_name_element_filter (const PFla_op_t* loop,
+                                 bool ordering,
+                                 struct PFla_pair_t *args)
+{
+    (void)loop; (void)ordering;
+    
+    PFla_op_t *elements = NULL;
+    PFalg_step_spec_t self_elem_spec;
+    self_elem_spec.axis = alg_self;
+    self_elem_spec.kind = node_kind_elem; 
+    
+    /* just find every element */
+    self_elem_spec.qname = PFqname (PFns_wild, NULL);
+    
+    elements = attach (
+                    PFla_step_simple (
+                        PFla_set_to_la (args[0].frag),
+                        project (args[0].rel,
+                                 proj (att_iter, att_iter),
+                                 proj (att_item, att_item)),
+                        self_elem_spec,
+                        att_iter, att_item, att_item),
+                        att_pos, lit_int(1));
+                                
+    return (struct PFla_pair_t) {
+                    .rel = elements,
+                    .frag = args[0].frag
+                };
+}
+
+static struct PFla_pair_t
+fn_bui_node_name_node_ (const PFla_op_t *loop,
+                        bool ordering,
+                        struct PFla_pair_t *args)
+{
+    PFla_op_t *union_ = disjunion (
+                            fn_bui_node_name_attr_filter (loop,
+                                                          ordering,
+                                                          args).rel,
+                            fn_bui_node_name_element_filter (loop,
+                                                             ordering,
+                                                             args).rel);
+                                                    
+    return (struct PFla_pair_t) {
+                .rel  = union_,
+                .frag = args[0].frag
+            };
+}
+
+/* node-name for attributes */
+struct PFla_pair_t
+PFfn_bui_node_name_attr (const PFla_op_t *loop,
+                         bool ordering,
+                         struct PFla_pair_t *args)
+{
+    return fn_bui_node_name (fn_bui_node_name_attr_, loop, ordering, args);
+}
+
+/* node-name for elements */
+struct PFla_pair_t 
+PFfn_bui_node_name_elem (const PFla_op_t *loop,
+                         bool ordering,
+                         struct PFla_pair_t *args)
+{
+    return fn_bui_node_name (fn_bui_node_name_elem_, loop, ordering, args);
+}
+
+/* node-name for general nodes */
+struct PFla_pair_t
+PFfn_bui_node_name_node (const PFla_op_t *loop,
+                         bool ordering,
+                         struct PFla_pair_t *args)
+{
+    return fn_bui_node_name (fn_bui_node_name_node_, loop, ordering, args);
+}
+
+
+
 /* -------------- */
 /* 2.3. fn:string */
 /* -------------- */


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to