/// <summary> For the current index: Checks whether the index represents a node which /// should exist given a non-interactive repeat, along with a count for that /// repeat which is beneath the dynamic level specified. /// /// If this index does represent such a node, the new model for the repeat is /// created behind the scenes and the index for the initial question is /// returned. /// /// Note: This method will not prevent the addition of new repeat elements in /// the interface, it will merely use the xforms repeat hint to create new /// nodes that are assumed to exist /// /// </summary> /// <param name="index">The index to be evaluated as to whether the underlying model is /// hinted to exist /// </param> private void createModelIfNecessary(FormIndex index) { if (index.InForm) { IFormElement e = Form.getChild(index); if (e is GroupDef) { GroupDef g = (GroupDef)e; if (g.Repeat && g.CountReference != null) { // Lu Gram: repeat count XPath needs to be contextualized for nested repeat groups TreeReference countRef = FormInstance.unpackReference(g.CountReference); TreeReference contextualized = countRef.contextualize(index.Reference); IAnswerData count = Form.MainInstance.resolveReference(contextualized).getValue(); if (count != null) { long fullcount = ((System.Int32)count.Value); TreeReference ref_Renamed = Form.getChildInstanceRef(index); TreeElement element = Form.MainInstance.resolveReference(ref_Renamed); if (element == null) { if (index.getTerminal().InstanceIndex < fullcount) { try { Form.createNewRepeat(index); } catch (InvalidReferenceException ire) { SupportClass.WriteStackTrace(ire, Console.Error); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new System.SystemException("Invalid Reference while creting new repeat!" + ire.Message); } } } } } } } }