コード例 #1
0
 /**
  * Reset this Namespace support object for reuse.
  *
  * <p>It is necessary to invoke this method before reusing the Namespace support object for a new
  * session.
  */
 public void reset() {
   // Discarding the whole stack doesn't save us a lot versus
   // creating a new NamespaceSupport. Do we care, or should we
   // change this to just reset the root context?
   currentContext = new Context2(null);
   currentContext.declarePrefix("xml", XMLNS);
 }
コード例 #2
0
 /**
  * Declare a Namespace prefix.
  *
  * <p>This method declares a prefix in the current Namespace context; the prefix will remain in
  * force until this context is popped, unless it is shadowed in a descendant context.
  *
  * <p>To declare a default Namespace, use the empty string. The prefix must not be "xml" or
  * "xmlns".
  *
  * <p>Note that you must <em>not</em> declare a prefix after you've pushed and popped another
  * Namespace.
  *
  * <p>Note that there is an asymmetry in this library: while {@link #getPrefix getPrefix} will not
  * return the default "" prefix, even if you have declared one; to check for a default prefix, you
  * have to look it up explicitly using {@link #getURI getURI}. This asymmetry exists to make it
  * easier to look up prefixes for attribute names, where the default prefix is not allowed.
  *
  * @param prefix The prefix to declare, or null for the empty string.
  * @param uri The Namespace URI to associate with the prefix.
  * @return true if the prefix was legal, false otherwise
  * @see #processName
  * @see #getURI
  * @see #getPrefix
  */
 public boolean declarePrefix(String prefix, String uri) {
   if (prefix.equals("xml") || prefix.equals("xmlns")) {
     return false;
   } else {
     currentContext.declarePrefix(prefix, uri);
     return true;
   }
 }