[opencms-dev] XSD: validation rules to control image size
Florian Hopf
hopf at synyx.de
Fri Aug 27 08:15:18 CEST 2010
Hi,
Daniel Cassiani Rezende schrieb:
> I need to control image bytes and dimension of the images users set in their templates/xsds.
>
> Is the a way to put a validation rule at the XSD to do it? Is there a guide for such rules?
>
You can create a class that extends CmsDefaultXmlContentHandler in which
you overwrite the method public CmsXmlContentErrorHandler
resolveValidation(CmsObject cms, I_CmsXmlContentValue value,
CmsXmlContentErrorHandler errorHandler)
You can add validation errors to the errorHandler using
errorHandler.addError(value, "Foo");
The handler can be configured in the XSD in the appinfo section like
this: <handler class="com.something.MyXmlContentHandler" />
The method is triggered for every value in your content so you can check
the name via value.getName() and act accordingly.
Regards
Florian
More information about the opencms-dev
mailing list