AnsweredAssumed Answered

Issue: not possible to update WCM item with formatted file

Question asked by zmicer on Jan 15, 2009
Latest reply on Jan 30, 2009 by mhanisch
Hi, All.

The issue is reproduced at the build of alfresco community for 24-Nov-2008

The case is:
A. create web form, add it to project, then create xml file using web forms section of project.
B then view content of this xml, copy it to disk, re-format it at favorite editor (\t,\n,\r added depending on os and editor)
C. at WCM click "update" button and then try to edit this xml.

Something like that appears

Caused by: java.lang.NullPointerException
at org.chiba.xml.xforms.core.Validator.checkDatatype(
at org.chiba.xml.xforms.core.Validator.validate(
at org.chiba.xml.xforms.core.Validator.validate(
at org.chiba.xml.xforms.core.Validator.validate(
at org.chiba.xml.xforms.core.Model.revalidate(
at org.chiba.xml.xforms.core.Model.performDefault(
at org.chiba.xml.xforms.Container.dispatch(
… 64 more

I have applied the following fix at the chiba sources (seems to be it could be done in other way - to remove thus values \t\r\n when performing update operation - but that is for alfresco developers to think over it). For now just think it could be useful.

/src/org/chiba/xml/xforms/core/ void validate(ModelItem modelItem)

Appropriate code in this method contained before the fix

        if (modelItem.isXSINillable() && (value == null || value.length() == 0)) {

and for our element this was not true, as it had values like "\n\t\t\t". For now this check contains

        if (modelItem.isXSINillable() && (value == null || value.length() == 0) || isTabbed(modelItem.getNode(), value)) {

and function for check is added

    public static final String TABS_LINE_ENDING_FILTER = "^[\\t\\n\\r]+$";
    public static boolean isTabbed(final Object node, final String value) {
        // only for elements
        if (node instanceof Element) {
            if (value.matches(TABS_LINE_ENDING_FILTER)) {
                return true;
        return false;