[jdom-interest] SaxParserException comparison

rpcee rpcee at operamail.com
Wed Oct 31 00:40:40 PST 2001


Not really jdom, but:

  if (je.getCause() instanceof SAXParseException) { ... }

Your element runs through samples.SAXBuilderDemo OK so I guess your error is 
elsewhere in your >753 line source.


>===== Original Message From "Lopez, William" <william.lopez at eds.com> =====
>I want to compare a Throwable object obtained from the
>JDOMException.getCause( ) method to a SaxParserException so I can flag the
>source table of the XML file I'm retrieving as "bogus".
>
>Here's the error:
>
>org.jdom.JDOMException: Error on line 753: The element type
>"OrganizationHierarchyNode" must be terminated by the matching end-tag
>"</OrganizationHierarchyNode>".
>	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:300)
>	at dtdmap.helpers.xml.JDOMReader.startBillParse(JDOMReader.java:134)
>	at dtdmap.ProcessXML.main(ProcessXML.java:126)
>Root cause: org.xml.sax.SAXParseException: The element type
>"OrganizationHierarchyNode" must be terminated by the matching end-tag
>"</OrganizationHierarchyNode>".
>	at
>org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016)
>	at
>org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocume
>ntScanner.java:634)
>	at
>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.endOfInput(
>XMLDocumentScanner.java:1457)
>	at
>org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocumentScanner
>.java:417)
>	at
>org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifications
>(XMLValidator.java:570)
>	at
>org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultEntityHa
>ndler.java:1026)
>	at
>org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityReader.java
>:168)
>	at
>org.apache.xerces.readers.UTF8Reader.changeReaders(UTF8Reader.java:182)
>	at
>org.apache.xerces.readers.UTF8Reader.lookingAtChar(UTF8Reader.java:197)
>	at
>org.apache.xerces.framework.XMLDocumentScanner.scanAttributeName(XMLDocument
>Scanner.java:2119)
>	at
>org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
>r.java:1797)
>	at
>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
>LDocumentScanner.java:1233)
>	at
>org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
>java:380)
>	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:908)
>	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:287)
>
>
>Here's my lame attempt to do so:
>
>catch (JDOMException je)
>    {
>      je.printStackTrace();
>
>      Throwable rootCause = je.getCause();
>
>        boolean saxExp =
>rootCause.equals(Class.forName("org.xml.sax.SAXParseException"));
>        if(saxExp)
>        {
>          ...do something
>        }
>     }
>
>How can I compare a Class (org.xml.sax.SAXParseException) to an Object
>(Throwable).
>
>Also, I can't seem to find the error the parser is complaining about. The
>element in question does have an  end-tag. Everything else appears to be
>correct. DOH!
>
>element:
><OrganizationHierarchyNode cancelDate="9999-12-31" bankAccountCode=""
>bankAccountDescription="" duplicateRuleCode="3"
>duplicateRuleDescription="Duplicate Rule 3" effectiveDate="1582-10-15" id=""
>name="FIRST HEALTH" maintenanceDocumentation="" produceChecks="false">
>	<OrganizationTreatmentParameters treatmentPercentileCode=""
>treatmentPercentileDescription="" treatmentVisits="" treatmentWarning=""/>
>	<OrganizationDrugSupplyDetail drugCutback="1.00" drugMarkup="1.50"
>maximumDrugMarkup="10.00" maximumSupplyMarkup="20.00"
>minimumDrugMarkup="5.00" minimumSupplyMarkup="5.00" 	supplyMarkup="1.50"
>supplyCutback="1.00"/>
>	<CommentCollection nbrComment="0"/>
></OrganizationHierarchyNode>
>
>DTD def:
><!ELEMENT OrganizationHierarchyNode (OrganizationTreatmentParameters,
>OrganizationDrugSupplyDetail, CommentCollection)>
><!ATTLIST OrganizationHierarchyNode
>	cancelDate CDATA #REQUIRED
>	bankAccountCode CDATA #REQUIRED
>	bankAccountDescription CDATA #REQUIRED
>	duplicateRuleCode CDATA #REQUIRED
>	duplicateRuleDescription CDATA #REQUIRED
>	effectiveDate CDATA #REQUIRED
>	id CDATA #REQUIRED
>	name CDATA #REQUIRED
>	maintenanceDocumentation CDATA #REQUIRED
>	produceChecks CDATA #REQUIRED
>>
>
>
>Thanks,
>
>
>William Lopez
>EDS - Health and Insurance Solution Centre
>MS C3-1C-37
>5400 Legacy Drive
>Plano, TX 75024
>
>* phone: +01-972-604-3372 (834-3372)
>* mailto:william.lopez at eds.com
>www.eds.com
>
>
>_______________________________________________
>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