cziegeler 2003/02/28 07:12:44
Modified: src/java/org/apache/cocoon/transformation SourceWritingTransformer.java Log: Optimizing code Revision Changes Path 1.20 +13 -43 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SourceWritingTransformer.java 28 Feb 2003 14:07:17 -0000 1.19 +++ SourceWritingTransformer.java 28 Feb 2003 15:12:43 -0000 1.20 @@ -443,21 +443,25 @@ ", name=" + name + ", raw=" + raw); } - if (name.equals(INSERT_ELEMENT) == true && this.state == STATE_INSERT) { + 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 - String tag; - String fileName = null; DocumentFragment fragment = null; - String path = null; - String replacePath = null; - String reinsert = null; + String tag; + String sourceName = null; + String path = (this.state == STATE_INSERT ? null : "/"); + // source:write's path can be empty + String replacePath = null; + String reinsert = null; do { tag = (String)this.stack.pop(); if (tag.equals("PATH") == true) { path = (String)this.stack.pop(); } else if (tag.equals("FILE") == true) { - fileName = (String)this.stack.pop(); + sourceName = (String)this.stack.pop(); } else if (tag.equals("FRAGMENT") == true) { fragment = (DocumentFragment)this.stack.pop(); } else if (tag.equals("REPLACE") == true) { @@ -465,47 +469,13 @@ } else if (tag.equals("REINSERT") == true) { reinsert = (String)this.stack.pop(); } - } while (tag.equals("INSERT") == false); - final String localSerializer = (String)this.stack.pop(); - final boolean overwrite = this.stack.pop().equals("true"); - final boolean create = this.stack.pop().equals("true"); + } while ( !tag.equals(endTag) ); - this.insertFragment(fileName, - path, - fragment, - replacePath, - create, - overwrite, - reinsert, - localSerializer, - name); - - this.state = STATE_OUTSIDE; - - } else if (name.equals(WRITE_ELEMENT) == true && this.state == STATE_WRITE) { - - // get the information from the stack - String tag; - String fileName = null; - DocumentFragment fragment = null; - String path = "/"; // source:write's path can be empty - String replacePath = null; - String reinsert = null; - do { - tag = (String)this.stack.pop(); - if (tag.equals("PATH") == true) { - path = (String)this.stack.pop(); - } else if (tag.equals("FILE") == true) { - fileName = (String)this.stack.pop(); - } else if (tag.equals("FRAGMENT") == true) { - fragment = (DocumentFragment)this.stack.pop(); - } - } while (tag.equals("WRITE") == false); final String localSerializer = (String)this.stack.pop(); final boolean overwrite = this.stack.pop().equals("true"); final boolean create = this.stack.pop().equals("true"); - this.insertFragment(fileName, + this.insertFragment(sourceName, path, fragment, replacePath,