1 16 package org.apache.cocoon.woody.generation; 17 18 import java.io.IOException ; 19 import java.util.Locale ; 20 import java.util.Map ; 21 22 import org.apache.avalon.framework.parameters.Parameters; 23 import org.apache.cocoon.ProcessingException; 24 import org.apache.cocoon.environment.SourceResolver; 25 import org.apache.cocoon.generation.AbstractGenerator; 26 import org.apache.cocoon.woody.Constants; 27 import org.apache.cocoon.woody.formmodel.Form; 28 import org.apache.cocoon.woody.transformation.WoodyPipelineConfig; 29 import org.xml.sax.Attributes ; 30 import org.xml.sax.SAXException ; 31 32 48 public class WoodyGenerator extends AbstractGenerator { 49 50 protected WoodyPipelineConfig config; 51 private static final String FORM_GENERATED_EL = "form-generated"; 52 53 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 54 throws ProcessingException, SAXException , IOException { 55 super.setup(resolver, objectModel, src, par); 56 57 this.config = WoodyPipelineConfig.createConfig(objectModel, parameters); 58 } 59 60 public void recycle() { 61 super.recycle(); 62 this.config = null; 63 } 64 65 public void generate() throws IOException , SAXException , ProcessingException { 66 contentHandler.startDocument(); 67 contentHandler.startPrefixMapping(Constants.WI_PREFIX, Constants.WI_NS); 68 Attributes formAtts = this.config.getFormAttributes(); 69 70 contentHandler.startElement(Constants.WI_NS, FORM_GENERATED_EL, Constants.WI_PREFIX_COLON +FORM_GENERATED_EL, formAtts); 71 Form form = config.findForm(); 72 form.generateSaxFragment(contentHandler, Locale.US); 73 contentHandler.endElement(Constants.WI_NS, FORM_GENERATED_EL, Constants.WI_PREFIX_COLON +FORM_GENERATED_EL); 74 75 contentHandler.endPrefixMapping(Constants.WI_PREFIX); 76 contentHandler.endDocument(); 77 } 78 } 79 | Popular Tags |