cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgaw...@apache.org
Subject svn commit: r169632 [3/4] - in /cocoon/blocks/unsupported/template/trunk: WEB-INF/xconf/ conf/ java/org/apache/cocoon/generation/ java/org/apache/cocoon/template/ java/org/apache/cocoon/template/environment/ java/org/apache/cocoon/template/expression/ java/org/apache/cocoon/template/instruction/ java/org/apache/cocoon/template/jxtg/ java/org/apache/cocoon/template/script/ java/org/apache/cocoon/template/script/event/ java/org/apache/cocoon/transformation/ test/org/apache/cocoon/template/jxtg/
Date Wed, 11 May 2005 12:08:37 GMT
Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java Wed May 11 05:08:34 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.instruction;
+
+import java.util.Stack;
+
+import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.script.event.StartElement;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @version SVN $Id$
+ */
+public class When extends Instruction {
+    private final JXTExpression test;
+    private When nextChoice;
+
+    public When(StartElement raw, Attributes attrs, Stack stack) 
+        throws SAXException {
+
+        super(raw);
+
+        Locator locator = getLocation();
+
+        if (stack.size() == 0 || !(stack.peek() instanceof Choose)) {
+            throw new SAXParseException("<when> must be within <choose>", locator, null);
+        }
+        String test = attrs.getValue("test");
+        if (test != null) {
+            this.test = JXTExpression.compileExpr(test, "when: \"test\": ", locator);
+            // Why is test lenient?
+            this.test.setLenient(Boolean.TRUE);
+            
+            Choose startChoose = (Choose) stack.peek();
+            if (startChoose.getFirstChoice() != null) {
+                When w = startChoose.getFirstChoice();
+                while (w.getNextChoice() != null) {
+                    w = w.getNextChoice();
+                }
+                w.setNextChoice(this);
+            } else {
+                startChoose.setFirstChoice(this);
+            }
+        } else {
+            throw new SAXParseException("when: \"test\" is required", locator, null);
+        }
+    }
+
+    public JXTExpression getTest() {
+        return test;
+    }
+
+    public void setNextChoice(When nextChoice) {
+        this.nextChoice = nextChoice;
+    }
+
+    public When getNextChoice() {
+        return nextChoice;
+    }
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/instruction/When.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java Wed May 11 05:08:34 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.template.instruction.Instruction;
+import org.apache.cocoon.template.script.event.StartElement;
+import org.apache.commons.lang.ClassUtils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @version SVN $Id: DefaultInstructionFactory.java 169615 2005-05-11 09:57:41Z
+ *          lgawron $
+ */
+public class DefaultInstructionFactory extends AbstractLogEnabled implements ThreadSafe, Configurable,
+        InstructionFactory {
+    private Map instructions;
+    final static Class[] INSTRUCTION_CONSTRUCTOR_PARAMS = new Class[] { StartElement.class, Attributes.class,
+            Stack.class };
+
+    public void configure(Configuration conf) throws ConfigurationException {
+        this.instructions = new HashMap();
+        Configuration[] instructionSets = conf.getChildren("instructions");
+        for (int i = 0; i < instructionSets.length; i++) {
+            Configuration instructionSet = instructionSets[i];
+            String namespace = instructionSet.getAttribute("targetNamespace", "");
+            
+            Configuration[] instr = instructionSet.getChildren("instruction");
+            for (int j = 0; j < instr.length; j++) {
+                Configuration currentInstruction = instr[j];
+                String name = currentInstruction.getAttribute("name");
+                if (name == null)
+                    throw new ConfigurationException("@name for instruction required");
+                
+                String className = currentInstruction.getAttribute("class");
+                if (className == null)
+                    throw new ConfigurationException("@class for instruction required");
+                
+                registerInstruction(name, namespace, className);
+            }
+        }
+    }
+
+    private void registerInstruction(String instructionName, String targetNamespace, String className)
+            throws ConfigurationException {
+        Class clazz;
+        try {
+            clazz = Class.forName(className);
+            if (!ClassUtils.isAssignable(clazz, Instruction.class))
+                throw new ConfigurationException("Class '" + className + "' is not assignable to "
+                        + "o.a.c.template.jxtg.script.event.StartInstruction ");
+            Constructor constructor = clazz.getConstructor(INSTRUCTION_CONSTRUCTOR_PARAMS);
+
+            String instructionKey = instructionKey(instructionName, targetNamespace);
+            this.instructions.put(instructionKey, constructor);
+        } catch (ClassNotFoundException e) {
+            throw new ConfigurationException("unable to register instruction", e);
+        } catch (SecurityException e) {
+            throw new ConfigurationException("unable to register instruction", e);
+        } catch (NoSuchMethodException e) {
+            throw new ConfigurationException("unable to register instruction", e);
+        }
+    }
+
+    private String instructionKey(String instructionName, String targetNamespace) {
+        return "{" + targetNamespace + "}" + instructionName;
+    }
+
+    private String instructionKey(StartElement element) {
+        return instructionKey(element.getLocalName(), element.getNamespaceURI());
+    }
+
+    public boolean isInstruction(StartElement element) {
+        String instructionKey = instructionKey(element);
+        return this.instructions.containsKey(instructionKey);
+    }
+
+    public Instruction createInstruction(StartElement startElement, Attributes attrs, Stack stack)
+            throws SAXException {
+        String instructionKey = instructionKey(startElement);
+        Constructor constructor = (Constructor) this.instructions.get(instructionKey);
+        if (constructor == null)
+            throw new SAXParseException("unrecognized instruction: " + instructionKey, startElement.getLocation(), null);
+        Object[] arguments = new Object[] { startElement, attrs, stack };
+        try {
+            return (Instruction) constructor.newInstance(arguments);
+        } catch (Exception e) {
+            throw new SAXParseException("error creating instruction: " + instructionKey, startElement.getLocation(), e);
+        }
+    }
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java Wed May 11 05:08:34 2005
@@ -0,0 +1,130 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.template.script.event.StartDocument;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.store.Store;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @version SVN $Id$
+ */
+public class DefaultScriptManager extends AbstractLogEnabled implements
+        Serviceable, Disposable, ScriptManager {
+    private ServiceManager manager;
+    private final static String JX_STORE_PREFIX = "jxtg:";
+    private Store store;
+    private InstructionFactory instructionFactory;
+
+    public DefaultScriptManager() {
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
+        this.instructionFactory = (InstructionFactory) this.manager
+                .lookup(InstructionFactory.ROLE);
+    }
+
+    public void dispose() {
+        this.manager.release(this.store);
+        this.manager.release(this.instructionFactory);
+    }
+
+    private Store getStore() {
+        return store;
+    }
+
+    public StartDocument resolveTemplate(String uri) throws SAXParseException,
+            ProcessingException {
+        return resolveTemplate(uri, null);
+    }
+
+    public StartDocument resolveTemplate(String uri, Locator location)
+            throws SAXParseException, ProcessingException {
+        Source input = null;
+        StartDocument doc = null;
+        SourceResolver resolver = null;
+        try {
+            resolver = (SourceResolver) this.manager
+                    .lookup(SourceResolver.ROLE);
+            input = resolver.resolveURI(uri);
+            SourceValidity validity = null;
+
+            String storeUri = JX_STORE_PREFIX + input.getURI();
+            doc = (StartDocument) getStore().get(storeUri);
+
+            // TODO: why was this previously in synchronized( getCache() )?
+            if (doc != null) {
+                boolean recompile = false;
+                if (doc.getSourceValidity() == null) {
+                    recompile = true;
+                } else {
+                    int valid = doc.getSourceValidity().isValid();
+                    if (valid == SourceValidity.UNKNOWN) {
+                        validity = input.getValidity();
+                        valid = doc.getSourceValidity().isValid(validity);
+                    }
+                    if (valid != SourceValidity.VALID) {
+                        recompile = true;
+                    }
+                }
+                if (recompile) {
+                    doc = null; // recompile
+                }
+            }
+
+            if (doc == null) {
+                Parser parser = new Parser();
+                parser.setInstructionFactory(instructionFactory);
+                // call getValidity before using the stream is faster if
+                // the source is a SitemapSource
+                if (validity == null) {
+                    validity = input.getValidity();
+                }
+                SourceUtil.parse(manager, input, parser);
+                doc = parser.getStartEvent();
+                doc.setUri(input.getURI());
+                doc.setSourceValidity(validity);
+
+                getStore().store(storeUri, doc);
+            }
+        } catch (SourceException se) {
+            throw SourceUtil.handle("Error during resolving of '" + uri + "'.",
+                    se);
+        } catch (Exception exc) {
+            throw new SAXParseException(exc.getMessage(), location, exc);
+        } finally {
+            if (input != null)
+                resolver.release(input);
+            if (resolver != null)
+                manager.release(resolver);
+        }
+        return doc;
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java Wed May 11 05:08:34 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import java.util.Stack;
+
+import org.apache.cocoon.template.instruction.Instruction;
+import org.apache.cocoon.template.script.event.StartElement;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public interface InstructionFactory {
+    public final static String ROLE = InstructionFactory.class.getName();
+
+    public abstract boolean isInstruction(StartElement element);
+
+    public abstract Instruction createInstruction(
+            StartElement startElement, Attributes attrs, Stack stack)
+            throws SAXException;
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/InstructionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java Wed May 11 05:08:34 2005
@@ -0,0 +1,131 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.JXTemplateGenerator;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.environment.LocatorFacade;
+import org.apache.cocoon.template.instruction.Call;
+import org.apache.cocoon.template.instruction.Define;
+import org.apache.cocoon.template.instruction.Instruction;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.template.script.event.Event;
+import org.apache.cocoon.template.script.event.StartElement;
+import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.cocoon.xml.dom.DOMBuilder;
+import org.apache.cocoon.xml.dom.DOMStreamer;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.excalibur.xml.sax.XMLizable;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * @version SVN $Id$
+ */
+public class Invoker {
+    private static final Attributes EMPTY_ATTRS = new AttributesImpl();
+
+    public static void execute(final XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+
+        Event ev = startEvent;
+        LocatorFacade loc = new LocatorFacade(ev.getLocation());
+        consumer.setDocumentLocator(loc);
+        while (ev != endEvent) {
+            loc.setDocumentLocator(ev.getLocation());
+
+            // ContentHandler methods
+            if (ev instanceof StartElement) {
+                StartElement startElement = (StartElement) ev;
+                Define def = (Define) executionContext
+                        .getDefinitions().get(startElement.getQname());
+                if (def == null) {
+                    ev = ev.execute(consumer, expressionContext,
+                            executionContext, macroContext, startEvent, endEvent);
+                    continue;
+                }
+
+                Call call = new Call( def, startElement );
+                ev = call.execute(consumer, expressionContext,
+                        executionContext, macroContext, startEvent, endEvent);
+            } else
+                ev = ev.execute(consumer, expressionContext, executionContext,
+                        macroContext, startEvent, endEvent);
+        }
+    }
+
+    public static void executeNode(final XMLConsumer consumer, Object val)
+            throws SAXException {
+
+        if (val instanceof Node) {
+            executeDOM(consumer, (Node) val);
+        } else if (val instanceof NodeList) {
+            NodeList nodeList = (NodeList) val;
+            int len = nodeList.getLength();
+            for (int i = 0; i < len; i++) {
+                Node n = nodeList.item(i);
+                executeDOM(consumer, n);
+            }
+        } else if (val instanceof Node[]) {
+            Node[] nodeList = (Node[]) val;
+            int len = nodeList.length;
+            for (int i = 0; i < len; i++) {
+                Node n = nodeList[i];
+                executeDOM(consumer, n);
+            }
+        } else if (val instanceof XMLizable) {
+            ((XMLizable) val).toSAX(new IncludeXMLConsumer(consumer));
+        } else {
+            char[] ch = val == null ? ArrayUtils.EMPTY_CHAR_ARRAY : val
+                    .toString().toCharArray();
+            consumer.characters(ch, 0, ch.length);
+        }
+    }
+
+    /**
+     * dump a DOM document, using an IncludeXMLConsumer to filter out start/end document events
+     */
+    public static void executeDOM(final XMLConsumer consumer, Node node)
+            throws SAXException {
+        IncludeXMLConsumer includer = new IncludeXMLConsumer(consumer);
+        DOMStreamer streamer = new DOMStreamer(includer);
+        streamer.stream(node);
+    }
+
+    public static NodeList toDOMNodeList(String elementName,
+            Instruction si, ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext)
+            throws SAXException {
+        DOMBuilder builder = new DOMBuilder();
+        builder.startDocument();
+        builder.startElement(JXTemplateGenerator.NS, elementName, elementName,
+                EMPTY_ATTRS);
+        execute(builder, expressionContext, executionContext, macroContext, si
+                .getNext(), si.getEndInstruction());
+        builder.endElement(JXTemplateGenerator.NS, elementName, elementName);
+        builder.endDocument();
+        Node node = builder.getDocument().getDocumentElement();
+        return node.getChildNodes();
+    }
+
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Invoker.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java Wed May 11 05:08:34 2005
@@ -0,0 +1,222 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import java.util.Stack;
+
+import org.apache.cocoon.template.JXTemplateGenerator;
+import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.instruction.Instruction;
+import org.apache.cocoon.template.script.event.*;
+import org.apache.commons.lang.StringUtils;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.LocatorImpl;
+
+/**
+ * @version SVN $Id$
+ */
+public class Parser implements ContentHandler, LexicalHandler {
+    StartDocument startEvent;
+    Event lastEvent;
+    Stack stack = new Stack();
+    Locator locator;
+    Locator charLocation;
+    StringBuffer charBuf;
+
+    public static final Locator NULL_LOCATOR = new LocatorImpl();
+    private InstructionFactory instructionFactory;
+
+    public Parser() {
+    }
+
+    public void setInstructionFactory(InstructionFactory factory) {
+        this.instructionFactory = factory;
+    }
+
+    public StartDocument getStartEvent() {
+        return this.startEvent;
+    }
+
+    protected void recycle() {
+        startEvent = null;
+        lastEvent = null;
+        stack.clear();
+        locator = null;
+        charLocation = null;
+        charBuf = null;
+    }
+
+    private void addEvent(Event ev) throws SAXException {
+        if (ev != null) {
+            if (lastEvent == null) {
+                lastEvent = startEvent = new StartDocument(locator);
+            } else {
+                flushChars();
+            }
+            lastEvent.setNext(ev);
+            lastEvent = ev;
+        } else {
+            throw new NullPointerException("null event");
+        }
+    }
+
+    void flushChars() throws SAXException {
+        if (charBuf != null) {
+            char[] chars = new char[charBuf.length()];
+            charBuf.getChars(0, charBuf.length(), chars, 0);
+            Characters ev = new Characters(charLocation, chars, 0, chars.length);
+            lastEvent.setNext(ev);
+            lastEvent = ev;
+            charLocation = null;
+            charBuf = null;
+        }
+    }
+
+    public void characters(char[] ch, int start, int length)
+            throws SAXException {
+        if (charBuf == null) {
+            charBuf = new StringBuffer(length);
+            charLocation = locator != null ? new LocatorImpl(locator)
+                    : NULL_LOCATOR;
+        }
+        charBuf.append(ch, start, length);
+    }
+
+    public void endDocument() throws SAXException {
+        StartDocument startDoc = (StartDocument) stack.pop();
+        EndDocument endDoc = new EndDocument(locator);
+        startDoc.setEndDocument(endDoc);
+        addEvent(endDoc);
+    }
+
+    public void endElement(String namespaceURI, String localName, String raw)
+            throws SAXException {
+        Event start = (Event) stack.pop();
+        Event newEvent = null;
+        if (start instanceof Instruction) {
+            Instruction startInstruction = (Instruction) start;
+            EndInstruction endInstruction = new EndInstruction(locator,
+                    startInstruction);
+            newEvent = endInstruction;
+            addEvent(newEvent);
+            startInstruction.endNotify();
+        } else {
+            StartElement startElement = (StartElement) start;
+            newEvent = new EndElement(locator, startElement);
+            startElement.setEndElement((EndElement) newEvent);
+            addEvent(newEvent);
+        }
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        EndPrefixMapping endPrefixMapping = new EndPrefixMapping(locator,
+                prefix);
+        addEvent(endPrefixMapping);
+    }
+
+    public void ignorableWhitespace(char[] ch, int start, int length)
+            throws SAXException {
+        Event ev = new IgnorableWhitespace(locator, ch, start, length);
+        addEvent(ev);
+    }
+
+    public void processingInstruction(String target, String data)
+            throws SAXException {
+        Event pi = new ProcessingInstruction(locator, target, data);
+        addEvent(pi);
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        this.locator = locator;
+    }
+
+    public void skippedEntity(String name) throws SAXException {
+        addEvent(new SkippedEntity(locator, name));
+    }
+
+    public void startDocument() {
+        startEvent = new StartDocument(locator);
+        lastEvent = startEvent;
+        stack.push(lastEvent);
+    }
+
+    public void startElement(String namespaceURI, String localName,
+            String qname, Attributes attrs) throws SAXException {
+        Event newEvent = null;
+        AttributesImpl elementAttributes = new AttributesImpl(attrs);
+        int attributeCount = elementAttributes.getLength();
+        for (int i = 0; i < attributeCount; i++) {
+            String attributeURI = elementAttributes.getURI(i);
+            if (StringUtils.equals(attributeURI, JXTemplateGenerator.NS)) {
+                // TODO: template properties should be allowed only on template
+                // root
+                getStartEvent().getTemplateProperties().put(
+                        elementAttributes.getLocalName(i),
+                        JXTExpression.compileExpr(
+                                elementAttributes.getValue(i), null, locator));
+                elementAttributes.removeAttribute(i--);
+            }
+        }
+        StartElement startElement = new StartElement(locator, namespaceURI,
+                localName, qname, elementAttributes);
+        if (instructionFactory.isInstruction(startElement))
+            newEvent = instructionFactory.createInstruction(startElement,
+                    attrs, stack);
+        else
+            newEvent = startElement;
+        stack.push(newEvent);
+        addEvent(newEvent);
+    }
+
+    public void startPrefixMapping(String prefix, String uri)
+            throws SAXException {
+        addEvent(new StartPrefixMapping(locator, prefix, uri));
+    }
+
+    public void comment(char ch[], int start, int length) throws SAXException {
+        // DO NOTHING
+    }
+
+    public void endCDATA() throws SAXException {
+        addEvent(new EndCDATA(locator));
+    }
+
+    public void endDTD() throws SAXException {
+        addEvent(new EndDTD(locator));
+    }
+
+    public void endEntity(String name) throws SAXException {
+        addEvent(new EndEntity(locator, name));
+    }
+
+    public void startCDATA() throws SAXException {
+        addEvent(new StartCDATA(locator));
+    }
+
+    public void startDTD(String name, String publicId, String systemId)
+            throws SAXException {
+        addEvent(new StartDTD(locator, name, publicId, systemId));
+    }
+
+    public void startEntity(String name) throws SAXException {
+        addEvent(new StartEntity(locator, name));
+    }
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/Parser.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java Wed May 11 05:08:34 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.template.script.event.StartDocument;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @version SVN $Id$
+ */
+public interface ScriptManager {
+    public final static String ROLE = ScriptManager.class.getName();
+
+    public abstract StartDocument resolveTemplate(String uri)
+            throws SAXParseException, ProcessingException;
+
+    public abstract StartDocument resolveTemplate(String uri, Locator location)
+            throws SAXParseException, ProcessingException;
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/ScriptManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java Wed May 11 05:08:34 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+/**
+ * @version SVN $Id$
+ */
+public abstract class AttributeEvent {
+    public AttributeEvent(String namespaceURI, String localName, String raw,
+            String type) {
+        this.namespaceURI = namespaceURI;
+        this.localName = localName;
+        this.raw = raw;
+        this.type = type;
+    }
+
+    final String namespaceURI;
+
+    public String getLocalName() {
+        return localName;
+    }
+
+    public String getNamespaceURI() {
+        return namespaceURI;
+    }
+
+    public String getRaw() {
+        return raw;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    final String localName;
+    final String raw;
+    final String type;
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/AttributeEvent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java Wed May 11 05:08:34 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import java.util.Iterator;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ErrorHolder;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.Literal;
+import org.apache.cocoon.template.expression.Subst;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.template.script.Invoker;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @version SVN $Id$
+ */
+public class Characters extends TextEvent {
+    public Characters(Locator location, char[] chars, int start, int length)
+            throws SAXException {
+        super(location, chars, start, length);
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        Iterator iter = getSubstitutions().iterator();
+        while (iter.hasNext()) {
+            Subst subst = (Subst) iter.next();
+            char[] chars;
+            if (subst instanceof Literal) {
+                chars = ((Literal) subst).getCharArray();
+                consumer.characters(chars, 0, chars.length);
+            } else {
+                JXTExpression expr = (JXTExpression) subst;
+                try {
+                    Object val = expr.getNode(expressionContext);
+                    Invoker.executeNode(consumer, val);
+                } catch (Exception e) {
+                    throw new SAXParseException(e.getMessage(), getLocation(), e);
+                } catch (Error err) {
+                    throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
+                }
+            }
+        }
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Characters.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java Wed May 11 05:08:34 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+/**
+ * @version SVN $Id$
+ */
+public class CopyAttribute extends AttributeEvent {
+    public CopyAttribute(String namespaceURI, String localName, String raw,
+            String type, String value) {
+        super(namespaceURI, localName, raw, type);
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    private final String value;
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/CopyAttribute.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java Wed May 11 05:08:34 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndCDATA extends Event {
+    public EndCDATA(Locator location) {
+        super(location);
+    }
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endCDATA();
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndCDATA.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java Wed May 11 05:08:34 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndDTD extends Event {
+    public EndDTD(Locator location) {
+        super(location);
+    }
+    
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endDTD();
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDTD.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java Wed May 11 05:08:34 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndDocument extends Event {
+    public EndDocument(Locator location) {
+        super(location);
+    }
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endDocument();
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndDocument.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java Wed May 11 05:08:34 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndElement extends Event {
+    public EndElement(Locator location, StartElement startElement) {
+        super(location);
+        this.startElement = startElement;
+    }
+
+    final StartElement startElement;
+
+    public StartElement getStartElement() {
+        return startElement;
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endElement(startElement.getNamespaceURI(), startElement
+                .getLocalName(), startElement.getRaw());
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndElement.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java Wed May 11 05:08:34 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndEntity extends Event {
+    public EndEntity(Locator location, String name) {
+        super(location);
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    private final String name;
+    
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endEntity( getName() );
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndEntity.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java Wed May 11 05:08:34 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.template.instruction.Instruction;
+import org.xml.sax.Locator;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndInstruction extends Event {
+    public EndInstruction(Locator locator, Instruction startInstruction) {
+        super(locator);
+        this.startInstruction = startInstruction;
+        startInstruction.setEndInstruction(this);
+    }
+
+    final Instruction startInstruction;
+
+    public Instruction getStartInstruction() {
+        return startInstruction;
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndInstruction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java Wed May 11 05:08:34 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class EndPrefixMapping extends Event {
+    public EndPrefixMapping(Locator location, String prefix) {
+        super(location);
+        this.prefix = prefix;
+    }
+
+    final String prefix;
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.endPrefixMapping(getPrefix());
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java Wed May 11 05:08:34 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.LocatorImpl;
+
+/**
+ * @version SVN $Id$
+ */
+public class Event {
+    protected final Locator location;
+    protected Event next; // in document order
+
+    public static final Locator NULL_LOCATOR = new LocatorImpl();
+
+    public Event(Locator locator) {
+        this.location = locator != null ? new LocatorImpl(locator) : NULL_LOCATOR;
+    }
+
+    public final Locator getLocation() {
+        return location;
+    }
+
+    public Event getNext() {
+        return next;
+    }
+
+    public void setNext(Event next) {
+        this.next = next;
+    }
+
+    public String locationString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append(location.getSystemId());
+        if (buf.length() > 0) {
+            buf.append(", ");
+        }
+        buf.append("Line " + location.getLineNumber());
+        int col = location.getColumnNumber();
+        if (col > 0) {
+            buf.append("." + col);
+        }
+        return buf.toString();
+    }
+
+    public Event execute(final XMLConsumer consumer,
+                         ExpressionContext expressionContext,
+                         ExecutionContext executionContext,
+                         MacroContext macroContext, Event startEvent, Event endEvent) 
+        throws SAXException {
+        return getNext();
+    }
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/Event.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java Wed May 11 05:08:34 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class IgnorableWhitespace extends TextEvent {
+    public IgnorableWhitespace(Locator location, char[] chars, int start,
+            int length) throws SAXException {
+        super(location, chars, start, length);
+    }
+
+    public Event execute(final XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+            characters(expressionContext, executionContext, this,
+                new CharHandler() {
+                    public void characters(char[] ch, int offset, int len)
+                            throws SAXException {
+                        consumer.ignorableWhitespace(ch, offset, len);
+                    }
+                });
+            return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/IgnorableWhitespace.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java Wed May 11 05:08:34 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class ProcessingInstruction extends Event {
+    public ProcessingInstruction(Locator location, String target, String data) {
+        super(location);
+        this.target = target;
+        this.data = data;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public String getTarget() {
+        return target;
+    }
+
+    private final String target;
+    private final String data;
+    
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.processingInstruction(getTarget(), getData());
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/ProcessingInstruction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java Wed May 11 05:08:34 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class SkippedEntity extends Event {
+    public SkippedEntity(Locator location, String name) {
+        super(location);
+        this.name = name;
+    }
+
+    final String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.skippedEntity(getName());
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/SkippedEntity.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java Wed May 11 05:08:34 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class StartCDATA extends Event {
+    public StartCDATA(Locator location) {
+        super(location);
+    }
+    
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.startCDATA();
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartCDATA.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java Wed May 11 05:08:34 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class StartDTD extends Event {
+    public StartDTD(Locator location, String name, String publicId,
+            String systemId) {
+        super(location);
+        this.name = name;
+        this.publicId = publicId;
+        this.systemId = systemId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getPublicId() {
+        return publicId;
+    }
+
+    public String getSystemId() {
+        return systemId;
+    }
+
+    private final String name;
+    private final String publicId;
+    private final String systemId;
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        consumer.startDTD(getName(), getPublicId(), getSystemId());
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDTD.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java Wed May 11 05:08:34 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.excalibur.source.SourceValidity;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class StartDocument extends Event {
+    public StartDocument(Locator location) {
+        super(location);
+        templateProperties = new HashMap();
+    }
+
+    private SourceValidity sourceValidity;
+    private String uri;
+    private EndDocument endDocument; // null if document fragment
+    private Map templateProperties;
+
+    public EndDocument getEndDocument() {
+        return endDocument;
+    }
+
+    public void setEndDocument(EndDocument endDoc) {
+        this.endDocument = endDoc;
+    }
+
+    public Map getTemplateProperties() {
+        return templateProperties;
+    }
+
+    public String getUri() {
+        return this.uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    /**
+     * @param sourceValidity
+     *            The compileTime to set.
+     */
+    public void setSourceValidity(SourceValidity sourceValidity) {
+        this.sourceValidity = sourceValidity;
+    }
+
+    /**
+     * @return Returns the compileTime.
+     */
+    public SourceValidity getSourceValidity() {
+        return sourceValidity;
+    }
+
+    /**
+     * @param validity
+     * @return
+     */
+    public Object getTemplateProperty(String name) {
+        return getTemplateProperties().get(name);
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        if (getEndDocument() != null)
+            consumer.startDocument();
+        return getNext();
+    }
+}
\ No newline at end of file

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartDocument.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java?rev=169632&view=auto
==============================================================================
--- cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java (added)
+++ cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java Wed May 11 05:08:34 2005
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.script.event;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.expression.Substitutions;
+import org.apache.cocoon.template.instruction.MacroContext;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * @version SVN $Id$
+ */
+public class StartElement extends Event {
+    public StartElement(Locator location, String namespaceURI,
+            String localName, String raw, Attributes attrs) throws SAXException {
+        super(location);
+        this.namespaceURI = namespaceURI;
+        this.localName = localName;
+        this.raw = raw;
+        this.qname = "{" + namespaceURI + "}" + localName;
+        int len = attrs.getLength();
+        for (int i = 0; i < len; i++) {
+            String uri = attrs.getURI(i);
+            String local = attrs.getLocalName(i);
+            String qname = attrs.getQName(i);
+            String type = attrs.getType(i);
+            String value = attrs.getValue(i);
+            Substitutions substitutions = new Substitutions(getLocation(),
+                    value);
+            if (substitutions.hasSubstitutions()) {
+                getAttributeEvents().add(
+                        new SubstituteAttribute(uri, local, qname, type,
+                                substitutions));
+            } else {
+                getAttributeEvents().add(
+                        new CopyAttribute(uri, local, qname, type, value));
+            }
+        }
+        this.attributes = new AttributesImpl(attrs);
+    }
+
+    final String namespaceURI;
+    final String localName;
+    final String raw;
+    private final String qname;
+    private final List attributeEvents = new LinkedList();
+    final Attributes attributes;
+    EndElement endElement;
+
+    public EndElement getEndElement() {
+        return endElement;
+    }
+
+    public String getLocalName() {
+        return localName;
+    }
+
+    public String getNamespaceURI() {
+        return namespaceURI;
+    }
+
+    public String getRaw() {
+        return raw;
+    }
+
+    public String getQname() {
+        return qname;
+    }
+
+    public List getAttributeEvents() {
+        return attributeEvents;
+    }
+
+    public void setEndElement(EndElement endElement) {
+        this.endElement = endElement;
+
+    }
+
+    public Event execute(XMLConsumer consumer,
+            ExpressionContext expressionContext,
+            ExecutionContext executionContext, MacroContext macroContext,
+            Event startEvent, Event endEvent) throws SAXException {
+        Iterator i = getAttributeEvents().iterator();
+        AttributesImpl attrs = new AttributesImpl();
+        while (i.hasNext()) {
+            AttributeEvent attrEvent = (AttributeEvent) i.next();
+            if (attrEvent instanceof CopyAttribute) {
+                CopyAttribute copy = (CopyAttribute) attrEvent;
+                attrs.addAttribute(copy.getNamespaceURI(), copy.getLocalName(),
+                        copy.getRaw(), copy.getType(), copy.getValue());
+            } else if (attrEvent instanceof SubstituteAttribute) {
+                SubstituteAttribute substEvent = (SubstituteAttribute) attrEvent;
+                String attributeValue = substEvent.getSubstitutions().toString(
+                        getLocation(), expressionContext);
+                attrs.addAttribute(attrEvent.getNamespaceURI(), attrEvent
+                        .getLocalName(), attrEvent.getRaw(), attrEvent
+                        .getType(), attributeValue);
+            }
+        }
+        consumer.startElement(getNamespaceURI(), getLocalName(), getRaw(),
+                attrs);
+        return getNext();
+    }
+}

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/unsupported/template/trunk/java/org/apache/cocoon/template/script/event/StartElement.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message