Exemple #1
0
 public FormDefinition parse(String xForm, String configurationName)
     throws XPathExpressionException {
   InputSource inputSource = new InputSource(new ByteArrayInputStream(xForm.getBytes()));
   Node root = getRoot(inputSource);
   FormDefinition formDefinition = parseXForm(configurationName, root);
   formDefinition.setXform(xForm);
   return formDefinition;
 }
Exemple #2
0
  protected FormDefinition parseXForm(String configurationName, Node root)
      throws XPathExpressionException {
    Map<String, FormElement> formElementMap = new HashMap<>();
    String title = xPath.compile(TITLE_PATH).evaluate(root);
    FormDefinition formDefinition = new FormDefinition(configurationName);
    formDefinition.setTitle(title);

    Node node = (Node) xPath.compile(FORM_ELEMENTS_PARENT_PATH).evaluate(root, XPathConstants.NODE);
    String uri = node.getNodeName();
    NodeList formElementsList = node.getChildNodes();

    recursivelyAddFormElements(formElementMap, formElementsList, SLASH + uri);
    NodeList binds = (NodeList) xPath.compile(BIND_ELEMENTS).evaluate(root, XPathConstants.NODESET);
    addBindInformationToFormFields(formElementMap, binds);
    removeFormNameFromLabel(formElementMap);
    formDefinition.setFormElements(createFormElementListFromMap(formElementMap));
    return formDefinition;
  }