KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > utils > xml > TestXML


1 /*
2  * Created on 11 mai 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.bull.eclipse.jonas.utils.xml;
8
9 import java.io.File JavaDoc;
10 import java.io.FileInputStream JavaDoc;
11 import java.io.FileNotFoundException JavaDoc;
12 import java.io.IOException JavaDoc;
13 import java.util.Vector JavaDoc;
14
15 import javax.xml.parsers.ParserConfigurationException JavaDoc;
16
17 import org.w3c.dom.Document JavaDoc;
18 import org.w3c.dom.Node JavaDoc;
19 import org.w3c.dom.NodeList JavaDoc;
20 import org.xml.sax.SAXException JavaDoc;
21
22 /**
23  * @author riase
24  *
25  * To change the template for this generated type comment go to
26  * Window>Preferences>Java>Code Generation>Code and Comments
27  */

28 public class TestXML {
29
30     public static void main(String JavaDoc[] args) {
31             File JavaDoc xmlFileEJB = new File JavaDoc("H:/Projet/Middlegen/samples/build/ejb-meta/META-INF/ejb-jar.xml");
32             FileXmlUtils.getAllNameAndPackageEJBEntity(xmlFileEJB);
33
34                 
35                 // Document docXmlEJB = XMLUtils.newDocument(new FileInputStream(xmlFileEJB),false);
36
//
37
// NodeList nl1 = docXmlEJB.getElementsByTagName("servlet-class");
38
// Node servletAxisNode = null;
39
// for(int i = 0;i < nl1.getLength(); i++) {
40
// System.out.println("Node = " + nl1.item(i));
41
// System.out.println("Value = " + nl1.item(i).getFirstChild().getNodeValue());
42
//
43
// }
44

45         
46     }
47     
48     private static Node JavaDoc getNodeInWebFile(Document JavaDoc webXmlFile) {
49         // On teste les tags pouvant être présents dans le web.xml
50
// On commence par servlet-mapping et on descend jusqu'a en trouver un
51
Node JavaDoc webNode = webXmlFile.getElementsByTagName("servlet-mapping").item(0);
52         if (webNode == null)
53             webNode = webXmlFile.getElementsByTagName("session-config").item(0);
54         if (webNode == null)
55             webNode = webXmlFile.getElementsByTagName("mime-mapping").item(0);
56         if (webNode == null)
57             webNode = webXmlFile.getElementsByTagName("welcome-file-list").item(0);
58         if (webNode == null)
59             webNode = webXmlFile.getElementsByTagName("error-page").item(0);
60         if (webNode == null)
61             webNode = webXmlFile.getElementsByTagName("taglib").item(0);
62         if (webNode == null)
63             webNode = webXmlFile.getElementsByTagName("resource-env-ref").item(0);
64         if (webNode == null)
65             webNode = webXmlFile.getElementsByTagName("resource-ref").item(0);
66         if (webNode == null)
67             webNode = webXmlFile.getElementsByTagName("security-constraint").item(0);
68         if (webNode == null)
69             webNode = webXmlFile.getElementsByTagName("login-config").item(0);
70         if (webNode == null)
71             webNode = webXmlFile.getElementsByTagName("security-role").item(0);
72         if (webNode == null)
73             webNode = webXmlFile.getElementsByTagName("env-entry").item(0);
74         if (webNode == null)
75             webNode = webXmlFile.getElementsByTagName("ejb-ref").item(0);
76         if (webNode == null)
77             webNode = webXmlFile.getElementsByTagName("ejb-local-ref").item(0);
78         if (webNode == null)
79             webNode = webXmlFile.getElementsByTagName("web-app").item(0);
80         
81         return webNode;
82     }
83 }
84
Popular Tags