CODEFETCH™
            Examples
Searched for 1 expression(s): DocumentBuilderFactory  
Java API
javax.xml.parsers.DocumentBuilderFactory search codefetch
Defines a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents.
Source code below from:
Professional Java User Interfaces
By Mauro Marinilli
Published 26 May, 2006
Average rating

      Powells     Alibris

PJUI/com/marinilli/b1/c8/cakes/test/delivery/content/DeliveryPanelAcceptTest.java (71 lines)
24      
25         public static final String DOCUMENT_FACTORY = 
26              "javax.xml.parsers.DocumentBuilderFactory";
27  
28         public DeliveryPanelAcceptTest() throws Exception { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48 if (System.getProperty(DOCUMENT_FACTORY) == null) { 49 System.setProperty(DOCUMENT_FACTORY, 50 "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); 51 } 52 Test t = (Test) DeliveryPanelAcceptTest.suite();
Source code below from:
Java Enterprise in a Nutshell (In a Nutshell)
By Jim Farley, William Crawford, Prakash Malani, John Norman, and Justin Gehtland
Published 22 November, 2005
Average rating

      Powells     Alibris

ch07-XML/src/java/com/oreilly/jent/xml/DOMOrderHandler.java (49 lines)
26  
27 import javax.xml.parsers.DocumentBuilder; 
28 import javax.xml.parsers.DocumentBuilderFactory;
29  
30 public class DOMOrderHandler { 
31    
32   public static void main(String[] args) { 
33     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
34     dbf.setValidating(true); //request a validating builder 
35     dbf.setNamespaceAware(true); 

ch07-XML/src/java/com/oreilly/jent/xml/DocumentCondenser.java (134 lines)
26  
27 import javax.xml.parsers.DocumentBuilder; 
28 import javax.xml.parsers.DocumentBuilderFactory;
29 import javax.xml.parsers.ParserConfigurationException; 
30 import javax.xml.transform.Transformer; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 public static void main(String[] args) throws Exception { 41 42 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance( ); 43 44 // For HTML, we don't want to validate without a DTD

ch07-XML/src/java/com/oreilly/jent/xml/TreeBuilder.java (84 lines)
26  
27 import javax.xml.parsers.DocumentBuilder; 
28 import javax.xml.parsers.DocumentBuilderFactory;
29 import javax.xml.parsers.ParserConfigurationException; 
30 import javax.xml.transform.Transformer; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 42 public static void main(String[] args) { 43 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 44 dbf.setValidating(false); 45

ch12-WebServices/src/java/com/oreilly/jent/people/util/ConfigSet.java (129 lines)
30  
31 import javax.xml.parsers.DocumentBuilder; 
32 import javax.xml.parsers.DocumentBuilderFactory;
33 import javax.xml.parsers.ParserConfigurationException; 
34  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 try { 60 DocumentBuilder docBuilder = 61 DocumentBuilderFactory.newInstance().newDocumentBuilder(); 62 mXMLConfig = docBuilder.parse(xmlStr); 63 }

ch12-WebServices/src/java/com/oreilly/jent/people/xml/XMLPersonDAO.java (190 lines)
34  
35 import javax.xml.parsers.DocumentBuilder; 
36 import javax.xml.parsers.DocumentBuilderFactory;
37 import javax.xml.parsers.FactoryConfigurationError; 
38 import javax.xml.parsers.ParserConfigurationException; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77 // Try to parse the XML file referenced by the xml-file element 78 String xmlFileName = config.getParameter("dao.parameters.xml-file"); 79 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 80 DocumentBuilder builder = factory.newDocumentBuilder(); 81 File xmlFile = new File(xmlFileName);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
161 Node pn = pNodes.item(i); 162 Document d = 163 DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); 164 Node pnc = d.importNode(pn, true); 165 d.appendChild(pnc);
Source code below from:
JDBC Recipes: A Problem-Solution Approach (Problem-Solution Approach)
By Mahmoud Parsian
Published 15 September, 2005
Average rating

      Powells     Alibris

jcb_package/src/jcb/util/DocumentManager.java (2134 lines)
10  
11 import javax.xml.parsers.DocumentBuilder; 
12 import javax.xml.parsers.DocumentBuilderFactory;
13  
14 import org.apache.xml.serialize.OutputFormat; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33 public class DocumentManager { 34 35 static DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = null; 36 37 static { 38 try { 39 DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); 40 DOCUMENT_BUILDER_FACTORY.setValidating(false); 41 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
209 Document doc = null; 210 try { 211 //DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 212 //factory.setValidating(false); 213 DocumentBuilder builder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();

jcb_package/src/jcb/util/SimpleXML.java (1263 lines)
41 public class SimpleXML { 
42  
43     static DocumentBuilderFactory _dbf = null;
44     static boolean _ignoreWhitespace = false; 
45     static boolean _ignoreComments = false; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 String xmlFilename = ""; 57 58 synchronized static DocumentBuilderFactory getDocumentBuilder() { 59 if (_dbf == null) { 60 try { 61 _dbf = DocumentBuilderFactory.newInstance(); 62 _dbf.setValidating(_validation); 63 } 64 catch (Exception e){ 65 System.out.println("DocumentBuilderFactory:" + e.toString()); 66 } 67 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1181 Document doc = null; 1182 try { 1183 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 1184 DocumentBuilder builder = factory.newDocumentBuilder(); 1185 InputSource is = new InputSource(new StringReader(s));

jcb_package/src/jcb/util/XMLValidator.java (333 lines)
12 import javax.xml.parsers.ParserConfigurationException; 
13 import javax.xml.parsers.SAXParser; 
14 import javax.xml.parsers.DocumentBuilderFactory;
15  
16  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 saxParser.parse( new File(xmlFilename), this /*handler*/); 41 42 // Step 1: create a DocumentBuilderFactory and configure it 43 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 44 45 doc = dbf.newDocumentBuilder().parse(new File(xmlFilename));
Source code below from:
Learning Java
By Pat Niemeyer and Jonathan Knudsen
Published 20 May, 2005
Average rating

      Powells     Alibris

examples/ch24/PrintDOM.java (20 lines)
10     { 
11         DocumentBuilder parser =  
12             DocumentBuilderFactory.newInstance().newDocumentBuilder();
13         Document document = parser.parse( new InputSource("zooinventory.xml") ); 
14         Transformer transformer =  

examples/ch24/PrintXInclude.java (24 lines)
9     public static void main( String [] args ) throws Exception  
10     { 
11         DocumentBuilderFactory factory = 
12             DocumentBuilderFactory.newInstance();
13         factory.setNamespaceAware( true ); 
14         factory.setXIncludeAware( true ); 

examples/ch24/TestDOM.java (33 lines)
6     public static void main( String [] args ) throws Exception 
7     { 
8         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
9         DocumentBuilder parser = factory.newDocumentBuilder(); 
10         Document document = parser.parse( "zooinventory.xml" ); 
Source code below from:
Java In A Nutshell, 5th Edition
By David Flanagan
Published 15 March, 2005
Average rating

      Powells     Alibris

Javanut5Examples/Chapter5/DOMToStream.java (46 lines)
11                TransformerException 
12     { 
13         // Create a DocumentBuilderFactory and a DocumentBuilder
14         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
15         DocumentBuilder db = dbf.newDocumentBuilder(); 
16         // Instead of parsing an XML document, however, just create an empty 

Javanut5Examples/Chapter5/GetSectionTitles.java (41 lines)
9     { 
10         // Create a factory object for creating DOM parsers and configure it 
11         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
12         factory.setIgnoringComments(true);  // We want to ignore comments 
13         factory.setCoalescing(true);        // Convert CDATA to Text nodes 

Javanut5Examples/Chapter5/XPathEvaluator.java (33 lines)
14     // XPath can also be used with a SAX InputSource 
15     DocumentBuilder parser = 
16         DocumentBuilderFactory.newInstance().newDocumentBuilder();
17     Document doc = parser.parse(new java.io.File(documentName)); 
18      
Source code below from:
Ivor Horton's Beginning Java 2, JDK 5 Edition
By Ivor Horton
Published 31 December, 2004
Average rating

      Powells     Alibris

Code/Ch23/Listing Elements with Attributes/TryDOM.java (125 lines)
1 import javax.xml.parsers.DocumentBuilderFactory;
2 import javax.xml.parsers.DocumentBuilder; 
3 import javax.xml.parsers.ParserConfigurationException; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27 } 28 File xmlFile = new File(args[0]); 29 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); 30 builderFactory.setNamespaceAware(true); // Set namespace aware 31 builderFactory.setValidating(true); // and validating parser feaures

Code/Ch23/Sketcher with XML/SketchFrame.java (926 lines)
30  
31 import javax.xml.parsers.DocumentBuilder; 
32 import javax.xml.parsers.DocumentBuilderFactory;
33 import javax.xml.parsers.ParserConfigurationException; 
34  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
733 // Open XML file containing a sketch 734 private void openXMLSketch(File xmlFile) { 735 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); 736 builderFactory.setValidating(true); // Add validating parser feature 737 builderFactory.setIgnoringElementContentWhitespace(true);

Code/Ch23/Sketcher with XML/SketchModel.java (86 lines)
5 import java.awt.Rectangle; 
6 import javax.swing.JOptionPane; 
7 import javax.xml.parsers.DocumentBuilderFactory;
8 import javax.xml.parsers.ParserConfigurationException; 
9 import org.w3c.dom.Document; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51 Document doc = null; 52 try { 53 DOMImplementation domImpl = DocumentBuilderFactory.newInstance() 54 .newDocumentBuilder() 55 .getDOMImplementation();

Code/Ch23/Try DOM Parsing/TryDOM.java (116 lines)
1 import javax.xml.parsers.DocumentBuilderFactory;
2 import javax.xml.parsers.DocumentBuilder; 
3 import javax.xml.parsers.ParserConfigurationException; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 } 26 File xmlFile = new File(args[0]); 27 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); 28 builderFactory.setNamespaceAware(true); // Set namespace aware 29 builderFactory.setValidating(true); // and validating parser feaures

Code/Ch23/TryDOM.java (20 lines)
1 import javax.xml.parsers.DocumentBuilderFactory;
2 import javax.xml.parsers.DocumentBuilder; 
3 import javax.xml.parsers.ParserConfigurationException; 
4 import org.xml.sax.SAXException; 
5  
6 public class TryDOM { 
7   public static void main(String args[]) { 
8      DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
9      DocumentBuilder builder = null; 
10      try { 
Source code below from:
Core Java(TM) 2, Volume II--Advanced Features (7th Edition)
By Cay Horstmann and Gary Cornell
Published 22 November, 2004
Average rating

      Powells     Alibris

v2/v2ch12/DOMTreeTest/DOMTreeTest.java (243 lines)
85          if (builder == null) 
86          { 
87             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
88             builder = factory.newDocumentBuilder(); 
89          } 

v2/v2ch12/GridBagTest/GridBagPane.java (247 lines)
34       try 
35       { 
36          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
37          factory.setValidating(true); 
38  

v2/v2ch12/XMLWriteTest/XMLWriteTest.java (228 lines)
132       generator = new Random(); 
133  
134       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
135       try 
136       { 

v2/v2ch12/XPathTest/XPathTest.java (180 lines)
86       try 
87       { 
88          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
89          builder = factory.newDocumentBuilder(); 
90       } 
Source code below from:
Java Cookbook, Second Edition
By Ian Darwin
Published 14 June, 2004
Average rating

      Powells     Alibris

xml/DocWriteDOM.java (64 lines)
2  
3 import javax.xml.parsers.DocumentBuilder; 
4 import javax.xml.parsers.DocumentBuilderFactory;
5  
6 import org.w3c.dom.Document; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33 protected Document makeDoc() { 34 try { 35 DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); 36 DocumentBuilder parser = fact.newDocumentBuilder(); 37 Document doc = parser.newDocument();

xml/XParse.java (67 lines)
2  
3 import javax.xml.parsers.DocumentBuilder; 
4 import javax.xml.parsers.DocumentBuilderFactory;
5  
6 import org.w3c.dom.Document; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 String uri = "file:" + new File(fileName).getAbsolutePath(); 23 24 DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); 25 if (validate) 26 f.setValidating(true);

xml/XTW.java (102 lines)
3  
4 import javax.xml.parsers.DocumentBuilder; 
5 import javax.xml.parsers.DocumentBuilderFactory;
6  
7 import org.w3c.dom.Document; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38 String uri = "file:" + new File(fileName).getAbsolutePath(); 39 40 DocumentBuilderFactory factory = 41 DocumentBuilderFactory.newInstance(); 42 DocumentBuilder builder = factory.newDocumentBuilder(); 43 Document doc = builder.parse( uri );

xmlform/XmlForm.java (60 lines)
26             //String uri = "file:" + new File(fileName).getAbsolutePath(); 
27             InputStream uri = getClass().getResourceAsStream(fileName); 
28             DocumentBuilderFactory factory =
29                 DocumentBuilderFactory.newInstance();
30             DocumentBuilder builder = factory.newDocumentBuilder(); 
31             Document doc = builder.parse( uri ); 
Source code below from:
Java Examples in a Nutshell, 3rd Edition
By David Flanagan
Published 01 January, 2004
Average rating

      Powells     Alibris

JavaExamples3/je3/xml/WebAppConfig.java (160 lines)
51     { 
52     // Get a JAXP parser factory object 
53     javax.xml.parsers.DocumentBuilderFactory dbf =
54         DocumentBuilderFactory.newInstance();
55     // Tell the factory what kind of parser we want  
56     dbf.setValidating(false); 
Source code below from:
Java Examples in a Nutshell (In a Nutshell)
By David Flanagan
Published 26 September, 2000
Average rating

      Powells     Alibris

JavaExamples2/com/davidflanagan/examples/xml/WebAppConfig.java (153 lines)
48     { 
49     // Get a JAXP parser factory object 
50     javax.xml.parsers.DocumentBuilderFactory dbf =
51         DocumentBuilderFactory.newInstance();
52     // Tell the factory what kind of parser we want  
53     dbf.setValidating(false); 

Not satisfied? Try this search biased towards software and programming:
Google