Пример #1
0
 /**
  * This will look up the value of a SAX feature.
  *
  * @param name <code>String</code> the feature name, which is a fully-qualified URI.
  * @return <code>boolean</code> the current state of the feature (true or false).
  * @throws SAXNotRecognizedException when SAXOutputter does not recognize the feature name.
  * @throws SAXNotSupportedException when SAXOutputter recognizes the feature name but determine
  *     its value at this time.
  */
 public boolean getFeature(String name)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (SAX_FEATURE_NAMESPACE_PREFIXES.equals(name)) {
     // Namespace prefix declarations.
     return (this.declareNamespaces);
   }
   if (SAX_FEATURE_NAMESPACES.equals(name)) {
     // Namespaces feature always supported by SAXOutputter.
     return (true);
   }
   if (SAX_FEATURE_VALIDATION.equals(name)) {
     // Report DTD events.
     return (this.reportDtdEvents);
   }
   // Not a supported feature.
   throw new SAXNotRecognizedException(name);
 }
Пример #2
0
 /**
  * This will set the state of a SAX feature.
  *
  * <p>All XMLReaders are required to support setting to true and to false.
  *
  * <p>SAXOutputter currently supports the following SAX core features:
  *
  * <dl>
  *   <dt><code>http://xml.org/sax/features/namespaces</code>
  *   <dd><strong>description:</strong> <code>true</code> indicates namespace URIs and unprefixed
  *       local names for element and attribute names will be available
  *   <dd><strong>access:</strong> read/write, but always <code>true</code>!
  *   <dt><code>http://xml.org/sax/features/namespace-prefixes</code>
  *   <dd><strong>description:</strong> <code>true</code> indicates XML 1.0 names (with prefixes)
  *       and attributes (including xmlns* attributes) will be available
  *   <dd><strong>access:</strong> read/write
  *   <dt><code>http://xml.org/sax/features/validation</code>
  *   <dd><strong>description:</strong> controls whether SAXOutputter is reporting DTD-related
  *       events; if <code>true</code>, the DocType internal subset will be parsed to fire DTD
  *       events
  *   <dd><strong>access:</strong> read/write, defaults to <code>true</code>
  * </dl>
  *
  * @param name <code>String</code> the feature name, which is a fully-qualified URI.
  * @param value <code>boolean</code> the requested state of the feature (true or false).
  * @throws SAXNotRecognizedException when SAXOutputter does not recognize the feature name.
  * @throws SAXNotSupportedException when SAXOutputter recognizes the feature name but cannot set
  *     the requested value.
  */
 public void setFeature(String name, boolean value)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (SAX_FEATURE_NAMESPACE_PREFIXES.equals(name)) {
     // Namespace prefix declarations.
     this.setReportNamespaceDeclarations(value);
   } else {
     if (SAX_FEATURE_NAMESPACES.equals(name)) {
       if (value != true) {
         // Namespaces feature always supported by SAXOutputter.
         throw new SAXNotSupportedException(name);
       }
       // Else: true is OK!
     } else {
       if (SAX_FEATURE_VALIDATION.equals(name)) {
         // Report DTD events.
         this.setReportDTDEvents(value);
       } else {
         // Not a supported feature.
         throw new SAXNotRecognizedException(name);
       }
     }
   }
 }