1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.binding.JXPathBindingManager.Assistant; 19 import org.apache.cocoon.forms.binding.library.Library; 20 import org.apache.cocoon.forms.binding.library.LibraryException; 21 import org.apache.cocoon.forms.util.DomHelper; 22 import org.w3c.dom.Element ; 23 24 29 public class ImportJXPathBindingBuilder extends JXPathBindingBuilderBase { 30 31 34 public JXPathBindingBase buildBinding(Element bindingElm, 35 Assistant assistant) throws BindingException { 36 37 Library lib = assistant.getContext().getLocalLibrary(); 38 39 String prefix = DomHelper.getAttribute(bindingElm, "prefix", null); 40 String uri = DomHelper.getAttribute(bindingElm, "uri", null); 41 42 if(prefix==null || uri==null) 43 throw new BindingException("Import needs to specify both @uri and @prefix! (at "+DomHelper.getLocation(bindingElm)+")"); 44 45 try { 46 lib.includeAs(prefix,uri); 47 } catch(LibraryException e) { 48 throw new BindingException("Could not import library !(at "+DomHelper.getLocation(bindingElm)+")",e); 49 } 50 51 return new ImportJXPathBinding(); 52 } 53 54 } 55 | Popular Tags |