コード例 #1
0
 /** Returns the URI of the current prefix or "" if no URI can be found */
 protected String getURI(Object node, Context context) {
   String uri = context.getNavigator().translateNamespacePrefixToUri(prefix, node);
   if (uri == null) {
     uri = context.getContextSupport().translateNamespacePrefixToUri(prefix);
   }
   if (uri == null) {
     uri = "";
   }
   return uri;
 }
コード例 #2
0
  /** @return true if the pattern matches the given node */
  public boolean matches(Object node, Context context) {
    Navigator navigator = context.getNavigator();
    String uri = getURI(node, context);

    if (nodeType == Pattern.ELEMENT_NODE) {
      return navigator.isElement(node) && uri.equals(navigator.getElementNamespaceUri(node));
    } else if (nodeType == Pattern.ATTRIBUTE_NODE) {
      return navigator.isAttribute(node) && uri.equals(navigator.getAttributeNamespaceUri(node));
    }
    return false;
  }