Example #1
0
 /**
  * Returns the initial context value of a path or {@code null}.
  *
  * @param qc query context (may be @code null)
  * @return root
  */
 private Value initial(final QueryContext qc) {
   // current context value
   final Value v = qc != null ? qc.value : null;
   // no root or context expression: return context
   if (root == null || root instanceof Context) return v;
   // root reference
   if (root instanceof Root) return v != null && v instanceof Item ? Root.root(v) : v;
   // root is value: return root
   if (root.isValue()) return (Value) root;
   // data reference
   final Data d = root.data();
   if (d != null) return new DBNode(d, 0, Data.ELEM);
   // otherwise, return null
   return null;
 }
Example #2
0
 @Override
 public Data data() {
   if (root != null) {
     // data reference
     final Data data = root.data();
     if (data != null) {
       final int sl = steps.length;
       for (int s = 0; s < sl; s++) {
         if (axisStep(s) == null) return null;
       }
       return data;
     }
   }
   return null;
 }