Microsoft KB Archive/832122

= How to implement a recursive data source structure and a view in Office InfoPath 2003 =

Article ID: 832122

Article Last Modified on 7/28/2006

-

APPLIES TO


 * Microsoft Office InfoPath 2003

-



SUMMARY
Microsoft Office InfoPath 2003 supports an arbitrarily deep recursive data source by using the Reference command of a group in the Data Source task pane.

This article provides step-by-step instructions for two methods that you can use to create a recursive data source structure and a view in InfoPath 2003:
 * Method 1: Modify the Manifest.xsf file
 * Method 2: Use script

In this example, the data source and the view are loosely modeled on a simple genealogical family tree.



Creating the form
Note The steps to create the form are the same for both method 1 and method 2.  Start Microsoft Office InfoPath 2003. On the File menu, click Design a Form. In the Design a Form task pane, click New Blank Form. On the View menu, click Data Source. The Data Source task pane opens. Right-click myFields, and then click Add. The Add Field or Group dialog box opens. Set the following properties for the Genealogy group, and then click OK:  In the Name box, type Genealogy.</li> In the Type list, click Group.</li> Select the Repeating check box.</li></ol> </li> Add the following elements to the Genealogy group: FirstName, LastName, SpouseFirstName, and SpouseLastName. For example, to add the FirstName element, follow these steps: <ol style="list-style-type: lower-alpha;"> In the Data Source pane, right-click the Genealogy group, and then click Add. The Add Field or Group dialog box opens.</li> In the Name box, type FirstName, and then click OK.</li> Repeat step a and step b to add the LastName element, the SpouseFirstName element, and the SpouseLastName element.</li></ol> </li> Right-click the Genealogy group that you added earlier, and then click Reference.</li> In the Reference Field or Group dialog box, click the Genealogy group, and then click OK.</li></ol>

Creating the view
<ol> Use the drag-and-drop technique to copy the top-level Genealogy group to the form. Just click the Genealogy node that appears directly below myFields in the Data source list, and then drag the group on to the form. Select Repeating Section as the control type.</li> Use the drag-and-drop technique to copy the elements from the top level Genealogy group on to the Genealogy Section control on the form. The name elements are: FirstName, LastName, SpouseFirstName and SpouseLastName.</li> Use the drag-and-drop technique to copy the second level Genealogy group into the Genealogy Section control on the form. Select Repeating Section with Controls as the control type.</li> Save the template as Genealogy.xsn. To do so, follow these steps: <ol style="list-style-type: lower-alpha;"> On the File menu, click Save As.</li> In the dialog box, click the Save button, and then select the folder location where you want to save the template.</li> Type Genealogy.xsn in the File name box, and then click Save.</li></ol> </li> On the File menu, click Extract Form Files, select a folder to extract the files to, and then click OK.</li> <li>Close InfoPath.</li> <li>Locate the folder where the files were extracted.</li></ol>

Modifying the Manifest.xsf file
<ol> <li>Open the Manifest.xsf file by using an XML editor such as Notepad or Visual Studio .NET.</li> <li> In the <xsf:editing> section of the file, locate the <xsf:xmlToEdit> element that corresponds to the recursive Genealogy group. Modify the item and the container attributes according to the following absolute paths that InfoPath creates: <xsf:xmlToEdit name=&quot;Genealogy_2&quot; item=&quot;/my:myFields/my:Genealogy/my:Genealogy&quot; container=&quot;/my:myFields/my:Genealogy&quot;> Modify the previous path information to the following relative paths: <xsf:xmlToEdit name=&quot;Genealogy_2&quot; item=&quot;my:Genealogy&quot; container=&quot;my:Genealogy&quot;> </li> <li>Copy the <xsf:xmlToEdit> element that corresponds to the recursive Genealogy group to the clipboard, and then paste the <xsf:xmlToEdit> element below the original element.</li> <li> Rename the <xsf:xmlToEdit> element that you just pasted, and then change the container attribute to refer to only Genealogy elements that have recursive children. For example, the following code is changed: <xsf:xmlToEdit name=&quot;Genealogy_2&quot; item=&quot;my:Genealogy&quot; container=&quot;my:Genealogy&quot;> <xsf:editWith caption=&quot;Genealogy&quot; xd:autogeneration=&quot;template&quot; component=&quot;xCollection&quot;> <xsf:fragmentToInsert> <xsf:chooseFragment> <my:Genealogy> <my:FirstName></my:FirstName> <my:LastName></my:LastName> <my:SpouseFirstName></my:SpouseFirstName> <my:SpouseLastName></my:SpouseLastName> </my:Genealogy> </xsf:chooseFragment> </xsf:fragmentToInsert> </xsf:editWith> </xsf:xmlToEdit> The previous code is changed to the following code: <xsf:xmlToEdit name=&quot;Genealogy_3&quot; item=&quot;my:Genealogy&quot; container=&quot;my:Genealogy[my:Genealogy]&quot;> <xsf:editWith caption=&quot;Genealogy&quot; xd:autogeneration=&quot;template&quot; component=&quot;xCollection&quot;> <xsf:fragmentToInsert> <xsf:chooseFragment> <my:Genealogy> <my:FirstName></my:FirstName> <my:LastName></my:LastName> <my:SpouseFirstName></my:SpouseFirstName> <my:SpouseLastName></my:SpouseLastName> </my:Genealogy> </xsf:chooseFragment> </xsf:fragmentToInsert> </xsf:editWith> </xsf:xmlToEdit> </li> <li>Locate the <xsf:menuArea name=&quot;msoInsertMenu&quot;> element in the manifest file.</li> <li> Add menu items for the new xmlToEdit section that you added in the previous step. <xsf:button action=&quot;xCollection::insert&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Genealogy&quot;></xsf:button> <xsf:button action=&quot;xCollection::remove&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Remove Genealogy&quot;></xsf:button> </li> <li>Locate the <xsf:menuArea name=&quot;msoStructuralEditingContextMenu&quot;> element in the Manifest.xsf file.</li> <li> Add menu items for the new xmlToEdit section that you added in the previous step. <xsf:button action=&quot;xCollection::insertBefore&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Insert Genealogy above&quot; showIf=&quot;immediate&quot;></xsf:button> <xsf:button action=&quot;xCollection::insertAfter&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Insert Genealogy below&quot; showIf=&quot;immediate&quot;></xsf:button> <xsf:button action=&quot;xCollection::remove&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Remove Genealogy&quot; showIf=&quot;immediate&quot;></xsf:button> <xsf:button action=&quot;xCollection::insert&quot; xmlToEdit=&quot;Genealogy_3&quot; caption=&quot;Insert Genealogy&quot; showIf=&quot;immediate&quot;></xsf:button> </li> <li>Save and close the Manifest.xsf file.</li></ol>

Modifying the .xsl transform file of the view
<ol> <li>Open the View1.xsl file by using an XML editor such as Notepad or Visual Studio .NET.</li> <li> Find the <xsl:template> element that corresponds to the top level recursive Genealogy group.

Modify the template to recursively apply itself for each recursive group element instead of applying the second template. For example, the following template is changed: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_1&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 100%&quot; align=&quot;left&quot; xd:xctname=&quot;RepeatingSection&quot; xd:CtrlId=&quot;CTRL6&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL7&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL8&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL9&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL10&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> <xsl:apply-templates select=&quot;my:Genealogy&quot; mode=&quot;_2&quot;/> </xsl:template> The previous template is changed to the following: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_1&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 100%&quot; align=&quot;left&quot; xd:xctname=&quot;RepeatingSection&quot; xd:CtrlId=&quot;CTRL6&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL7&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL8&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL9&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL10&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> <xsl:apply-templates select=&quot;my:Genealogy&quot; mode=&quot;_1&quot;/> </xsl:template> </li> <li> Find the <xsl:template> element that corresponds to the second level recursive Genealogy group, and then remove the element.

For example, the following template is removed: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_2&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 100%&quot; align=&quot;left&quot; xd:xctname=&quot;RepeatingSection&quot; xd:CtrlId=&quot;CTRL6&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL7&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL8&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL9&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL10&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> </xsl:template> </li> <li>Save and close the View1.xsl file.</li> <li>Right-click the Manifest.xsf file, and then click Design.</li> <li>To repackage the component files of the form template back into an .xsn file, click either Publish or Save As on the File menu in InfoPath.

Note If you change the view after you manually modify the View1.xsl file, InfoPath does not save the changes to the View1.xsl file. Microsoft recommends the following: <ul> <li>Do not change the view after you manually modify the View1.xsl transform file of the view.</li> <li>Alternatively, modify the template to use the xd:preserve mode. This mode tells InfoPath to keep the changes intact.</li></ul> </li></ol>

Test the form
In InfoPath, click the Preview Form button on the Standard toolbar. Notice that you can enter parent and child information in the form. To insert multiple children for a parent, right-click each child field, and then click Insert Genealogy.

Creating the form
Note The steps to create the form are the same for both method 1 and method 2. <ol> <li>Start Microsoft Office InfoPath 2003.</li> <li>On the File menu, click Design a Form.</li> <li>In the Design a Form task pane, click New Blank Form.</li> <li>On the View menu, click Data Source. The Data Source task pane opens.</li> <li>Right-click myFields, and then click Add. The Add Field or Group dialog box opens.</li> <li>Set the following properties for the Genealogy group, and then click OK: <ol style="list-style-type: lower-alpha;"> <li>In the Name box, type Genealogy.</li> <li>In the Type list, click Group.</li> <li>Select the Repeating check box.</li></ol> </li> <li>Add the following elements to the Genealogy group: FirstName, LastName, SpouseFirstName, and SpouseLastName. For example, to add the FirstName element, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In the Data Source pane, right-click the Genealogy group, and then click Add. The Add Field or Group dialog box opens.</li> <li>In the Name box, type FirstName, and then click OK.</li> <li>Repeat step a and step b to add the LastName element, the SpouseFirstName element, and the SpouseLastName element.</li></ol> </li> <li>Right-click the Genealogy group that you added earlier, and then click Reference.</li> <li>In the Reference Field or Group dialog box, click the Genealogy group, and then click OK.</li></ol>

Creating the view
<ol> <li>Use the drag-and-drop technique to copy the top-level Genealogy group to the form. Just click the Genealogy node that appears directly below myFields in the Data source list, and then drag the group on to the form. Select Repeating Section as the control type.</li> <li>Use the drag-and-drop technique to copy the elements from the top level Genealogy group on to the Genealogy Section control on the form. The name elements are: FirstName, LastName, SpouseFirstName and SpouseLastName.</li> <li>Add command buttons to the Genealogy Section control of the form. For example, to add the Insert Node button in InfoPath, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the View menu, click Design Tasks.</li> <li>In the Design Tasks task pane, click Controls.</li> <li>Use the drag-and-drop technique to copy the Button control to the Genealogy Section control on the form.</li> <li>Right-click the Button control, and then click Button Properties. The Button Properties dialog box appears, and the General tab is visible.</li> <li>In the Label box, type Insert Node. In the ID box, type Insert_Node, and then click OK.</li> <li>Repeat steps c through e to add the Remove Node button, the Copy Node button, and the Paste Node button.</li></ol> </li> <li>Add the code that the command buttons will execute. <ol style="list-style-type: lower-alpha;"> <li>On the Tools menu in InfoPath, click Script, and then click Microsoft Script Editor.</li> <li> Paste the following code at the end of the script that is displayed in Microsoft Script Editor. var copiedNode;

function Remove_Node::OnClick(eventObj) {   eventObj.Source.parentNode.removeChild(eventObj.Source); }

function Copy_Node::OnClick(eventObj) {   copiedNode = eventObj.Source.cloneNode(true); }

function Paste_Node::OnClick(eventObj) {   eventObj.Source.appendChild(copiedNode); }

function Insert_Node::OnClick(eventObj) {   var newnode = eventObj.Source.cloneNode(true); var fragnodes = newnode.selectNodes(&quot;/my:Genealogy&quot;); if(fragnodes.length>=1) {       for(i=0;i<fragnodes.length;i++) {           newnode.removeChild(fragnodes.item(i)); }   }

newnode.selectSingleNode(&quot;/my:FirstName&quot;).text = &quot;&quot;; newnode.selectSingleNode(&quot;/my:LastName&quot;).text = &quot;&quot;; newnode.selectSingleNode(&quot;/my:SpouseFirstName&quot;).text = &quot;&quot;; newnode.selectSingleNode(&quot;/my:SpouseLastName&quot;).text = &quot;&quot; eventObj.Source.appendChild(newnode); } </li> <li>Save the changes, and then close Microsoft Script Editor.</li></ol> </li> <li>On the View menu in InfoPath, click Data Source.</li> <li>In the Data Source task pane, use the drag-and-drop technique to copy the second level Genealogy group into the Genealogy Section control on the form. Select Repeating Section with Controls as the control type.</li> <li>Save and name the template Genealogy_Script.xsn .</li> <li>On the File menu, click Extract Form Files, and then select a folder to extract the files to.</li> <li>Close InfoPath.</li> <li>Locate the folder where the files were extracted.</li></ol>

Modifying the .xsl transform file of the view
<ol> <li>Open the View1.xsl file by using an XML editor such as Notepad or Visual Studio .NET.</li> <li> Find the <xsl:template> element that corresponds to the top level recursive Genealogy group. Modify the template to recursively apply itself for each recursive group element instead of applying the second template.

For example, the following template is changed: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_1&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 542px&quot; align=&quot;left&quot; xd:xctname=&quot;RepeatingSection&quot; xd:CtrlId=&quot;CTRL1&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL5&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL6&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL7&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL8&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 114px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Insert Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Insert_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 141px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;1&quot; value=&quot;Remove Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Remove_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 102px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Copy Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Copy_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 119px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;6&quot; value=&quot;Paste Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Paste_Node&quot; tabIndex=&quot;0&quot;/> <xsl:apply-templates select=&quot;my:Genealogy&quot; mode=&quot;_2&quot;/> </xsl:template> The previous template is changed to appear as follows: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_1&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 542px&quot; align=&quot;left&quot; xd:xctname=&quot;RepeatingSection&quot; xd:CtrlId=&quot;CTRL1&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL5&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL6&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL7&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; xd:xctname=&quot;PlainText&quot; xd:CtrlId=&quot;CTRL8&quot; tabIndex=&quot;0&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 114px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Insert Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Insert_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 141px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;1&quot; value=&quot;Remove Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Remove_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 102px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Copy Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Copy_Node&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 119px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;6&quot; value=&quot;Paste Node&quot; xd:xctname=&quot;Button&quot; xd:CtrlId=&quot;Paste_Node&quot; tabIndex=&quot;0&quot;/> <xsl:apply-templates select=&quot;my:Genealogy&quot; mode=&quot;_1&quot;/> </xsl:template> </li> <li> Find the <xsl:template> element that corresponds to the second level recursive Genealogy group, and then remove the <xsl:template> element.

For example, the following template is removed: <xsl:template match=&quot;my:Genealogy&quot; mode=&quot;_2&quot;> <div class=&quot;xdRepeatingSection xdRepeating&quot; title=&quot;&quot; style=&quot;MARGIN-BOTTOM: 6px; WIDTH: 542px&quot; align=&quot;left&quot; xd:CtrlId=&quot;CTRL1&quot; xd:xctname=&quot;RepeatingSection&quot; tabIndex=&quot;-1&quot;> First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; tabIndex=&quot;0&quot; xd:CtrlId=&quot;CTRL5&quot; xd:xctname=&quot;PlainText&quot; xd:binding=&quot;my:FirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:FirstName&quot;/> Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; tabIndex=&quot;0&quot; xd:CtrlId=&quot;CTRL6&quot; xd:xctname=&quot;PlainText&quot; xd:binding=&quot;my:LastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:LastName&quot;/> Spouse First Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; tabIndex=&quot;0&quot; xd:CtrlId=&quot;CTRL7&quot; xd:xctname=&quot;PlainText&quot; xd:binding=&quot;my:SpouseFirstName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseFirstName&quot;/> Spouse Last Name: <span class=&quot;xdTextBox&quot; hideFocus=&quot;1&quot; title=&quot;&quot; tabIndex=&quot;0&quot; xd:CtrlId=&quot;CTRL8&quot; xd:xctname=&quot;PlainText&quot; xd:binding=&quot;my:SpouseLastName&quot; style=&quot;WIDTH: 130px&quot;> <xsl:value-of select=&quot;my:SpouseLastName&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 114px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Insert Node&quot; xd:CtrlId=&quot;Insert_Node&quot; xd:xctname=&quot;Button&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 141px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;1&quot; value=&quot;Remove Node&quot; xd:CtrlId=&quot;Remove_Node&quot; xd:xctname=&quot;Button&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 102px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;3&quot; value=&quot;Copy Node&quot; xd:CtrlId=&quot;Copy_Node&quot; xd:xctname=&quot;Button&quot; tabIndex=&quot;0&quot;/> <input class=&quot;langFont&quot; title=&quot;&quot; style=&quot;WIDTH: 119px; HEIGHT: 30px&quot; type=&quot;button&quot; size=&quot;6&quot; value=&quot;Paste Node&quot; xd:CtrlId=&quot;Paste_Node&quot; xd:xctname=&quot;Button&quot; tabIndex=&quot;0&quot;/> </xsl:template> </li> <li>Save and close the View1.xsl file.</li> <li>Right-click the Manifest.xsf file, and then click Design.</li> <li>To repackage the component files of the form template back into an .xsn file, click either Publish or Save As on the File menu in InfoPath.

Note If you change the view after you manually modify the View1.xsl file, InfoPath does not save the changes to the View1.xsl file. Microsoft recommends the following: <ul> <li>Do not change the view after you manually modify the View1.xsl transform file of the view.</li> <li>Alternatively, modify the template to use the xd:preserve mode. This mode tells InfoPath to keep the changes intact.</li></ul> </li></ol>

Test the form
In InfoPath, click the Preview Form button on the Standard toolbar. Notice that you can enter parent and child information in the form.

To insert multiple children for a specific parent, you can copy and paste nodes if you want. Click the appropriate button: the Insert Node button, the Copy Node button, or the Paste Node button.

To remove a node, click the Remove Node button in the node that you want to delete.

Keywords: kbhowto KB832122

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.