You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/04/11 10:38:26 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/serialization AbstractTextSerializer.java

bruno       2003/04/11 01:38:26

  Modified:    src/java/org/apache/cocoon/serialization
                        AbstractTextSerializer.java
  Log:
  Fixed a problem in NamespaceAsAttributes: if there are start/endPrefixMapping calls
  with no element event between them, the namespace(s) were incorrectly added to the next
  element following the endPrefixMapping call. Especially troublesome in case of the
  default namespace.
  
  Revision  Changes    Path
  1.4       +15 -1     cocoon-2.1/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractTextSerializer.java	19 Mar 2003 17:37:12 -0000	1.3
  +++ AbstractTextSerializer.java	11 Apr 2003 08:38:26 -0000	1.4
  @@ -531,6 +531,20 @@
                 this.prefixToUriMap.remove(prefix);
               }
   
  +            if (hasMappings) {
  +                // most of the time, start/endPrefixMapping calls have an element event between them,
  +                // which will clear the hasMapping flag and so this code will only be executed in the
  +                // rather rare occasion when there are start/endPrefixMapping calls with no element
  +                // event in between. If we wouldn't remove the items from the prefixList and uriList here,
  +                // the namespace would be incorrectly declared on the next element following the
  +                // endPrefixMapping call.
  +                int pos = prefixList.lastIndexOf(prefix);
  +                if (pos != -1) {
  +                    prefixList.remove(pos);
  +                    uriList.remove(pos);
  +                }
  +            }
  +
               super.endPrefixMapping(prefix);
           }