[jdom-interest] Failing early on maxLength violations
Michael Kay
mike at saxonica.com
Wed Dec 14 02:04:57 PST 2005
Where exactly does JDOM come into this?
In general I don't think that schemas are the right way to impose system
limits for performance or resource utilisation reasons. Your example tends
to reinforce this view.
You're better off imposing a limit on the total size of the XML file, which
is something you can check before you start parsing it.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: jdom-interest-bounces at jdom.org
> [mailto:jdom-interest-bounces at jdom.org] On Behalf Of J. McConnell
> Sent: 14 December 2005 00:38
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Failing early on maxLength violations
>
> I am currently developing a web service that accepts images, among
> other things. I am debating having the images submitted in the XML
> using base64Binary typed elements. Using a maxLength restriction on
> these elements, I plan on limiting images to around 512 KB, mainly
> because I am concerned about both bandwidth and memory (parsing and
> decoding) issues.
>
> One question I still have is, what happens if a user uploads a 5 MB
> photo? I would love for the 512 KB maxLength to protect me from this,
> but some initial tests indicate that the SAXBuilder won't throw an
> exception until the end tag for the element it's parsing is reached.
> At that point, I've already sucked the entire 5 MB worth of data into
> memory, though I am saved the decoding costs.
>
> Is there any way to have the SAXBuilder throw the exception as soon as
> the maxLength is exceeded?
>
> Thanks for any insight,
>
> - J.
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
> rhost.com
>
More information about the jdom-interest
mailing list