1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.util.DomHelper; 19 import org.w3c.dom.Element ; 20 21 40 public class ContextJXPathBindingBuilder extends JXPathBindingBuilderBase { 41 42 46 public JXPathBindingBase buildBinding(Element bindingElm, 47 JXPathBindingManager.Assistant assistant) throws BindingException { 48 49 try { 50 CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElm); 51 String xpath = DomHelper.getAttribute(bindingElm, "path", null); 52 String factory = DomHelper.getAttribute(bindingElm, "factory", null); 53 54 JXPathBindingBase[] childBindings = new JXPathBindingBase[0]; 55 56 ContextJXPathBinding otherBinding = (ContextJXPathBinding)assistant.getContext().getSuperBinding(); 58 if(otherBinding!=null) { 59 childBindings = otherBinding.getChildBindings(); 60 commonAtts = JXPathBindingBuilderBase.mergeCommonAttributes(otherBinding.getCommonAtts(),commonAtts); 61 62 if(xpath==null) 63 xpath = otherBinding.getXPath(); 64 if (factory == null) 65 factory = otherBinding.getFactoryClassName(); 66 67 } 68 69 childBindings = assistant.makeChildBindings(bindingElm,childBindings); 70 71 ContextJXPathBinding contextBinding = new ContextJXPathBinding(commonAtts, xpath, factory, childBindings); 72 return contextBinding; 73 } catch (BindingException e) { 74 throw e; 75 } catch (Exception e) { 76 throw new BindingException("Error building context binding defined at " + DomHelper.getLocation(bindingElm), e); 77 } 78 } 79 } 80 | Popular Tags |