Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Call for Votes: new name for ParseException

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Janek Bogucki <janekdb AT yahoo.co.uk>
  • To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>, xom-interest AT lists.ibiblio.org
  • Cc:
  • Subject: Re: [XOM-interest] Call for Votes: new name for ParseException
  • Date: Mon, 21 Jul 2003 18:44:48 +0100 (BST)

--- Elliotte Rusty Harold <elharo AT metalab.unc.edu> wrote: >
> It's been pointed out that nu.xom.ParseException conflicts with
> java.text.ParseException. I'd certainly prefer not to have any needless
> name conflicts between XOM and the classes in the java.* packages. Thus
> a name change is called for. Possible new names for this class include:
>
> XMLParseException
> ParserException
> ParsingException
>
> Please let me know which one you prefer, or any other suggestions you
> might have. Thanks! I've already implemented the NodeFactory and
> Serializer changes discussed here over the last couple of weeks, so once
> we decide on a new name for ParseException, I can push 1.0d19 out the door.
> --
>
> Elliotte Rusty Harold

Looking through the usage of ParseException leads me to believe a better name
would be:

WellformednessException

In the majority of uses where ParseException is caught it is assumed to be a
well-formedness
error. ParseException is thrown in Builder and it looks like it's in response
to a well-formedness
problem on both occassions. PsuedoAttributes also throws ParseException but
someone familiar with
this class should comment on the intention here.

One notable exception to these pattern of usage is in SchemaValidator where
we have:

catch (ParseException ex) {
System.out.println(args[0] + " is not schema valid.");
System.out.println(ex.getMessage());
ex.printStackTrace();
System.out.println(" at line " + ex.getLineNumber()
+ ", column " + ex.getColumnNumber());
}

but the method throwing ParseException should probably be throwing
nu.xom.ValidityException
instead. Whether a validity exception remains a subclass of a wellformedness
exception is another
question.

So in summary I suggest

fix up uses of ParseException that should be uses of ValidityException
replace ParseException with WellformednessException

One problem with this suggestion is that it leaves XOM without a sutiable
generic superclass for
all checked exceptions thrown in XOM (because the name is
WellformedException) so maybe this is an
argument for a subclass of XOMException (where XOMException is the generic
superclass for checked
exceptions).

Having said that the generic superclass of all runtime exceptions is named
XMLException and there
may be runtime exceptions unrelated to XML thrown. The obvious proposal here
is:

XOMException for checked exceptions
XOMRuntimeException for unchecked exceptions

My two Euros.

-Janek

Below are extracts of catchs of ParseException from 1.0d18. Not included are
usages where the
thrown ParseException is stackTraced'd to err without supplementary
information being prefixed. So
it's not scientific...


samples/ElementLister.java- // indicates a well-formedness error
samples/ElementLister.java: catch (ParseException e) {

samples/CommentReader.java: catch (ParseException ex) {
samples/CommentReader.java- System.out.println(args[0] + " is not
well-formed.");

samples/FibonacciXMLRPCClient.java: catch (ParseException ex) {
samples/FibonacciXMLRPCClient.java- System.err.println("Server sent
malformed output");
samples/FibonacciXMLRPCClient.java- System.err.println(ex);

samples/Linkset.java: catch (ParseException e) {
samples/Linkset.java- System.out.println(url + " is not well-formed.");
samples/Linkset.java- }

samples/NodeLister.java: catch (ParseException e) {
samples/NodeLister.java- System.out.println(args[0] + " is not
well-formed.");
samples/NodeLister.java- System.out.println(e.getMessage());
samples/NodeLister.java- }

samples/PrettyPrinter.java: catch (ParseException ex) {
samples/PrettyPrinter.java- System.out.println(args[0] + " is not
well-formed.");
samples/PrettyPrinter.java- System.out.println(ex.getMessage());
samples/PrettyPrinter.java- }

samples/ProcessingInstructionLister.java: catch (ParseException ex) {
samples/ProcessingInstructionLister.java- System.out.println(args[0]
+ " is not
well-formed.");
samples/ProcessingInstructionLister.java-
System.out.println(ex.getMessage());
samples/ProcessingInstructionLister.java- }


samples/PseudoAttributes.java: throw new ParseException(pi.toXML()
samples/PseudoAttributes.java- + " is not in pseudo-attribute
format.", ex);

samples/RDDLStripper.java: catch (ParseException ex) {
samples/RDDLStripper.java- System.out.println(args[0] + " is not
well-formed.");
samples/RDDLStripper.java- System.out.println(ex.getMessage());
samples/RDDLStripper.java- }

samples/ResourceToTable.java: catch (ParseException ex) {
samples/ResourceToTable.java- System.out.println(args[0] + " is not
well-formed.");
samples/ResourceToTable.java- }

samples/Restructurer.java: catch (ParseException e) {
samples/Restructurer.java- System.out.println(url + " is not
well-formed.");
samples/Restructurer.java- }

samples/SchemaValidator.java: catch (ParseException ex) {
samples/SchemaValidator.java- System.out.println(args[0] + " is not
schema valid.");
samples/SchemaValidator.java- System.out.println(ex.getMessage());
samples/SchemaValidator.java- ex.printStackTrace();
samples/SchemaValidator.java- System.out.println(" at line " +
ex.getLineNumber()
samples/SchemaValidator.java- + ", column " + ex.getColumnNumber());
samples/SchemaValidator.java- }

samples/TextExtractor.java: catch (ParseException ex) {
samples/TextExtractor.java- System.out.println(args[0] + " is not
well-formed.");
samples/TextExtractor.java- System.out.println(" at line " +
ex.getLineNumber()
samples/TextExtractor.java- + ", column " +
ex.getColumnNumber());
samples/TextExtractor.java- System.out.println(ex.getMessage());
samples/TextExtractor.java- }

samples/TreePrinter.java- // indicates a well-formedness error
samples/TreePrinter.java: catch (ParseException e) {
samples/TreePrinter.java- System.out.println(args[0] + " is not
well-formed.");
samples/TreePrinter.java- System.out.println(e.getMessage());
samples/TreePrinter.java- }

samples/Validator.java:import nu.xom.ParseException;
samples/Validator.java-import nu.xom.ValidityException;
samples/Validator.java-
samples/Validator.java-/**
samples/Validator.java- * <p>
samples/Validator.java- * Demonstrates validation via the
<code>Builder</code> class.
samples/Validator.java- * </p>
samples/Validator.java- *
samples/Validator.java- * @author Elliotte Rusty Harold
samples/Validator.java- * @version 1.0d18
samples/Validator.java- *
samples/Validator.java- */
samples/Validator.java-public class Validator {
samples/Validator.java-
samples/Validator.java- public static void main(String[] args) {
samples/Validator.java-
samples/Validator.java- if (args.length <= 0) {
samples/Validator.java- System.out.println("Usage: java
nu.xom.samples.Validator URL");
samples/Validator.java- return;
samples/Validator.java- }
samples/Validator.java-
samples/Validator.java- try {
samples/Validator.java- Builder parser = new Builder(true);
samples/Validator.java- parser.build(args[0]);
samples/Validator.java- System.out.println(args[0] + " is valid.");
samples/Validator.java- }
samples/Validator.java- catch (ValidityException ex) {
samples/Validator.java- System.out.println(args[0] + " is not valid.");
samples/Validator.java- System.out.println(ex.getMessage());
samples/Validator.java- System.out.println(" at line " +
ex.getLineNumber()
samples/Validator.java- + ", column " + ex.getColumnNumber());
samples/Validator.java- }
samples/Validator.java: catch (ParseException ex) {
samples/Validator.java- System.out.println(args[0] + " is not
well-formed.");
samples/Validator.java- System.out.println(ex.getMessage());
samples/Validator.java- System.out.println(" at line " +
ex.getLineNumber()
samples/Validator.java- + ", column " + ex.getColumnNumber());
samples/Validator.java- }

samples/XHTMLPurifier.java: catch (ParseException ex) {
samples/XHTMLPurifier.java- System.out.println(args[0] + " is not
well-formed.");
samples/XHTMLPurifier.java- System.out.println(ex.getMessage());
samples/XHTMLPurifier.java- }

amples/XHTMLQualifier.java: catch (ParseException e) {
samples/XHTMLQualifier.java- System.out.println(args[0] + " is not
well-formed.");
samples/XHTMLQualifier.java- System.out.println(e.getMessage());
samples/XHTMLQualifier.java- }

samples/XHTMLValidator.java: catch (ParseException e) {
samples/XHTMLValidator.java- System.out.println(source
samples/XHTMLValidator.java- + " is invalid XML, and thus not
XHTML.");
samples/XHTMLValidator.java- return;
samples/XHTMLValidator.java- }

samples/XMLPrinter.java: catch (ParseException ex) {
samples/XMLPrinter.java- System.out.println(args[0] + " is not
well-formed.");
samples/XMLPrinter.java- System.out.println(ex.getMessage());
samples/XMLPrinter.java- }

samples/XOMChecker.java: catch (ParseException ex) {
samples/XOMChecker.java- System.out.println(args[0] + " is not
well-formed.");
samples/XOMChecker.java- System.out.println(ex.getMessage());
samples/XOMChecker.java- System.out.println(" at line " +
ex.getLineNumber()
samples/XOMChecker.java- + ", column " + ex.getColumnNumber());
samples/XOMChecker.java- }

samples/StreamingCommentReader.java: catch (ParseException ex) {
samples/StreamingCommentReader.java- System.out.println(args[0] + "
is not
well-formed.");
samples/StreamingCommentReader.java-
System.out.println(ex.getMessage());
samples/StreamingCommentReader.java- }

samples/StreamingElementLister.java: catch (ParseException e) {
samples/StreamingElementLister.java- System.out.println(args[0] +
" is not
well-formed.");
samples/StreamingElementLister.java-
System.out.println(e.getMessage());
samples/StreamingElementLister.java- }

samples/RDDLToTable.java: catch (ParseException ex) {
samples/RDDLToTable.java- System.out.println(args[0] + " is not
well-formed.");
samples/RDDLToTable.java- System.out.println(ex.getMessage());
samples/RDDLToTable.java- }


samples/StreamingNodeLister.java- // indicates a well-formedness error
samples/StreamingNodeLister.java: catch (ParseException ex) {
samples/StreamingNodeLister.java- System.out.println(args[0] + " is not
well-formed.");
samples/StreamingNodeLister.java- System.out.println(ex.getMessage());
samples/StreamingNodeLister.java- }

samples/StreamingProcessingInstructionLister.java: catch
(ParseException ex) {
samples/StreamingProcessingInstructionLister.java-
System.out.println(args[0] + " is not
well-formed.");
samples/StreamingProcessingInstructionLister.java-
System.out.println(ex.getMessage());
samples/StreamingProcessingInstructionLister.java- }

samples/StreamingPropertyPrinter.java: catch (ParseException ex) {
samples/StreamingPropertyPrinter.java- System.out.println(args[0] +
" is not
well-formed.");
samples/StreamingPropertyPrinter.java-
System.out.println(ex.getMessage());
samples/StreamingPropertyPrinter.java- }

samples/StreamingTextExtractor.java: catch (ParseException ex) {
samples/StreamingTextExtractor.java- System.out.println(args[0] + "
is not
well-formed.");
samples/StreamingTextExtractor.java-
System.out.println(ex.getMessage());
samples/StreamingTextExtractor.java- }

samples/StreamingTreeReporter.java: catch (ParseException ex) {
samples/StreamingTreeReporter.java- System.out.println(args[0] + "
is not well-formed.");
samples/StreamingTreeReporter.java-
System.out.println(ex.getMessage());
samples/StreamingTreeReporter.java- }

samples/StreamingXHTMLQualifier.java: catch (ParseException ex) {
samples/StreamingXHTMLQualifier.java- System.out.println(args[0] + "
is not
well-formed.");
samples/StreamingXHTMLQualifier.java-
System.out.println(ex.getMessage());
samples/StreamingXHTMLQualifier.java- }

samples/PureValidator.java: catch (ParseException ex) {
samples/PureValidator.java- System.out.println(args[0] + " is not
well-formed.");
samples/PureValidator.java- System.out.println(ex.getMessage());
samples/PureValidator.java- System.out.println(" at line " +
ex.getLineNumber()
samples/PureValidator.java- + ", column " + ex.getColumnNumber());
samples/PureValidator.java- }

samples/RSSHeadlines.java: catch (ParseException ex) {
samples/RSSHeadlines.java- System.out.println(url + " is not
well-formed.");
samples/RSSHeadlines.java- System.out.println(ex.getMessage());
samples/RSSHeadlines.java- }

samples/RDDLFilter.java: catch (ParseException ex) {
samples/RDDLFilter.java- System.out.println(args[0] + " is not
well-formed.");
samples/RDDLFilter.java- System.out.println(ex.getMessage());
samples/RDDLFilter.java- }




__________________________________________________
Yahoo! Plus - For a better Internet experience
http://uk.promotions.yahoo.com/yplus/yoffer.html




Archive powered by MHonArc 2.6.24.

Top of Page