cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r232842 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java
Date Mon, 15 Aug 2005 18:14:06 GMT
Author: sylvain
Date: Mon Aug 15 11:14:02 2005
New Revision: 232842

URL: http://svn.apache.org/viewcvs?rev=232842&view=rev
Log:
Fix bug reported by Ugo when some xmlns declarations are on a jx:forEach

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java?rev=232842&r1=232841&r2=232842&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java Mon Aug
15 11:14:02 2005
@@ -59,7 +59,7 @@
     /** The last namespace declaration. */
     private Entry lastEntry;
 
-    private boolean filterDuplicate = true;
+    private boolean usesScopes = false;
 
     /**
      * Construct a new <code>NamespacesTable</code> instance.
@@ -93,7 +93,7 @@
         }
 
         if (dup != null) {
-            if (filterDuplicate && dup.uri.equals(uri)) {
+            if (usesScopes && dup.uri.equals(uri)) {
                 return dup;
             }
             dup.overriden = true;
@@ -115,6 +115,11 @@
      * @return The removed <code>Declaration</code> or <b>null</b>.
      */
     public Declaration removeDeclaration(String prefix) {
+        if (usesScopes) {
+            // Automatically handled in leaveScope
+            return null; // or throw and IllegalStateException if enterScope(handler) was
used?
+        }
+
         Entry current = this.lastEntry;
         Entry afterCurrent = null;
         while(current != null) {
@@ -159,6 +164,7 @@
      * @since 2.1.8
      */
     public void enterScope() {
+        this.usesScopes = true;
         this.lastEntry.closedScopes++;
     }
 
@@ -172,6 +178,7 @@
      * @since 2.1.8
      */
     public void enterScope(ContentHandler handler) throws SAXException {
+        this.usesScopes = true;
         Entry current = this.lastEntry;
         while (current != null && current.closedScopes == 0) {
             handler.startPrefixMapping(current.prefix, current.uri);
@@ -188,13 +195,13 @@
      * @param autoUndeclare if <code>true</code>, remove all mappings for the
current scope.
      * @since 2.1.8
      */
-    public void leaveScope(boolean autoUndeclare) {
+    public void leaveScope() {
         Entry current = this.lastEntry;
         if (current.closedScopes <= 0) {
             throw new IllegalStateException("Misbalanced enter and leaving of scope.");
         }
         current.closedScopes--;
-        if (autoUndeclare) {
+        if (usesScopes) {
             while (current != null && current.closedScopes == 0) {
                 Entry overrides = current.overrides;
                 if (overrides != null) {
@@ -221,6 +228,7 @@
         if (current.closedScopes <= 0) {
             throw new IllegalStateException("Misbalanced enter and leaving of scope.");
         }
+        current.closedScopes--;
         while (current != null && current.closedScopes == 0) {
             handler.endPrefixMapping(current.prefix);
             Entry overrides = current.overrides;
@@ -231,7 +239,6 @@
             current = current.previous;
         }
 
-        current.closedScopes--;
         this.lastEntry = current;
     }
 



Mime
View raw message