We will use the if attribute of an action that is part of the XForms 1.1 specification. We will set up an event that will be triggered every time an instance becomes empty. We will create an action and set the observer attribute to watch for changes in the people instance.

This says to watch the people instance and if there is not a person in the people instance then insert one using the person-template instance.

<htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:xf="http://www.w3.org/2002/xforms"xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes"xmlns:ev="http://www.w3.org/2001/xml-events"><head><title>Test of populating a repeat if it becomes empty</title><xf:modelid="m"><xf:instanceid="people"><peoplexmlns=""><person><name>John</name><email>j...@example.org</email></person><person><name>Bethany</name><email>beth...@example.org</email></person></people></xf:instance><xf:instanceid="person-template"><personxmlns=""><name/><email/></person></xf:instance></xf:model></head><body><h1>Test of populating a repeat if it becomes empty</h1><xf:groupref="instance('people')"><xf:repeatnodeset="person"><xf:inputref="name"><xf:label>Name: </xf:label></xf:input><br/><xf:inputref="email"><xf:label>Email address: </xf:label></xf:input><xf:trigger><xf:label>Delete</xf:label><xf:deleteev:event="DOMActivate"nodeset="."/></xf:trigger></xf:repeat><xf:actionev:event="xforms-delete"ev:observer="people"if="not(person)"><xf:insertorigin="instance('person-template')"context="."/></xf:action></xf:group></body></html>