1 7 8 package org.jdesktop.jdnc.markup.attr; 9 10 import org.jdesktop.swing.data.DefaultTableModelExt; 11 import org.jdesktop.swing.data.DOMAdapter; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import javax.xml.parsers.DocumentBuilder ; 17 import javax.xml.parsers.DocumentBuilderFactory ; 18 19 import net.openmarkup.ApplierException; 20 import net.openmarkup.AttributeApplier; 21 import net.openmarkup.Realizable; 22 23 import org.w3c.dom.Document ; 24 25 import org.jdesktop.jdnc.markup.Attributes; 26 import org.jdesktop.jdnc.markup.ElementTypes; 27 import org.jdesktop.jdnc.markup.Namespace; 28 29 32 public class HierarchicalDataAttributes { 33 public static final AttributeApplier sourceApplier = new AttributeApplier() { 34 public void apply(Realizable target, String namespaceURI, 35 String attributeName, String attributeValue) throws ApplierException { 36 try { 37 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 38 dbf.setNamespaceAware(true); 39 dbf.setIgnoringComments(true); 40 URL url = target.getResolvedURL(attributeValue); 41 Document dom = dbf.newDocumentBuilder().parse(url.toExternalForm()); 42 ((DOMAdapter) target.getObject()).bind(dom); 43 } 44 catch (Exception ex) { 45 throw new ApplierException("Couldn't set data source " + 46 attributeName + "=" + attributeValue, ex); 47 } 48 } 49 }; 50 } 51 | Popular Tags |