/** 将W3C element转换成DOM4j element。 */ public static org.dom4j.Element convertElement(Element element) { Document doc; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new IllegalArgumentException("Failed to create dom4j document", e); } Element clonedElement = (Element) doc.importNode(element, true); doc.appendChild(clonedElement); DOMReader reader = new DOMReader(); org.dom4j.Document dom4jDoc = reader.read(doc); return dom4jDoc.getRootElement(); }
public Document read(org.w3c.dom.Document domDocument) { if (domDocument instanceof Document) { return (Document) domDocument; } Document document = createDocument(); clearNamespaceStack(); org.w3c.dom.NodeList nodeList = domDocument.getChildNodes(); for (int i = 0, size = nodeList.getLength(); i < size; i++) { readTree(nodeList.item(i), document); } return document; }
protected Document createDocument() { return getDocumentFactory().createDocument(); }
/** * Read mappings from a DOM <tt>Document</tt> * * @param doc a DOM document */ public Configuration addDocument(Document doc) throws MappingException { if ( log.isDebugEnabled() ) log.debug( "Mapping XML:\n" + doc ); try { add( xmlHelper.createDOMReader().read( doc ) ); } catch ( Exception e ) { log.error( "Could not configure datastore from XML document", e ); throw new MappingException( e ); } return this; }
/** * Create a dom4j DOMReader */ public DOMReader createDOMReader() { if (domReader==null) domReader = new DOMReader(); return domReader; }
readElement(node, current);
/** * Use the mappings and properties specified in the given XML document. * The format of the file is defined in * <tt>hibernate-configuration-2.2.dtd</tt>. * * @param document an XML document from which you wish to load the configuration * @return A configuration configured via the <tt>Document</tt> * @throws HibernateException if there is problem in accessing the file. */ public Configuration configure(Document document) throws HibernateException { log.info( "configuring from XML document" ); org.dom4j.Document doc; try { doc = xmlHelper.createDOMReader().read( document ); } catch ( Exception e ) { log.error( "problem parsing document", e ); throw new HibernateException( "problem parsing document", e ); } return doConfigure( doc ); }
/** * Create a dom4j DOMReader */ public DOMReader createDOMReader() { if (domReader==null) domReader = new DOMReader(); return domReader; }
readElement(node, current);
/** 将W3C element转换成DOM4j element。 */ public static org.dom4j.Element convertElement(Element element) { Document doc; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new IllegalArgumentException("Failed to create dom4j document", e); } Element clonedElement = (Element) doc.importNode(element, true); doc.appendChild(clonedElement); DOMReader reader = new DOMReader(); org.dom4j.Document dom4jDoc = reader.read(doc); return dom4jDoc.getRootElement(); }
/** * Use the mappings and properties specified in the given XML document. * The format of the file is defined in * <tt>hibernate-configuration-3.0.dtd</tt>. * * @param document an XML document from which you wish to load the configuration * @return A configuration configured via the <tt>Document</tt> * @throws HibernateException if there is problem in accessing the file. */ public Configuration configure(org.w3c.dom.Document document) throws HibernateException { LOG.configuringFromXmlDocument(); return doConfigure( xmlHelper.createDOMReader().read( document ) ); }
/** * Create a dom4j DOMReader */ public DOMReader createDOMReader() { if (domReader==null) domReader = new DOMReader(); return domReader; }
public Document read(org.w3c.dom.Document domDocument) { if (domDocument instanceof Document) { return (Document) domDocument; } Document document = createDocument(); clearNamespaceStack(); org.w3c.dom.NodeList nodeList = domDocument.getChildNodes(); for (int i = 0, size = nodeList.getLength(); i < size; i++) { readTree(nodeList.item(i), document); } return document; }
protected Namespace getNamespace(String prefix, String uri) { return getDocumentFactory().createNamespace(prefix, uri); }
readElement(node, current);
/** 将W3C element转换成DOM4j element。 */ public static org.dom4j.Element convertElement(Element element) { Document doc; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new IllegalArgumentException("Failed to create dom4j document", e); } Element clonedElement = (Element) doc.importNode(element, true); doc.appendChild(clonedElement); DOMReader reader = new DOMReader(); org.dom4j.Document dom4jDoc = reader.read(doc); return dom4jDoc.getRootElement(); }
/** * Use the mappings and properties specified in the given XML document. * The format of the file is defined in * <tt>hibernate-configuration-3.0.dtd</tt>. * * @param document an XML document from which you wish to load the configuration * @return A configuration configured via the <tt>Document</tt> * @throws HibernateException if there is problem in accessing the file. */ public Configuration configure(org.w3c.dom.Document document) throws HibernateException { LOG.configuringFromXmlDocument(); return doConfigure( xmlHelper.createDOMReader().read( document ) ); }