/**
     * Reads a property list (key and element pairs) from the input stream. The stream is assumed to
     * be using the ISO 8859-1 character encoding.
     */
    public synchronized void load(InputStream is) throws IOException {
      BufferedReader r;
      r = new BufferedReader(new InputStreamReader(is, PREFERENCE_ENCODING));
      DocumentFactory df =
          new SAXDocumentFactory(
              GenericDOMImplementation.getDOMImplementation(), xmlParserClassName);
      Document doc =
          df.createDocument("http://xml.apache.org/batik/preferences", "preferences", null, r);
      Element elt = doc.getDocumentElement();
      for (Node n = elt.getFirstChild(); n != null; n = n.getNextSibling()) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
          if (n.getNodeName().equals("property")) {
            String name = ((Element) n).getAttributeNS(null, "name");

            StringBuffer cont = new StringBuffer();
            for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling()) {
              if (c.getNodeType() == Node.TEXT_NODE) {
                cont.append(c.getNodeValue());
              } else {
                break;
              }
            }
            String val = cont.toString();
            put(name, val);
          }
        }
      }
    }
  /**
   * Transcodes the specified XML input in the specified output. All <code>TranscoderException
   * </code> exceptions not catched previously are tagged as fatal errors (ie. call the <code>
   * fatalError</code> method of the <code>ErrorHandler</code>).
   *
   * @param input the XML input to transcode
   * @param output the ouput where to transcode
   * @exception TranscoderException if an error occured while transcoding
   */
  public void transcode(TranscoderInput input, TranscoderOutput output) throws TranscoderException {

    Document document = null;
    String uri = input.getURI();
    if (input.getDocument() != null) {
      document = input.getDocument();
    } else {
      String parserClassname = (String) hints.get(KEY_XML_PARSER_CLASSNAME);
      String namespaceURI = (String) hints.get(KEY_DOCUMENT_ELEMENT_NAMESPACE_URI);
      String documentElement = (String) hints.get(KEY_DOCUMENT_ELEMENT);
      DOMImplementation domImpl = (DOMImplementation) hints.get(KEY_DOM_IMPLEMENTATION);

      if (parserClassname == null) {
        parserClassname = XMLResourceDescriptor.getXMLParserClassName();
      }
      if (domImpl == null) {
        handler.fatalError(
            new TranscoderException("Unspecified transcoding hints: KEY_DOM_IMPLEMENTATION"));
        return;
      }
      if (namespaceURI == null) {
        handler.fatalError(
            new TranscoderException(
                "Unspecified transcoding hints: KEY_DOCUMENT_ELEMENT_NAMESPACE_URI"));
        return;
      }
      if (documentElement == null) {
        handler.fatalError(
            new TranscoderException("Unspecified transcoding hints: KEY_DOCUMENT_ELEMENT"));
        return;
      }
      // parse the XML document
      DocumentFactory f = createDocumentFactory(domImpl, parserClassname);
      Object xmlParserValidating = hints.get(KEY_XML_PARSER_VALIDATING);
      boolean validating =
          xmlParserValidating != null && ((Boolean) xmlParserValidating).booleanValue();
      f.setValidating(validating);
      try {
        if (input.getInputStream() != null) {
          document =
              f.createDocument(
                  namespaceURI, documentElement, input.getURI(), input.getInputStream());
        } else if (input.getReader() != null) {
          document =
              f.createDocument(namespaceURI, documentElement, input.getURI(), input.getReader());
        } else if (input.getXMLReader() != null) {
          document =
              f.createDocument(namespaceURI, documentElement, input.getURI(), input.getXMLReader());
        } else if (uri != null) {
          document = f.createDocument(namespaceURI, documentElement, uri);
        }
      } catch (DOMException ex) {
        handler.fatalError(new TranscoderException(ex));
      } catch (IOException ex) {
        handler.fatalError(new TranscoderException(ex));
      }
    }
    // call the dedicated transcode method
    if (document != null) {
      try {
        transcode(document, uri, output);
      } catch (TranscoderException ex) {
        // at this time, all TranscoderExceptions are fatal errors
        handler.fatalError(ex);
        return;
      }
    }
  }