From: Bill H. <Bil...@Ac...> - 2003-09-24 00:22:46
|
Thanks David that helps a lot. It was the document.toString() that I didn't understand, as I've found examples of document.get("attr_name") in the examples. Thanks also for the test script, I was just about to have to write one. - Now I'll just modify yours. regards, Bill On 23 Sep 2003 at 16:34, David Glick wrote: > Hi Bill, > > There is no default attribute for the document. You have to put it > into a new attribute. For example: > > ###### > # Save the document into an attribute > ###### > initialize.stageType=Scripting > initialize.nextStage=<whatever> > initialize.failOnError=true > initialize.language=javascript > initialize.script=\ > document.put("main_document", document.toString()); > > Then, you can replace the current document by simply over-writing it > with the contents of another attribute (or any other data from a > script or file or whatever): > > ###### > # Extract the response from the attribute and replace the document > # with the response > ###### > extract-response.stageType=Scripting > extract-response.nextStage=branch-on-error > extract-response.failOnError=true > extract-response.tracked=true > extract-response.language=javascript > extract-response.script=\ > document.setBytes(document.get("desired_attribute").getBytes());\ > document.setMimeType("text/xml"); > > After you're done processing, you can then use the above to place the > original document back into the main document. > > I have a test stage I use to dump all the attributes of a document. > You're welcome to use it: > > ----------------------------------- > ###### > # List all attributes on this document > ###### > get-attributes.stageType=Scripting > get-attributes.nextStage=console-writer > get-attributes.language=javascript > get-attributes.script=\ > var keyset = document.getAttributes().keySet();\ > var keyiter = keyset.iterator();\ > var bufr = new java.lang.StringBuffer();\ > bufr.append("<attributes>\\n");\ > while(keyiter.hasNext()) {\ > var key = keyiter.next();\ > var cls = document.get(key);\ > bufr.append(key + "=" + cls + "\\n");\ > }\ > bufr.append("</attributes>\\n");\ > document.setBytes(bufr.toString().getBytes());\ > document.setMimeType("text/xml"); > > ###### > # This stage is useful for testing; it writes the current document to > # stdout. Unfortunately, it only works under Unix. Sorry... :-( > ###### > console-writer.stageType=FileWriter > console-writer.nextStage=null > console-writer.outputFile=/dev/tty > ----------------------------------- > > Hope this helps, > > David > > On Tuesday 23 September 2003 2:50 pm, Bill Harrelson wrote: > > This is very similar to what I need to do as well. What I don't > > understand is how to do these described steps, as I can't find any > > documentation on what variables are available to the script. Is > > there an example somewhere? > > > > Thanks, > > > > Bill > > > > The steps I don't understand how to do are: > > > b) Place the original document into an attribute > > > > (what is the attribute for the document body? I understand how to > > assign a > > new attribute.) > > > > > c) Replace the current document with the report to be e-mailed. > > > > and > > (probably answered by the answer above??) > > > > > e) Move the original document from the attribute in which it is > > > stored back into the current document > > > > (converse of b I suppose).-- > > William B. Harrelson > > President > > Accordare > > 13A Medford Street, Arlington, MA 02474 > > t:781-646-2241 f:781-646-2242 > > Bil...@Ac... > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf > > _______________________________________________ > > Babeldoc-user mailing list > > Bab...@li... > > https://lists.sourceforge.net/lists/listinfo/babeldoc-user > > -- > David Glick > Transmit Consulting, Inc > 619-475-4052 > dg...@tr... > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Babeldoc-user mailing list > Bab...@li... > https://lists.sourceforge.net/lists/listinfo/babeldoc-user |