cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From volker.schm...@basf-it-services.com
Subject Re: cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation TraversableGenerator.java
Date Thu, 25 Sep 2003 17:59:33 GMT

you can use
XMLUtils.startElement(contentHandler, "authentication")
instead of
contentHandler.startElement("", "authentication", "authentication", new
AttributesImpl());

not so much to write and doesn't create an new AttributesImpl(). There are
other helpers like createElement ... too.
I am a friend of the Garbage Collector ;.-)

Volker




joerg       2003/09/25 10:28:38

  Modified:    src/java/org/apache/cocoon/generation
                        DirectoryGenerator.java

src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        LinkTransformer.java
               src/samples/org/apache/cocoon/samples/errorhandling
                        ExceptionGenerator.java

src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context

                        AuthenticationContext.java

src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
               src/blocks/proxy/java/org/apache/cocoon/generation
                        GenericProxyGenerator.java
               src/blocks/scratchpad/java/org/apache/cocoon/generation
                        TraversableGenerator.java
  Log:
  fixing sax event handling in other classes than the RequestGenerator -
some of them I have never touched ;-)
  please review

  Revision  Changes    Path
  1.9       +3 -1
cocoon-2.1/src/java/org/apache/cocoon/generation/DirectoryGenerator.java

  Index: DirectoryGenerator.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/DirectoryGenerator.java,v

  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DirectoryGenerator.java        3 Sep 2003 15:00:56 -0000
1.8
  +++ DirectoryGenerator.java        25 Sep 2003 17:28:38 -0000
1.9
  @@ -318,10 +318,12 @@
               }

               this.contentHandler.startDocument();
  +            this.contentHandler.startPrefixMapping(PREFIX, URI);

               Stack ancestors = getAncestors(directoryFile);
               addAncestorPath(directoryFile, ancestors);

  +            this.contentHandler.endPrefixMapping(PREFIX);
               this.contentHandler.endDocument();
           } catch (SourceException se) {
               throw SourceUtil.handle(se);



  1.3       +6 -20
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java


  Index: LinkTransformer.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java,v

  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LinkTransformer.java           9 Sep 2003 18:52:33 -0000
1.2
  +++ LinkTransformer.java           25 Sep 2003 17:28:38 -0000
1.3
  @@ -101,11 +101,6 @@
       public static final String NAMESPACE_PREFIX = "ev";

       /**
  -     * Flag telling if prefix mapping has already be sent
  -     */
  -    protected boolean prefixMappingSent = false;
  -
  -    /**
        * Used for appending a request parameter containing the coplet id
        */
       protected String copletIdParamString = null;
  @@ -174,7 +169,6 @@
       public void recycle() {
           copletInstanceData = null;
           elementStack.clear();
  -        prefixMappingSent = false;
           copletIdParamString = null;
           portalNameParamString = null;
       }
  @@ -185,8 +179,9 @@
       public void startDocument() throws SAXException {
           super.startDocument();
           documentBase =
  -            (String) copletInstanceData.getAttribute(
  -                ProxyTransformer.DOCUMENT_BASE);
  +
(String)copletInstanceData.getAttribute(ProxyTransformer.DOCUMENT_BASE);
  +        super.startPrefixMapping(NAMESPACE_PREFIX,
  +                                 NewEventLinkTransformer.NAMESPACE_URI);
       }

       /**
  @@ -200,18 +195,9 @@
       /**
        * @see org.xml.sax.ContentHandler#startElement(String, String,
String, Attributes)
        */
  -    public void startElement(
  -        String uri,
  -        String name,
  -        String raw,
  -        Attributes attributes)
  +    public void startElement(String uri, String name, String raw,
  +                             Attributes attributes)
           throws SAXException {
  -        if (!prefixMappingSent) {
  -            super.startPrefixMapping(
  -                NAMESPACE_PREFIX,
  -                NewEventLinkTransformer.NAMESPACE_URI);
  -            prefixMappingSent = true;
  -        }

           if ("form".equalsIgnoreCase(name)) {
               handleTag(



  1.4       +7 -7
cocoon-2.1/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java


  Index: ExceptionGenerator.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java,v

  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExceptionGenerator.java        10 Jul 2003 13:17:01 -0000
1.3
  +++ ExceptionGenerator.java        25 Sep 2003 17:28:38 -0000
1.4
  @@ -103,13 +103,13 @@
           Attributes noAttrs = new AttributesImpl();

           this.contentHandler.startDocument();
  -        this.contentHandler.startElement(null, "html", "html", noAttrs);
  -        this.contentHandler.startElement(null, "body", "body", noAttrs);
  -        this.contentHandler.startElement(null, "p", "p", noAttrs);
  +        this.contentHandler.startElement("", "html", "html", noAttrs);
  +        this.contentHandler.startElement("", "body", "body", noAttrs);
  +        this.contentHandler.startElement("", "p", "p", noAttrs);
           this.contentHandler.characters(text.toCharArray(), 0,
text.length());
  -        this.contentHandler.endElement(null, "p", "p");
  -        this.contentHandler.endElement(null, "body", "body");
  -        this.contentHandler.endElement(null, "html", "html");
  +        this.contentHandler.endElement("", "p", "p");
  +        this.contentHandler.endElement("", "body", "body");
  +        this.contentHandler.endElement("", "html", "html");
           this.contentHandler.endDocument();
       }
   }



  1.10      +5 -5
cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java


  Index: AuthenticationContext.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java,v

  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AuthenticationContext.java           1 Jul 2003 19:26:40 -0000
 1.9
  +++ AuthenticationContext.java           25 Sep 2003 17:28:38 -0000
 1.10
  @@ -448,14 +448,14 @@

           if (path.equals("/") ) {
               // get all: first authentication then application
  -            contentHandler.startElement(null, "authentication",
"authentication", new AttributesImpl());
  +            contentHandler.startElement("", "authentication",
"authentication", new AttributesImpl());
               this.authContext.streamXML("/authentication",
contentHandler, lexicalHandler);
  -            contentHandler.endElement(null, "authentication",
"authentication");
  +            contentHandler.endElement("", "authentication",
"authentication");

               if (applicationName != null) {
  -                contentHandler.startElement(null, "application",
"application", new AttributesImpl());
  +                contentHandler.startElement("", "application",
"application", new AttributesImpl());
                   this.authContext.streamXML("/applications/" +
applicationName, contentHandler, lexicalHandler);
  -                contentHandler.endElement(null, "application",
"application");
  +                contentHandler.endElement("", "application",
"application");
               }
               return true;




  1.9       +7 -10
cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java


  Index: WebDAVSource.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java,v

  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- WebDAVSource.java        24 Sep 2003 22:34:52 -0000          1.8
  +++ WebDAVSource.java        25 Sep 2003 17:28:38 -0000          1.9
  @@ -502,16 +502,13 @@
           StreamResult result = new StreamResult(bOut);
           th.setResult(result);
           th.startDocument();
  -        th.startElement(
  -            NAMESPACE,
  -            COLLECTION_NAME,
  -            PREFIX + ":" + COLLECTION_NAME,
  -            new AttributesImpl());
  +        th.startPrefixMapping(PREFIX, NAMESPACE);
  +        th.startElement(NAMESPACE, COLLECTION_NAME,
  +                        PREFIX + ":" + COLLECTION_NAME, new
AttributesImpl());
           this.resourcesToSax(resources, th);
  -        th.endElement(
  -            NAMESPACE,
  -            COLLECTION_NAME,
  -            PREFIX + ":" + COLLECTION_NAME);
  +        th.endElement(NAMESPACE, COLLECTION_NAME,
  +                      PREFIX + ":" + COLLECTION_NAME);
  +        th.endPrefixMapping(PREFIX);
           th.endDocument();
           return new ByteArrayInputStream(bOut.toByteArray());
       }



  1.3       +3 -3
cocoon-2.1/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java


  Index: GenericProxyGenerator.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java,v

  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericProxyGenerator.java           4 Sep 2003 09:38:37 -0000
 1.2
  +++ GenericProxyGenerator.java           25 Sep 2003 17:28:38 -0000
 1.3
  @@ -197,8 +197,8 @@
               } else {
                   // Just send a dummy XML
                   this.contentHandler.startDocument();
  -                this.contentHandler.startElement(null, "no-xml-content",
"no-xml-content", new AttributesImpl());
  -                this.contentHandler.endElement(null, "no-xml-content",
"no-xml-content");
  +                this.contentHandler.startElement("", "no-xml-content",
"no-xml-content", new AttributesImpl());
  +                this.contentHandler.endElement("", "no-xml-content",
"no-xml-content");
                   this.contentHandler.endDocument();
               }




  1.2       +3 -1
cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/TraversableGenerator.java


  Index: TraversableGenerator.java
  ===================================================================
  RCS file:
/home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/TraversableGenerator.java,v

  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TraversableGenerator.java            4 Sep 2003 12:42:40 -0000
 1.1
  +++ TraversableGenerator.java            25 Sep 2003 17:28:38 -0000
 1.2
  @@ -313,10 +313,12 @@
               }

               this.contentHandler.startDocument();
  +            this.contentHandler.startPrefixMapping(PREFIX, URI);

               Stack ancestors = getAncestors(inputSource);
               addAncestorPath(inputSource, ancestors);

  +            this.contentHandler.endPrefixMapping(PREFIX);
               this.contentHandler.endDocument();
               if (this.validity != null) {
                   this.validity.close();









Mime
View raw message