You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Thierry Kormann <Th...@sophia.inria.fr> on 2000/11/15 16:58:09 UTC

error handling

Hi,

Here is a proposal of what we (stephane and I) plan to start tomorrow. You will 
find the different exceptions. No freeze needed now.

Any comments?
Thierry.

---

--------------
- SAXException 
--------------
	Thrown when the SVG file is not a valid XML document.

----------------------------------
- MalformedSVGException (abstract)
----------------------------------

	Thrown when the SVG file is not	conformed to the spec.

  * MissingAttributeException (subclass)

	Thrown when an attribute is missing (ie. not specified on a SVGElement).
	ex: <image xlink:href="foo.jpg"/>

  * IllegalAttributeValueException (subclass)

	Thrown when an attribute has an illegal value.
	ex: <linearGradient gradientUnits="objectBoundingBox" x="3"/>

  * ParseAttributeException (subclass)

	Thrown when an error occured while parsing an attribute.
	ex: <path d="M10 10X"/> or <rect x="3.3.3"/>

  * BadDocumentStructureException

	Thrown when an SVGElement is at a wrong place.
	ex: <clipPath ...><g> 

-------------------
- CSSParseException
-------------------

	Thrown when an error occured while parsing a style declaration
	or a style sheet.
	ex: <rect style="fill:red stroke:black"/>

----------------------------------
- IllegalCSSPropertyValueException
----------------------------------

	Thrown when a css property value is not recognized by the CSS engine.

-------------------------------------------------------------------------------

Patches needed:

- micro parser default handler (see if ParseException is not catched)
- see where SAXExceptions are catched
- see if the CSS engine can throw exceptions
- all bridge classes : remove empty try catch
- CSSUtilities and SVGUtilities : check NumberFormatException...
- GVTBuilder 

  a. catches the exception, 

  b. call the appropriate method on the UserAgent to signal the error

As we can not show the line and column numbers except when a
SAXException occured - we will display the element responsible on the
error (print the element using the DOM tree). The current state of the
GVT tree displayed can also give some hints about where the error has
be thrown.


-- 
Thierry Kormann
email: Thierry.Kormann@sophia.inria.fr  http://www.inria.fr/koala/tkormann/
Koala/Dyade/Bull @ INRIA - Sophia Antipolis






Re: error handling

Posted by Vincent Hardy <vi...@eng.sun.com>.
Thierry,

Thanks for putting this together, this looks good. I have a couple 
comments/questions:

a. May be we could group IllegalAttributeValueException and 
   ParseAttributeException. As Christophe pointed out, I think they
   catch the same problem (from a user's perspective).

b. Is BadDocumentStructureException thrown when the document is not
   valid (i.e., is this only thrown when the parser's validation is
   on?). What about if there is no DTD reference.

Thanks.
V.

Thierry Kormann wrote:
> 
> Hi,
> 
> Here is a proposal of what we (stephane and I) plan to start tomorrow. You will
> find the different exceptions. No freeze needed now.
> 
> Any comments?
> Thierry.
> 
> ---
> 
> --------------
> - SAXException
> --------------
>         Thrown when the SVG file is not a valid XML document.
> 
> ----------------------------------
> - MalformedSVGException (abstract)
> ----------------------------------
> 
>         Thrown when the SVG file is not conformed to the spec.
> 
>   * MissingAttributeException (subclass)
> 
>         Thrown when an attribute is missing (ie. not specified on a SVGElement).
>         ex: <image xlink:href="foo.jpg"/>
> 
>   * IllegalAttributeValueException (subclass)
> 
>         Thrown when an attribute has an illegal value.
>         ex: <linearGradient gradientUnits="objectBoundingBox" x="3"/>
> 
>   * ParseAttributeException (subclass)
> 
>         Thrown when an error occured while parsing an attribute.
>         ex: <path d="M10 10X"/> or <rect x="3.3.3"/>
> 
>   * BadDocumentStructureException
> 
>         Thrown when an SVGElement is at a wrong place.
>         ex: <clipPath ...><g>
> 
> -------------------
> - CSSParseException
> -------------------
> 
>         Thrown when an error occured while parsing a style declaration
>         or a style sheet.
>         ex: <rect style="fill:red stroke:black"/>
> 
> ----------------------------------
> - IllegalCSSPropertyValueException
> ----------------------------------
> 
>         Thrown when a css property value is not recognized by the CSS engine.
> 
> -------------------------------------------------------------------------------
> 
> Patches needed:
> 
> - micro parser default handler (see if ParseException is not catched)
> - see where SAXExceptions are catched
> - see if the CSS engine can throw exceptions
> - all bridge classes : remove empty try catch
> - CSSUtilities and SVGUtilities : check NumberFormatException...
> - GVTBuilder
> 
>   a. catches the exception,
> 
>   b. call the appropriate method on the UserAgent to signal the error
> 
> As we can not show the line and column numbers except when a
> SAXException occured - we will display the element responsible on the
> error (print the element using the DOM tree). The current state of the
> GVT tree displayed can also give some hints about where the error has
> be thrown.
> 
> --
> Thierry Kormann
> email: Thierry.Kormann@sophia.inria.fr  http://www.inria.fr/koala/tkormann/
> Koala/Dyade/Bull @ INRIA - Sophia Antipolis
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-dev-help@xml.apache.org

Re: error handling

Posted by Christophe Jolif <cj...@ilog.fr>.
Hello Thierry,

Thierry Kormann wrote:

> Here is a proposal of what we (stephane and I) plan to start tomorrow. You will
> find the different exceptions. No freeze needed now.
> 
> Any comments?

It seems reasonable. see comments below.

> --------------
> - SAXException
> --------------
>         Thrown when the SVG file is not a valid XML document.
> 
> ----------------------------------
> - MalformedSVGException (abstract)
> ----------------------------------
> 
>         Thrown when the SVG file is not conformed to the spec.
> 
>   * MissingAttributeException (subclass)
> 
>         Thrown when an attribute is missing (ie. not specified on a SVGElement).
>         ex: <image xlink:href="foo.jpg"/>
> 
>   * IllegalAttributeValueException (subclass)
> 
>         Thrown when an attribute has an illegal value.
>         ex: <linearGradient gradientUnits="objectBoundingBox" x="3"/>

For my information, what is the attribute that has an illegal value? I
see an attribute that is not a linearGradient attribute (x instead of
x1), but I can't see a wrong value?
 
>   * ParseAttributeException (subclass)
> 
>         Thrown when an error occured while parsing an attribute.
>         ex: <path d="M10 10X"/> or <rect x="3.3.3"/>

Is this one a subclass of IllegalAttributeValueException? Indeed when
the parsing is not ok, this means that the attribute value is wrong :-)
 
>   * BadDocumentStructureException
> 
>         Thrown when an SVGElement is at a wrong place.
>         ex: <clipPath ...><g>

In general for MalformedSVGException, do you plan to have a non "strict"
policy available. I explain: by default when such an error is
encountered, the exception is thrown and the loading stops at the place
of the error. But do you plan to have a mode where these kind of errors
are ignored (just to get an idea of what could be the file if it was
correctly formed for example when somebody forgot to put type="text/css"
on a style element)?

> -------------------
> - CSSParseException
> -------------------
> 
>         Thrown when an error occured while parsing a style declaration
>         or a style sheet.
>         ex: <rect style="fill:red stroke:black"/>
> 
> ----------------------------------
> - IllegalCSSPropertyValueException
> ----------------------------------
> 
>         Thrown when a css property value is not recognized by the CSS engine.

Here also a non "strict" policy could help to load files that have been
designed with property values other than specified one (for particular
extensions for example)

For CSS, do you plan to have a particular kind of exception for bad URI
references?

> -------------------------------------------------------------------------------
> 
> Patches needed:
> 
> - micro parser default handler (see if ParseException is not catched)
> - see where SAXExceptions are catched
> - see if the CSS engine can throw exceptions
> - all bridge classes : remove empty try catch
> - CSSUtilities and SVGUtilities : check NumberFormatException...
> - GVTBuilder
> 
>   a. catches the exception,
> 
>   b. call the appropriate method on the UserAgent to signal the error
> 
> As we can not show the line and column numbers except when a
> SAXException occured - we will display the element responsible on the
> error (print the element using the DOM tree). The current state of the
> GVT tree displayed can also give some hints about where the error has
> be thrown.

-- 
Christophe