Community articlecheckDataValidity method
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars


This method tests the validity of the data in an XForms model. By default, the following aspects of XForms validity are analyzed:
  • XML schema validity
  • validity of the type Model Item Property (MIP)
  • xsi:type validity
  • XForms constraints
  • the required but empty condition
checkDataValidity can only be used when XForms processing is turned on. You cannot use this method on a form that has been opened using the readForm method with either the XFDL.UFL_SERVER_SPEED_FLAGS flag or the XFDL.UFL_XFORMS_OFF flag; use the 0 flag or the XFDL.UFL_SERVER_SPEED_FLAGS_WITH_XFORMS flag to keep XForms processing turned on.


   public boolean checkDataValidity(
      int validityFlags,
      String modelID,
      String dataRef,
      StringListHolder listOfFailures
   ) throws UWIException;


Table 1. Method parameters
validityFlagsintSpecifies the behavior of the method. Must be one of the following values:
0 — Analyzes all relevant nodes as specified by modelID and dataRef parameters.
FormNodeP.UFL_IGNORE_RELEVANCE — Analyzes all nodes, including nodes that are not relevant.
FormNodeP.UFL_STOP_ON_FIRST_INVALID — Returns when the first failure is found.
FormNodeP.UFL_IGNORE_MODEL_UPDATES — Ignores the flags that mark a model for a deferred update, and analyzes the data without updating the XForms model.
modelIDStringThe ID of the model that will be analyzed. If null or empty, the default model is analyzed.
dataRefStringAn XPath expression that specifies the nodeset that will be analyzed. If null or empty, all instances in the model are analyzed. The XPath evaluation context and namespace resolution come from the form node, page node, or item node on which the function is called.
listOfFailuresStringListHolderContains a list of XPath expressions when the method returns. Each expression indicates a node that did not pass the validation test.
This parameter can also be null. If null, the method returns when the first failure is found.


true if all nodes that were checked are valid, false if at least one node fails one or more of the validity tests.


This method does not test for out-of-range conditions on xforms:select, xforms:select1, and xforms:range.
In an XForms model that has been flagged for update, the default behaviour of checkDataValidity is to xformsrebuild API 4 JavaCreate New Article, xformsrecalculate API 4 JavaCreate New Article, and xformsrevalidate API 4 JavaCreate New Article the model before analyzing the data.


The following example prompts for a form to open. It then opens the form, tests the validity of the XForms model, and reports the results.
import com.PureEdge.DTK;
import com.PureEdge.IFSSingleton;
import com.PureEdge.error.UWIException;
import com.PureEdge.xfdl.FormNodeP;
import com.PureEdge.StringListHolder;
import com.PureEdge.xfdl.XFDL;
import com.PureEdge.dom.Document;
public class testCheckDataValidity {
    public static void main(String [] args) {
        try {
        // initialize the API
        DTK.initialize("test_dtk", "1.0.0", "8.0.0");
        DataInputStream in = new DataInputStream(;			
        System.out.println("Enter filename: ");
        String fileName = in.readLine();
        // obtain an XFDL object
        XFDL theXFDL = IFSSingleton.getXFDL();
        // read in a form with XForms in 'initialize-only' mode (with fully constructed 
        // model but without the UI)
        FormNodeP theForm = theXFDL.readForm(fileName, XFDL.UFL_SERVER_SPEED_FLAGS_WITH_XFORMS);
        // obtain the list of model 'names' (ID's)
        String models [] =  theForm.getXFormsModels();
        // check & report overall data validity for every model 
        boolean valid = true, modelValid;
        for (int i = 0; i < models.length; i++)
            modelValid = theForm.checkDataValidity(FormNodeP.UFL_STOP_ON_FIRST_INVALID, models [i], null, null); 
            System.out.println("model " + models [i] + " " + (modelValid ? "valid!" : "invalid") );
            valid  = valid && modelValid;
        // report form's overall data validity 
        System.out.println("Form data is " + (valid ? "valid!" : "invalid"));
        // obtain & report the list of invalid data nodes for a default (first) model ignoring node relevance.
        StringListHolder invalidNodes =  new StringListHolder();
        theForm.checkDataValidity(FormNodeP.UFL_IGNORE_RELEVANCE, null, null, invalidNodes);
        if (invalidNodes.value != null)
            for (int i = 0; i < invalidNodes.value.length; i++)
                System.out.println(invalidNodes.value [i]);
        // obtain & report the list of invalid data nodes for a given data sub-tree (here, the 
        // entire 'data0' instance) of the default model
        invalidNodes =  new StringListHolder();
        theForm.checkDataValidity(0, null, "instance('data0')", invalidNodes);
        if (invalidNodes.value != null)
            for (int i = 0; i < invalidNodes.value.length; i++)
                System.out.println(invalidNodes.value [i]);
        catch (Exception e) 

Parent topic:
FormNodeP class