1 16 package org.apache.cocoon.components.language.markup.xsp; 17 18 19 import org.apache.cocoon.components.modules.input.InputModuleHelper; 20 21 import org.xml.sax.ContentHandler ; 22 import org.xml.sax.SAXException ; 23 import org.xml.sax.helpers.AttributesImpl ; 24 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 37 public class XSPModuleHelper extends InputModuleHelper { 38 39 private static final String PREFIX = "input"; 40 private static final String URI = "http://apache.org/cocoon/xsp/input/1.0"; 41 42 53 public void getAttributeValues(Map objectModel, ContentHandler contentHandler, String module, String name ) 54 throws SAXException , RuntimeException { 55 56 AttributesImpl attr = new AttributesImpl (); 57 XSPObjectHelper.addAttribute(attr, "name", name); 58 59 XSPObjectHelper.start(URI, PREFIX, contentHandler, 60 "attribute-values", attr); 61 62 Object [] values = this.getAttributeValues(objectModel, module, name, null); 63 64 if (values != null) { 65 for (int i = 0; i < values.length; i++) { 66 XSPObjectHelper.elementData(URI, PREFIX, contentHandler, 67 "value", String.valueOf(values[i])); 68 } 69 } 70 71 XSPObjectHelper.end(URI, PREFIX, contentHandler, "attribute-values"); 72 } 73 74 83 public void getAttributeNames(Map objectModel, ContentHandler contentHandler, String module) 84 throws SAXException , RuntimeException { 85 86 XSPObjectHelper.start(URI, PREFIX, contentHandler, "attribute-names"); 87 88 Iterator iter = this.getAttributeNames(objectModel, module); 89 while (iter.hasNext()) { 90 String name = (String ) iter.next(); 91 XSPObjectHelper.elementData(URI, PREFIX, contentHandler, "name", name); 92 } 93 94 XSPObjectHelper.end(URI, PREFIX, contentHandler, "attribute-names"); 95 } 96 97 98 } 99 | Popular Tags |