[jdom-interest] getChild problem?

Michael E. Smoot mes5k at cs.virginia.edu
Tue Oct 2 08:05:56 PDT 2001


On Tue, 2 Oct 2001, Nick Fankhauser wrote:

> Mike-
>
> Are you sure this is an error associated with the XML/JDOM part? It looks to
> me like a JDOM exception would be giving you a "Parse error", but any other
> exception prints "Unknown error".
>
> Have you tried putting a couple of print statements right after the getChild
> lines to see if those lines actually execute & if so what "header" & "seq"
> contain ?
>
> -Nick


Nick, I agree its a bit strange.  I have tried all sorts of print
statements and the result is always the same: it dies at the first
getChild().  I even tried: root.getChild("contig").getChild("header") and
again it fails.

Here is the result of some added print statements ( the code is below ).


root: [Element: <Seq:sequenceSet [Namespace: file:///export/work/DisplayMUMs/]/> ]
e: [Element: <Seq:contig [Namespace: file:///export/work/DisplayMUMs/]/>]
Unknown error: null




thanks,
Mike








Here is the code:

    public SequenceSet( String f )
    {
        file = new File(f);
        seqs = new Vector();

        try
        {
            DOMBuilder builder = new DOMBuilder();
            Document doc = builder.build(file);

            Element root = doc.getRootElement();
            System.out.println("root: " + root.toString());

            List kids = root.getChildren();

            for ( int i = 0; i< kids.size(); i++ )
            {
                Element e = (Element)(kids.get(i));
                System.out.println("e: " + e.toString());

                Element e1 = e.getChild("Seq:header");
                System.out.println("e1: " + e1.toString());

                String header = e1.getTextTrim();
                System.out.println("header: " + header);

                StringBuffer seq = new StringBuffer(
                        e.getChild("Seq:sequence").getTextTrim() );

                seqs.add( new Sequence(header,seq) );
            }

        } catch (JDOMException e)
            { System.out.println("Parse error: " + e.getMessage()); }
          catch (Exception e)
            { System.out.println("Unknown error: " + e.getMessage()); }

    }




More information about the jdom-interest mailing list