tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r747972 - /tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java
Date Wed, 25 Feb 2009 23:55:38 GMT
Author: rfeng
Date: Wed Feb 25 23:55:37 2009
New Revision: 747972

URL: http://svn.apache.org/viewvc?rev=747972&view=rev
Log:
Fix the push/pop out of sequence issue

Modified:
    tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java

Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java?rev=747972&r1=747971&r2=747972&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java
Wed Feb 25 23:55:37 2009
@@ -75,22 +75,25 @@
         this.characterEncodingScheme = super.getCharacterEncodingScheme();
     }
 
+    // A flag to indicate if the next() is called from nextTag()
+    private boolean withinNextTagMethod = false;
+   
     /*
      * Overriding the next() method to perform PUSH and POP operations 
      * for the NamespaceContext for the current element
      */
-
     @Override
     public int next() throws XMLStreamException {
-        // POP the context if the element ends
-        if (this.getEventType() == END_ELEMENT) {
+        // POP the namespaces if the reader leaves the end element
+        if (!withinNextTagMethod && this.getEventType() == END_ELEMENT) {
             popContext();
         }
 
-        //get the next event 
+        // get the next event 
         int nextEvent = super.next();
-        //PUSH the events info onto the Stack 
-        if (nextEvent == START_ELEMENT) {
+        
+        // PUSH the namespaces onto the stack as the reader enters the start element
+        if (!withinNextTagMethod && nextEvent == START_ELEMENT) {
             pushContext();
         }
         return nextEvent;
@@ -98,14 +101,20 @@
 
     @Override
     public int nextTag() throws XMLStreamException {
+        withinNextTagMethod = true;
+        // POP the namespaces out of the stack if the reader leaves the end element
+        if (this.getEventType() == END_ELEMENT) {
+            popContext();
+        }        
+        
+        // REVIEW: what if nextTag() calls next()?
         int event = super.nextTag();
         
+        // PUSH the namespaces onto the stack as the reader enters the start element
         if (event == START_ELEMENT) {
             pushContext();
         }
-        if (event == END_ELEMENT) {
-            popContext();
-        }
+        withinNextTagMethod = false;
         return event;
     }
 



Mime
View raw message