KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > util > XMLUtils


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis2.util;
17
18 import org.w3c.dom.Document JavaDoc;
19 import org.xml.sax.SAXException JavaDoc;
20
21 import javax.xml.parsers.DocumentBuilder JavaDoc;
22 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
23 import javax.xml.parsers.ParserConfigurationException JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.io.InputStream JavaDoc;
26
27 /**
28  * Some XML utility functions
29  *
30  */

31 public class XMLUtils {
32     
33     /**
34      * Get an empty new Document
35      *
36      * @return Document
37      * @throws ParserConfigurationException if construction problems occur
38      */

39     public static Document JavaDoc newDocument()
40     throws ParserConfigurationException JavaDoc {
41         DocumentBuilder JavaDoc db = null;
42         
43         DocumentBuilderFactory JavaDoc dbf = DocumentBuilderFactory.newInstance();
44         dbf.setNamespaceAware(true);
45         db = dbf.newDocumentBuilder();
46         Document JavaDoc doc = db.newDocument();
47         return doc;
48     }
49     
50     /**
51      * Method newDocument
52      *
53      * @param in
54      * @return
55      * @throws ParserConfigurationException
56      * @throws SAXException
57      * @throws IOException
58      */

59     public static Document JavaDoc newDocument(InputStream JavaDoc in)
60             throws ParserConfigurationException JavaDoc, SAXException JavaDoc, IOException JavaDoc {
61         DocumentBuilderFactory JavaDoc dbf = DocumentBuilderFactory.newInstance();
62         dbf.setNamespaceAware(true);
63         DocumentBuilder JavaDoc db = dbf.newDocumentBuilder();
64         return db.parse(in);
65     }
66
67 }
68
Popular Tags