[jdom-interest] getChild problem?
Michael E. Smoot
mes5k at cs.virginia.edu
Tue Oct 2 07:19:38 PDT 2001
Hello,
I'm getting an undefined error by calling getChild on an element. Is
there anything obviously wrong with this 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();
List kids = root.getChildren();
for ( int i = 0; i< kids.size(); i++ )
{
Element e = (Element)(kids.get(i));
String header = e.getChild("Seq:header").getTextTrim();
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()); }
}
...
The result I get: Unknown error: null
Anything obvious? The "kids" List is populated, and Element "e" is
created each time, the problem always appears when I try to do a
getChild() on "e".
The xml used as the input here is below. According to Xerces, it is
valid.
thanks,
Mike
<?xml version="1.0"?> <!DOCTYPE Seq:sequenceSet SYSTEM
"file:///export/work/DisplayMUMs/sequenceSet.dtd"> <Seq:sequenceSet
xmlns:Seq="file:///export/work/DisplayMUMs/">
<Seq:contig>
<Seq:header>
>GSEJD27TR 2000 3000 2500 71 617
</Seq:header>
<Seq:sequence>
AAAAGGACATATGGGAGGAATGGTGGTGGGCGTGAGAAACCTGGGGTGAGACGGGTGGAAGGGTGGT
</Seq:sequence>
</Seq:contig>
<Seq:contig>
<Seq:header>
>GSECJ13TR 2000 3000 2500 25 691
</Seq:header>
<Seq:sequence>
GGATTTTGATTTTACCTATTTTGGAAGTGATATATAACCGGTTATATTTTAATGATGACCTGGCTTAT
</Seq:sequence>
</Seq:contig>
</Seq:sequenceSet>
More information about the jdom-interest
mailing list