1 16 package org.apache.cocoon.woody.binding; 17 18 import org.apache.cocoon.woody.util.DomHelper; 19 import org.apache.cocoon.woody.Constants; 20 import org.apache.cocoon.woody.datatype.convertor.Convertor; 21 import org.apache.cocoon.i18n.I18nUtils; 22 import org.w3c.dom.Element ; 23 24 import java.util.Locale ; 25 26 42 public class ValueJXPathBindingBuilder extends JXPathBindingBuilderBase { 43 44 48 public JXPathBindingBase buildBinding(Element bindingElm, JXPathBindingManager.Assistant assistant) throws BindingException { 49 50 try { 51 CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElm); 52 String xpath = DomHelper.getAttribute(bindingElm, "path"); 53 String widgetId = DomHelper.getAttribute(bindingElm, "id"); 54 55 Element updateWrapElement = 56 DomHelper.getChildElement(bindingElm, BindingManager.NAMESPACE, "on-update"); 57 JXPathBindingBase[] updateBindings = assistant.makeChildBindings(updateWrapElement); 58 59 Convertor convertor = null; 60 Locale convertorLocale = Locale.US; 61 Element convertorEl = DomHelper.getChildElement(bindingElm, Constants.WD_NS, "convertor"); 62 if (convertorEl != null) { 63 String datatype = DomHelper.getAttribute(convertorEl, "datatype"); 64 String localeStr = convertorEl.getAttribute("datatype"); 65 if (!localeStr.equals("")) { 66 convertorLocale = I18nUtils.parseLocale(localeStr); 67 } 68 69 convertor = assistant.getDatatypeManager().createConvertor(datatype, convertorEl); 70 } 71 72 ValueJXPathBinding fieldBinding = 73 new ValueJXPathBinding(commonAtts, 74 widgetId, xpath, updateBindings, convertor, convertorLocale); 75 76 return fieldBinding; 77 } catch (BindingException e) { 78 throw e; 79 } catch (Exception e) { 80 throw new BindingException("Error building binding defined at " + DomHelper.getLocation(bindingElm), e); 81 } 82 } 83 } 84 | Popular Tags |