use of org.javarosa.core.model.GroupDef in project javarosa by opendatakit.
the class XFormParserTest method parseGroupWithNodesetAttrForm.
@Test
public void parseGroupWithNodesetAttrForm() throws IOException {
// Given & When
ParseResult parseResult = parse(r("group-with-nodeset-attr.xml"));
// Then
assertEquals(parseResult.formDef.getTitle(), "group with nodeset attribute");
assertEquals("Number of error messages", 0, parseResult.errorMessages.size());
final TreeReference expectedTreeReference = new TreeReference();
// absolute reference
expectedTreeReference.setRefLevel(-1);
// the instance root
expectedTreeReference.add("data", -1);
// the outer repeat
expectedTreeReference.add("R1", -1);
// the inner group
expectedTreeReference.add("G2", -1);
final IDataReference expectedXPathReference = new XPathReference(expectedTreeReference);
IFormElement groupElement = parseResult.formDef.getChild(0).getChild(0);
assertThat(groupElement, instanceOf(GroupDef.class));
assertThat(((GroupDef) groupElement).getRepeat(), is(false));
assertThat(groupElement.getBind(), is(expectedXPathReference));
}
use of org.javarosa.core.model.GroupDef in project javarosa by opendatakit.
the class FormParseInit method printStuff.
/*
* Makes an 'extremely basic' print out of the xform model.
*/
public String printStuff() {
String stuff = "";
// go to the beginning of the form
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
do {
FormEntryCaption fep = femodel.getCaptionPrompt();
boolean choiceFlag = false;
if (fep.getFormElement() instanceof QuestionDef) {
stuff += "\t[Type:QuestionDef, ";
List<SelectChoice> s = ((QuestionDef) fep.getFormElement()).getChoices();
stuff += "ContainsChoices: " + ((s != null && s.size() > 0) ? "true " : "false") + ", ";
if (s != null && s.size() > 0)
choiceFlag = true;
} else if (fep.getFormElement() instanceof FormDef) {
stuff += "\t[Type:FormDef, ";
} else if (fep.getFormElement() instanceof GroupDef) {
stuff += "\t[Type:GroupDef, ";
} else {
stuff += "\t[Type:Unknown]\n";
continue;
}
stuff += "ID:" + fep.getFormElement().getID() + ", TextID:" + fep.getFormElement().getTextID() + ",InnerText:" + fep.getFormElement().getLabelInnerText();
if (choiceFlag) {
stuff += "] \n\t\t---Choices:" + ((QuestionDef) fep.getFormElement()).getChoices().toString() + "\n";
} else {
stuff += "]\n";
}
} while (fec.stepToNextEvent() != fec.EVENT_END_OF_FORM);
return stuff;
}
Aggregations