cziegeler 2003/02/28 07:16:42
Modified: src/java/org/apache/cocoon/transformation SourceWritingTransformer.java Log: Optimizing code Revision Changes Path 1.21 +6 -27 xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java Index: SourceWritingTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- SourceWritingTransformer.java 28 Feb 2003 15:12:43 -0000 1.20 +++ SourceWritingTransformer.java 28 Feb 2003 15:16:42 -0000 1.21 @@ -346,30 +346,11 @@ ", name=" + name + ", raw=" + raw + ", attr=" + attr); } // Element: insert - if (name.equals(INSERT_ELEMENT) - && this.state == STATE_OUTSIDE) { - this.state = STATE_INSERT; - this.parent_state = STATE_INSERT; - if (attr.getValue(CREATE_ATTRIBUTE) != null - && attr.getValue(CREATE_ATTRIBUTE).equals("false")) { - this.stack.push("false"); - } else { - this.stack.push("true"); - } - if (attr.getValue(OVERWRITE_ATTRIBUTE) != null - && attr.getValue(OVERWRITE_ATTRIBUTE).equals("false")) { - this.stack.push("false"); - } else { - this.stack.push("true"); - } - this.stack.push(attr.getValue(SERIALIZER_ATTRIBUTE)); - this.stack.push("INSERT"); + if (this.state == STATE_OUTSIDE + && (name.equals(INSERT_ELEMENT) || name.equals(WRITE_ELEMENT))) { - // Element: write - } else if (name.equals(WRITE_ELEMENT) - && this.state == STATE_OUTSIDE) { - this.state = STATE_WRITE; - this.parent_state = STATE_WRITE; + this.state = (name.equals(INSERT_ELEMENT) ? STATE_INSERT : STATE_WRITE); + this.parent_state = this.state; if (attr.getValue(CREATE_ATTRIBUTE) != null && attr.getValue(CREATE_ATTRIBUTE).equals("false")) { this.stack.push("false"); @@ -383,7 +364,7 @@ this.stack.push("true"); // default value } this.stack.push(attr.getValue(SERIALIZER_ATTRIBUTE)); - this.stack.push("WRITE"); + this.stack.push("END"); // Element: file } else if (name.equals(SOURCE_ELEMENT) @@ -446,8 +427,6 @@ if ((name.equals(INSERT_ELEMENT) && this.state == STATE_INSERT) || (name.equals(WRITE_ELEMENT) && this.state == STATE_WRITE)) { - final String endTag = (this.state == STATE_INSERT ? "INSERT" : "WRITE"); - // get the information from the stack DocumentFragment fragment = null; String tag; @@ -469,7 +448,7 @@ } else if (tag.equals("REINSERT") == true) { reinsert = (String)this.stack.pop(); } - } while ( !tag.equals(endTag) ); + } while ( !tag.equals("END") ); final String localSerializer = (String)this.stack.pop(); final boolean overwrite = this.stack.pop().equals("true");