AW: [jdom-interest] More Exceptions

Benjamin Broll benjamin.broll at massp.com
Fri Dec 1 06:50:08 PST 2000


I think the exception is thrown because your doctype declaration looks like:

>
> <!DOCTYPE xml SYSTEM
> "http://mrc3k.micro.lucent.com/~aballen/CreatePack-w.dtd">
>

The part where you've written "xml" must be the name of the root element in
the document. Since the root element of your document is REQUEST

>
>   <REQUEST>
>     <TIMESTAMP>2000/10/07 15:14:09</TIMESTAMP>
>

and you specified the root element to be "xml" in your doctype declaration
you get the error. Change the doctype to the following:

<!DOCTYPE REQUEST SYSTEM
"http://mrc3k.micro.lucent.com/~aballen/CreatePack-w.dtd">

and it should work ...

Regards,


  BENJAMIN BROLL

  M A S S P | NEWMEDIA GMBH  FRIELINGSDORFWEG | 12  45239 | ESSEN
  TELEFON | 49 201 6159141  TELEFAX | 49 201 45139284
  BENJAMIN.BROLL at MASSP.COM  MASSPNEWMEDIA.COM


> -----Ursprüngliche Nachricht-----
> Von: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]Im Auftrag von Allen, Aristotle B
> (Ari)
> Gesendet: Donnerstag, 30. November 2000 17:45
> An: 'jdom-interest at jdom.org'
> Betreff: [jdom-interest] More Exceptions
>
>
> 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(CreatePa
> ck.java:75
> )
> 	at
> com.lucent.mrc.opto.dataserver.modules.CreatePack.execute(CreatePa
> ck.java:56
> )
> 	at
> com.lucent.mrc.opto.dataserver.ThreadedHandler._$2476(ThreadedHand
> ler.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(CreatePa
> ck.java:75
> )
> 	at
> com.lucent.mrc.opto.dataserver.modules.CreatePack.execute(CreatePa
> ck.java:56
> )
> 	at
> com.lucent.mrc.opto.dataserver.ThreadedHandler._$2476(ThreadedHand
> ler.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)
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yourad
dr at yourhost.com





More information about the jdom-interest mailing list