(self, reference_id, case_type, ref, relationship='child')
When an index points to a parent case, its relationship attribute is
        set to "child". When it points to a host case, relationship is set to
        "extension".
When an index points to a parent case, its relationship attribute is
        set to "child". When it points to a host case, relationship is set to
        "extension".
When an index points to a parent case its relationship attribute is set to child . When it points to a host case relationship is set to extension .
def add_index_ref(self, reference_id, case_type, ref, relationship='child'):
        """
        When an index points to a parent case, its relationship attribute is
        set to "child". When it points to a host case, relationship is set to
        "extension".
        """
        index_node = self.elem.find('{cx2}index'.format(**namespaces))
        if index_node is None:
            index_node = make_case_elem('index')
            self.elem.append(index_node)

        valid_relationships = ['child', 'extension', 'question']
        if relationship not in valid_relationships:
            raise CaseError('Valid values for an index relationship are: {}'.format(
                ', '.join(['"{}"'.format(r) for r in valid_relationships])))
        if relationship == 'child':
            case_index = make_case_elem(reference_id, {'case_type': case_type})
        elif relationship == 'extension':
            case_index = make_case_elem(reference_id, {'case_type': case_type, 'relationship': relationship})
        elif relationship == 'question':
            case_index = make_case_elem(reference_id, {'case_type': case_type, 'relationship': '@relationship'})

        index_node.append(case_index)

        self.xform.add_bind(
            nodeset='{path}case/index/{ref}'.format(path=self.path, ref=reference_id),
            calculate=ref,
        )
def add_index_ref ( self , reference_id , case_type , ref , relationship = 'child' ) : index_node = self . elem . find ( '{cx2}index' . format ( * * namespaces ) ) if index_node is None : index_node = make_case_elem ( 'index' ) self . elem . append ( index_node ) valid_relationships = [ 'child' , 'extension' , 'question' ] if relationship not in valid_relationships : raise CaseError ( 'Valid values for an index relationship are: {}' . format ( ', ' . join ( [ '"{}"' . format ( r ) for r in valid_relationships ] ) ) ) if relationship == 'child' : case_index = make_case_elem ( reference_id , { 'case_type' : case_type } ) elif relationship == 'extension' : case_index = make_case_elem ( reference_id , { 'case_type' : case_type , 'relationship' : relationship } ) elif relationship == 'question' : case_index = make_case_elem ( reference_id , { 'case_type' : case_type , 'relationship' : '@relationship' } ) index_node . append ( case_index ) self . xform . add_bind ( nodeset = '{path}case/index/{ref}' . format ( path = self . path , ref = reference_id ) , calculate = ref , )