Esempio n. 1
0
 /**
  * Removes unused namespaces.
  *
  * @param node to be modified
  */
 private static void noPreserve(final ANode node) {
   final Atts ns = node.namespaces();
   final byte[] pref = node.qname().prefix();
   for (int i = ns.size() - 1; i >= 0; i--) {
     boolean f = eq(ns.name(i), pref);
     final AxisIter atts = node.attributes();
     for (ANode it; f && (it = atts.next()) != null; ) {
       f |= eq(it.qname().prefix(), pref);
     }
     if (!f) ns.delete(i);
   }
 }
Esempio n. 2
0
 /**
  * Sets the parameters of a prepared statement.
  *
  * @param params parameters
  * @param stmt prepared statement
  * @throws QueryException query exception
  */
 private void setParameters(final AxisMoreIter params, final PreparedStatement stmt)
     throws QueryException {
   int i = 0;
   for (ANode next; (next = params.next()) != null; ) {
     // Check name
     if (!next.qname().eq(E_PARAM)) PARWHICH.thrw(input, next.qname());
     final AxisIter attrs = next.attributes();
     byte[] paramType = null;
     boolean isNull = false;
     for (ANode attr; (attr = attrs.next()) != null; ) {
       // Attribute "type"
       if (eq(attr.nname(), TYPE)) paramType = attr.atom();
       // Attribute "null"
       else if (eq(attr.nname(), NULL))
         isNull = attr.atom() != null && Bln.parse(attr.atom(), input);
       // Not expected attribute
       else throw NOTEXPATTR.thrw(input, string(attr.nname()));
     }
     if (paramType == null) NOPARAMTYPE.thrw(input);
     final byte[] v = next.atom();
     isNull |= v.length == 0;
     setParam(++i, stmt, paramType, isNull ? null : string(v), isNull);
   }
 }