Okay I am having trouble with JAXP. I parse through the tree and find my element_nodes easily. Then I go for getNodeValue and it always seems to be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?

- thanx - JAW

       System.setProperty(
       "javax.xml.parsers.DocumentBuilderFactory",
       "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
       return dfactory = DocumentBuilderFactory.newInstance();
     HashMap result = new HashMap();

Document doc = XML.getFactory().newDocumentBuilder().parse(
new InputSource( new FileInputStream(deployPath + "META-INF/ejb-jar.xml")));
Node node = XPathAPI.selectSingleNode( doc, "ejb-jar/enterprise-beans");


NodeList childList = node.getChildNodes();
for( int i=0;i<childList.getLength();i++){
Node child = childList.item(i);
if( child.getNodeType() == Node.ELEMENT_NODE){
Element element = (Element)child;
String name = element.getTagName();
NamedNodeMap namedNodeMap = element.getAttributes();
System.out.println( name + " " + namedNodeMap.item(0).getNodeValue() );
result.put( name, child.getNodeValue() );
}
}
return result;


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd";>
<ejb-jar>
<enterprise-beans>
<!-- Session Beans -->
<session>
<description>Mail Processing Session Bean.</description>
<display-name>MailProcessingServerDisplayName</display-name>
<ejb-name>MailProcessingServer</ejb-name> <!-- Matches with JBoss.xml -->
<home>honour.session.MailProcessHome</home>
<remote>honour.session.MailProcess</remote>
<ejb-class>honour.session.MailProcessBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

Reply via email to