[jdom-interest] More Exceptions
Allen, Aristotle B (Ari)
aballen at lucent.com
Thu Nov 30 08:44:41 PST 2000
When I try to build a validating sax parser I get an exception thrown and
I'm not sure why
Can anyone help me with this one? I really like JDOM much better than my
other options, but I'm running low on time.
my code:
SAXBuilder builder = new SAXBuilder(debug);
Document doc = builder.build(bais); <-- my exception is thrown here
Element root = doc.getRootElement();
String option = root.getChild("ACTION").getAttribute("option").getValue();
<--when I don't validate I get an exception here
Can JDOM handle attributes at this point? Would I be better off using a
DOMAdapter?
my dtd looks like this:
<!ELEMENT REQUEST ( TIMESTAMP, ACTION, DATABLOCK ) >
<!ELEMENT TIMESTAMP ( #PCDATA ) >
<!ELEMENT ACTION ( #PCDATA ) >
<!ATTLIST ACTION option NMTOKEN #REQUIRED >
<!ELEMENT DATABLOCK ( PARTID ) >
<!ELEMENT PARTID ( PACK_ID, OPERATOR, TESTSET, STATUS, QTY, CODE,
METAL_PACK ) >
<!ATTLIST PARTID name NMTOKEN #REQUIRED >
<!ELEMENT PACK_ID ( #PCDATA ) >
<!ELEMENT OPERATOR ( #PCDATA ) >
<!ELEMENT TESTSET ( #PCDATA ) >
<!ELEMENT STATUS ( #PCDATA ) >
<!ELEMENT QTY ( #PCDATA ) >
<!ELEMENT CODE ( #PCDATA ) >
<!ELEMENT METAL_PACK ( #PCDATA ) >
and my input stream consists of this:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE xml SYSTEM
"http://mrc3k.micro.lucent.com/~aballen/CreatePack-w.dtd">
<REQUEST>
<TIMESTAMP>2000/10/07 15:14:09</TIMESTAMP>
<ACTION option="w">CreatePack</ACTION>
<DATABLOCK>
<PARTID name="EX1234">
<PACK_ID>EX1234</PACK_ID>
<OPERATOR>AA</OPERATOR>
<TESTSET>ab16355</TESTSET>
<STATUS>PASS/AB</STATUS>
<QTY>50</QTY>
<CODE>361</CODE>
<METAL_PACK>12345678</METAL_PACK>
</PARTID>
</DATABLOCK>
</REQUEST>
org.jdom.JDOMExceptionMessage: Document root element "REQUEST", must match
DOCTYPE root "xml".: Error on line 1: Document root element "REQUEST", must
match DOCTYPE root "xml".org.jdom.JDOMException: Document root element
"REQUEST", must match DOCTYPE root "xml".: Error on line 1: Document root
element "REQUEST", must match DOCTYPE root "xml".
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:315)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:337)
at
com.lucent.mrc.opto.dataserver.modules.CreatePack.doTrans(CreatePack.java:75
)
at
com.lucent.mrc.opto.dataserver.modules.CreatePack.execute(CreatePack.java:56
)
at
com.lucent.mrc.opto.dataserver.ThreadedHandler._$2476(ThreadedHandler.java:8
4)
at
com.lucent.mrc.opto.dataserver.ThreadedHandler.run(ThreadedHandler.java:61)
Root cause: org.jdom.JDOMException: Error on line 1: Document root element
"REQUEST", must match DOCTYPE root "xml".
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:316)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:337)
at
com.lucent.mrc.opto.dataserver.modules.CreatePack.doTrans(CreatePack.java:75
)
at
com.lucent.mrc.opto.dataserver.modules.CreatePack.execute(CreatePack.java:56
)
at
com.lucent.mrc.opto.dataserver.ThreadedHandler._$2476(ThreadedHandler.java:8
4)
at
com.lucent.mrc.opto.dataserver.ThreadedHandler.run(ThreadedHandler.java:61)
Aristotle B. Allen
Software Engineer
Computer Integrated Manufacturing
Manufacturing Realization Center
Optoelectronics
m i c r o e l e c t r o n i c s g r o u p
Lucent Technologies O
Bell Labs Innovations
* aballen at lucent.com
* 610.391.3845(phone)
* 610.391.3845 (fax)
More information about the jdom-interest
mailing list