bruno       2003/03/18 07:54:52

  Modified:    src/java/org/apache/cocoon/xml/dom DOMStreamer.java
  Log:
  re-added setContentHandler method, thanks to Unico Hommes (Unico at hippo dot nl) 
for reporting.
  
  Revision  Changes    Path
  1.4       +17 -16    cocoon-2.0/src/java/org/apache/cocoon/xml/dom/DOMStreamer.java
  
  Index: DOMStreamer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/xml/dom/DOMStreamer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMStreamer.java  11 Mar 2003 15:40:54 -0000      1.3
  +++ DOMStreamer.java  18 Mar 2003 15:54:52 -0000      1.4
  @@ -90,8 +90,11 @@
    */
   public class DOMStreamer implements XMLProducer {
   
  +    /** Default value for normalizeNamespaces. */
  +    private final boolean DEFAULT_NORMALIZE_NAMESPACES = true;
  +
       /** Indicates whether namespace normalization should happen. */
  -    protected boolean normalizeNamespaces = true;
  +    protected boolean normalizeNamespaces = DEFAULT_NORMALIZE_NAMESPACES;
   
       /** DOMStreamer used in case of namespace normalization. */
       protected NamespaceNormalizingDOMStreamer namespaceNormalizingDOMStreamer = new 
NamespaceNormalizingDOMStreamer();
  @@ -149,18 +152,16 @@
       }
   
       /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     */
  +    public void setContentHandler(ContentHandler handler) {
  +        defaultDOMStreamer.setContentHandler(handler);
  +        namespaceNormalizingDOMStreamer.setContentHandler(handler);
  +    }
  +    /**
        * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
        */
       public void setLexicalHandler(LexicalHandler handler) {
  -        // FIXME Shouldn't be used IHMO.
  -
           defaultDOMStreamer.setLexicalHandler(handler);
           namespaceNormalizingDOMStreamer.setLexicalHandler(handler);
       }
  @@ -186,7 +187,7 @@
       public void recycle() {
           defaultDOMStreamer.recycle();
           namespaceNormalizingDOMStreamer.recycle();
  -        normalizeNamespaces = true;
  +        normalizeNamespaces = DEFAULT_NORMALIZE_NAMESPACES;
       }
   
       /**
  @@ -463,9 +464,10 @@
                               Map.Entry entry = (Map.Entry) localNsDeclIt.next();
                               String pr = (String) entry.getKey();
                               String ns = (String) entry.getValue();
  -                            String pr1 = pr.equals("") ? "xmlns" : pr;
  -                            String qn = pr.equals("") ? "xmlns" : "xmlns:" + pr;
  -                            newAttrs.addAttribute("", pr1, qn, "CDATA", ns);
  +                            // the following lines enable the creation of explicit 
xmlns attributes
  +                            //String pr1 = pr.equals("") ? "xmlns" : pr;
  +                            //String qn = pr.equals("") ? "xmlns" : "xmlns:" + pr;
  +                            //newAttrs.addAttribute("", pr1, qn, "CDATA", ns);
                               // System.out.println("starting prefix mapping  for 
prefix " + pr + " for " + ns);
                               contentHandler.startPrefixMapping(pr, ns);
                           }
  @@ -532,7 +534,6 @@
            * @return the namespace, or null if not found.
            */
           public String getNamespaceForPrefix(String prefix, Element 
namespaceContext) {
  -            // TODO cache this information in the ElementInfo objects?
               int type;
               Node parent = namespaceContext;
               String namespace = null;
  
  
  

Reply via email to