[jdom-interest] RE: Please Help me ASAP with JDOM to SAX

Jools Enticknap jools at jools.org
Thu Jul 20 11:35:53 PDT 2000


Hi Johnathan

1) Have you looked WarReader.java in the samples directory ? Looks like it
   might help.....

2) What __exactly__ is your problem ? A problem description would be nice
   :-)

--Jools


> 
> > Do to memory issues I have to write a program like this in SAX.
> > 
> > Can help out help me I have to get this done today and I dont know sax
> > 
> > import java.io.*;
> > import java.util.*;
> > import org.jdom.*;
> > import org.jdom.input.*;
> > import org.jdom.output.*;
> > 
> > public class WarReader {
> > 
> > public static void main(String[] args) {
> > 
> > PrintStream out = System.out;
> > 
> > if (args.length != 1 && args.length != 2) {
> > out.println("Usage: WarReader [web.xml]");
> > return;
> > }
> > 
> > try {
> > // Request document building without validation
> > SAXBuilder builder = new SAXBuilder(false);
> > Document doc = builder.build(new File(args[0]));
> > 
> > // Get the root element
> > Element root = doc.getRootElement();
> > 
> > // Print servlet information
> > List servlets = root.getChildren("servlet");
> > out.println("This WAR has "+ servlets.size() +" registered servlets:");
> > Iterator i = servlets.iterator();
> > while (i.hasNext()) {
> > Element servlet = (Element) i.next();
> > out.print("\t" + servlet.getChild("servlet-name")
> > .getContent() +
> > " for " + servlet.getChild("servlet-class")
> > .getContent());
> > List initParams = servlet.getChildren("init-param");
> > out.println(" (it has " + initParams.size() + " init params)");
> > }
> > 
> > // Print security role information
> > List securityRoles = root.getChildren("security-role");
> > if (securityRoles.size() == 0) {
> > out.println("This WAR contains no roles");
> > }
> > else {
> > Element securityRole = (Element) securityRoles.get(0);
> > List roleNames = securityRole.getChildren("role-name");
> > out.println("This WAR contains " + roleNames.size() + " roles:");
> > i = roleNames.iterator();
> > while (i.hasNext()) {
> > Element e = (Element) i.next();
> > out.println("\t" + e.getContent());
> > }
> > }
> > 
> > // Print distributed information (notice this is out of order)
> > List distrib = root.getChildren("distributed");
> > if (distrib.size() == 0) {
> > out.println("This WAR is not distributed");
> > } else {
> > out.println("This WAR is distributed");
> > }
> > 
> > } catch (Exception e) {
> > e.printStackTrace();
> > }
> > }
> > }
> > 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 




More information about the jdom-interest mailing list