1 5 6 package org.exoplatform.services.jcr.impl.util; 7 8 import org.w3c.dom.Document ; 9 10 import javax.xml.parsers.ParserConfigurationException ; 11 import javax.xml.parsers.DocumentBuilderFactory ; 12 import javax.xml.parsers.DocumentBuilder ; 13 import java.io.InputStream ; 14 import java.io.IOException ; 15 16 import org.xml.sax.SAXException ; 17 18 24 25 public class DOMBuilder { 26 27 public static Document createDocument() throws ParserConfigurationException { 28 DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); 29 dfactory.setNamespaceAware(true); 30 DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); 31 return docBuilder.newDocument(); 32 } 33 34 public static Document createDocument(InputStream is) 35 throws IOException , SAXException , ParserConfigurationException { 36 DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); 37 dfactory.setNamespaceAware(true); 38 DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); 39 return docBuilder.parse(is); 40 } 41 42 43 } 44 | Popular Tags |