diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-25 23:55:37 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-25 23:55:37 +0000 |
commit | 176f6afc0662e66b14e56e7569da47ff3efa843f (patch) | |
tree | 575d3069b583ba858fb32ab8e4d26d3eee1cbf1c /branches/sca-java-1.x/modules/contribution | |
parent | c36c817a5c93fad7dc9edb40c11dd499814433b8 (diff) |
Fix the push/pop out of sequence issue
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@747972 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution')
-rw-r--r-- | branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java index f2afe419a3..e1b218d9f4 100644 --- a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java +++ b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java @@ -75,22 +75,25 @@ public class TuscanyXMLStreamReader extends StreamReaderDelegate implements XMLS 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 @@ public class TuscanyXMLStreamReader extends StreamReaderDelegate implements XMLS @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; } |