How to implement a recursive data source structure and a view in Office InfoPath 2003 (832122)



The information in this article 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.

MORE INFORMATION

Method 1: Modify the Manifest.xsf file

Creating the form

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

Creating the view

  1. 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.
  2. 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.
  3. 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.
  4. Save the template as Genealogy.xsn. To do so, follow these steps:
    1. On the File menu, click Save As.
    2. In the dialog box, click the Save button, and then select the folder location where you want to save the template.
    3. Type Genealogy.xsn in the File name box, and then click Save.
  5. On the File menu, click Extract Form Files, select a folder to extract the files to, and then click OK.
  6. Close InfoPath.
  7. Locate the folder where the files were extracted.

Modifying the Manifest.xsf file

  1. Open the Manifest.xsf file by using an XML editor such as Notepad or Visual Studio .NET.
  2. 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="Genealogy_2" item="/my:myFields/my:Genealogy/my:Genealogy" 
       container="/my:myFields/my:Genealogy">
    Modify the previous path information to the following relative paths:
    <xsf:xmlToEdit name="Genealogy_2" item="my:Genealogy" container="my:Genealogy">
    
  3. 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.
  4. 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="Genealogy_2" item="my:Genealogy" container="my:Genealogy">
       <xsf:editWith caption="Genealogy" xd:autogeneration="template" 
          component="xCollection">
          <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="Genealogy_3" item="my:Genealogy" 
       container="my:Genealogy[my:Genealogy]">
       <xsf:editWith caption="Genealogy" xd:autogeneration="template" 
          component="xCollection">
          <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>
    
  5. Locate the <xsf:menuArea name="msoInsertMenu"> element in the manifest file.
  6. Add menu items for the new xmlToEdit section that you added in the previous step.
    <xsf:button action="xCollection::insert" xmlToEdit="Genealogy_3" 
       caption="Genealogy"></xsf:button>
    <xsf:button action="xCollection::remove" xmlToEdit="Genealogy_3" 
       caption="Remove Genealogy"></xsf:button>
  7. Locate the <xsf:menuArea name="msoStructuralEditingContextMenu"> element in the Manifest.xsf file.
  8. Add menu items for the new xmlToEdit section that you added in the previous step.
    <xsf:button action="xCollection::insertBefore" xmlToEdit="Genealogy_3" 
       caption="Insert Genealogy above" showIf="immediate"></xsf:button>
    <xsf:button action="xCollection::insertAfter" xmlToEdit="Genealogy_3" 
       caption="Insert Genealogy below" showIf="immediate"></xsf:button>
    <xsf:button action="xCollection::remove" xmlToEdit="Genealogy_3" 
       caption="Remove Genealogy" showIf="immediate"></xsf:button>
    <xsf:button action="xCollection::insert" xmlToEdit="Genealogy_3" 
       caption="Insert Genealogy" showIf="immediate"></xsf:button>
    
  9. Save and close the Manifest.xsf file.

Modifying the .xsl transform file of the view

  1. Open the View1.xsl file by using an XML editor such as Notepad or Visual Studio .NET.
  2. 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="my:Genealogy" mode="_1">
       <div class="xdRepeatingSection xdRepeating" title="" 
          style="MARGIN-BOTTOM: 6px; WIDTH: 100%" align="left" 
          xd:xctname="RepeatingSection" xd:CtrlId="CTRL6" tabIndex="-1">
          <div>First Name: <span class="xdTextBox" hideFocus="1" title="" 
             xd:xctname="PlainText" xd:CtrlId="CTRL7" tabIndex="0" 
             xd:binding="my:FirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:FirstName"/>
    </span>
       </div>
       <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
          xd:xctname="PlainText" xd:CtrlId="CTRL8" tabIndex="0" 
          xd:binding="my:LastName" style="WIDTH: 130px">
       <xsl:value-of select="my:LastName"/>
    </span>
       </div>
       <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" title="" 
          xd:xctname="PlainText" xd:CtrlId="CTRL9" tabIndex="0" 
          xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseFirstName"/>
    </span>
       </div>
       <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" title="" 
          xd:xctname="PlainText" xd:CtrlId="CTRL10" tabIndex="0" 
          xd:binding="my:SpouseLastName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseLastName"/>
    </span>
          </div>
          <div><xsl:apply-templates select="my:Genealogy" mode="_2"/>
          </div>
       </div>
    </xsl:template>
    
    The previous template is changed to the following:
    <xsl:template match="my:Genealogy" mode="_1">
       <div class="xdRepeatingSection xdRepeating" title="" 
          style="MARGIN-BOTTOM: 6px; WIDTH: 100%" align="left" 
          xd:xctname="RepeatingSection" xd:CtrlId="CTRL6" tabIndex="-1">
          <div>First Name: <span class="xdTextBox" hideFocus="1" title="" 
             xd:xctname="PlainText" xd:CtrlId="CTRL7" tabIndex="0" 
             xd:binding="my:FirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:FirstName"/>
    </span>
          </div>
          <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
             xd:xctname="PlainText" xd:CtrlId="CTRL8" tabIndex="0" 
             xd:binding="my:LastName" style="WIDTH: 130px">
       <xsl:value-of select="my:LastName"/>
    </span>
          </div>
          <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" 
             title="" xd:xctname="PlainText" xd:CtrlId="CTRL9" tabIndex="0" 
             xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseFirstName"/>
    </span>
          </div>
          <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" 
             title="" xd:xctname="PlainText" xd:CtrlId="CTRL10" tabIndex="0" 
             xd:binding="my:SpouseLastName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseLastName"/>
    </span>
          </div>
          <div><xsl:apply-templates select="my:Genealogy" mode="_1"/>
          </div>
       </div>
    </xsl:template>
    
  3. 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="my:Genealogy" mode="_2">
       <div class="xdRepeatingSection xdRepeating" title="" 
          style="MARGIN-BOTTOM: 6px; WIDTH: 100%" align="left" 
          xd:xctname="RepeatingSection" xd:CtrlId="CTRL6" tabIndex="-1">
          <div>First Name: <span class="xdTextBox" hideFocus="1" title="" 
             xd:xctname="PlainText" xd:CtrlId="CTRL7" tabIndex="0" 
             xd:binding="my:FirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:FirstName"/>
    </span>
          </div>
          <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
             xd:xctname="PlainText" xd:CtrlId="CTRL8" tabIndex="0" 
             xd:binding="my:LastName" style="WIDTH: 130px">
       <xsl:value-of select="my:LastName"/>
    </span>
          </div>
          <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" 
             title="" xd:xctname="PlainText" xd:CtrlId="CTRL9" tabIndex="0" 
             xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseFirstName"/>
    </span>
          </div>
          <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" 
             title="" xd:xctname="PlainText" xd:CtrlId="CTRL10" tabIndex="0" 
             xd:binding="my:SpouseLastName" style="WIDTH: 130px">
       <xsl:value-of select="my:SpouseLastName"/>
    </span>
          </div>
          <div> </div>
       </div>
    </xsl:template>
    
  4. Save and close the View1.xsl file.
  5. Right-click the Manifest.xsf file, and then click Design.
  6. 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:
    • Do not change the view after you manually modify the View1.xsl transform file of the view.
    • Alternatively, modify the template to use the xd:preserve mode. This mode tells InfoPath to keep the changes intact.

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.

Method 2: Use script

Creating the form

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

Creating the view

  1. 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.
  2. 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.
  3. Add command buttons to the Genealogy Section control of the form. For example, to add the Insert Node button in InfoPath, follow these steps:
    1. On the View menu, click Design Tasks.
    2. In the Design Tasks task pane, click Controls.
    3. Use the drag-and-drop technique to copy the Button control to the Genealogy Section control on the form.
    4. Right-click the Button control, and then click Button Properties. The Button Properties dialog box appears, and the General tab is visible.
    5. In the Label box, type Insert Node. In the ID box, type Insert_Node, and then click OK.
    6. Repeat steps c through e to add the Remove Node button, the Copy Node button, and the Paste Node button.
  4. Add the code that the command buttons will execute.
    1. On the Tools menu in InfoPath, click Script, and then click Microsoft Script Editor.
    2. 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("/my:Genealogy");
      	if(fragnodes.length>=1)
      	{
      		for(i=0;i<fragnodes.length;i++)
      		{
      			newnode.removeChild(fragnodes.item(i));
      		}
      	}
      
      	newnode.selectSingleNode("/my:FirstName").text = "";
      	newnode.selectSingleNode("/my:LastName").text = "";
      	newnode.selectSingleNode("/my:SpouseFirstName").text = "";
      	newnode.selectSingleNode("/my:SpouseLastName").text = ""
      	eventObj.Source.appendChild(newnode);	
      }
    3. Save the changes, and then close Microsoft Script Editor.
  5. On the View menu in InfoPath, click Data Source.
  6. 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.
  7. Save and name the template Genealogy_Script.xsn.
  8. On the File menu, click Extract Form Files, and then select a folder to extract the files to.
  9. Close InfoPath.
  10. Locate the folder where the files were extracted.

Modifying the .xsl transform file of the view

  1. Open the View1.xsl file by using an XML editor such as Notepad or Visual Studio .NET.
  2. 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="my:Genealogy" mode="_1">
        <div class="xdRepeatingSection xdRepeating" title="" 
             style="MARGIN-BOTTOM: 6px; WIDTH: 542px" align="left" 
             xd:xctname="RepeatingSection" xd:CtrlId="CTRL1" tabIndex="-1">
            <div>First Name: <span class="xdTextBox" hideFocus="1" title=""
                xd:xctname="PlainText" xd:CtrlId="CTRL5" tabIndex="0" 
                xd:binding="my:FirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:FirstName"/>
    </span>
            </div>
            <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
               xd:xctname="PlainText" xd:CtrlId="CTRL6" tabIndex="0" 
               xd:binding="my:LastName" style="WIDTH: 130px">
        <xsl:value-of select="my:LastName"/>
    </span>
            </div>
            <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" 
                title="" xd:xctname="PlainText" xd:CtrlId="CTRL7" tabIndex="0" 
                xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseFirstName"/>
    </span>
            </div>
            <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" 
               title="" xd:xctname="PlainText" xd:CtrlId="CTRL8" tabIndex="0" 
               xd:binding="my:SpouseLastName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseLastName"/>
    </span>
            </div>
            <div><input class="langFont" title="" 
                style="WIDTH: 114px; HEIGHT: 30px" type="button" size="3" 
                value="Insert Node" xd:xctname="Button" xd:CtrlId="Insert_Node" 
                tabIndex="0"/>
                <input class="langFont" title="" style="WIDTH: 141px; HEIGHT: 30px" 
                   type="button" size="1" value="Remove Node" xd:xctname="Button" 
                   xd:CtrlId="Remove_Node" tabIndex="0"/>
                <input class="langFont" title="" style="WIDTH: 102px; HEIGHT: 30px" 
                   type="button" size="3" value="Copy Node" xd:xctname="Button" 
                   xd:CtrlId="Copy_Node" tabIndex="0"/>
                <input class="langFont" title="" style="WIDTH: 119px; HEIGHT: 30px" 
                   type="button" size="6" value="Paste Node" xd:xctname="Button" 
                   xd:CtrlId="Paste_Node" tabIndex="0"/>
            </div>
            <div><xsl:apply-templates select="my:Genealogy" mode="_2"/>
            </div>
            <div> </div>
            </div>
    </xsl:template>
    
    The previous template is changed to appear as follows:
    <xsl:template match="my:Genealogy" mode="_1">
        <div class="xdRepeatingSection xdRepeating" title="" 
           style="MARGIN-BOTTOM: 6px; WIDTH: 542px" align="left" 
           xd:xctname="RepeatingSection" xd:CtrlId="CTRL1" tabIndex="-1">
            <div>First Name: <span class="xdTextBox" hideFocus="1" title="" 
               xd:xctname="PlainText" xd:CtrlId="CTRL5" tabIndex="0" 
               xd:binding="my:FirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:FirstName"/>
    </span>
            </div>
            <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
               xd:xctname="PlainText" xd:CtrlId="CTRL6" tabIndex="0" 
               xd:binding="my:LastName" style="WIDTH: 130px">
        <xsl:value-of select="my:LastName"/>
    </span>
            </div>
            <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" 
               title="" xd:xctname="PlainText" xd:CtrlId="CTRL7" tabIndex="0" 
               xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseFirstName"/>
    </span>
            </div>
            <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" 
               title="" xd:xctname="PlainText" xd:CtrlId="CTRL8" tabIndex="0" 
               xd:binding="my:SpouseLastName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseLastName"/>
    </span>
            </div>
            <div><input class="langFont" title="" 
               style="WIDTH: 114px; HEIGHT: 30px" type="button" size="3" 
               value="Insert Node" xd:xctname="Button" xd:CtrlId="Insert_Node" 
               tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 141px; HEIGHT: 30px" 
                  type="button" size="1" value="Remove Node" xd:xctname="Button" 
                  xd:CtrlId="Remove_Node" tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 102px; HEIGHT: 30px" 
                  type="button" size="3" value="Copy Node" xd:xctname="Button" 
                  xd:CtrlId="Copy_Node" tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 119px; HEIGHT: 30px" 
                  type="button" size="6" value="Paste Node" xd:xctname="Button" 
                  xd:CtrlId="Paste_Node" tabIndex="0"/>
            </div>
            <div><xsl:apply-templates select="my:Genealogy" mode="_1"/>
            </div>
            <div> </div>
            </div>
    </xsl:template>
    
  3. 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="my:Genealogy" mode="_2">
        <div class="xdRepeatingSection xdRepeating" title="" 
           style="MARGIN-BOTTOM: 6px; WIDTH: 542px" align="left" xd:CtrlId="CTRL1" 
           xd:xctname="RepeatingSection" tabIndex="-1">
            <div>First Name: <span class="xdTextBox" hideFocus="1" title="" 
               tabIndex="0" xd:CtrlId="CTRL5" xd:xctname="PlainText" 
               xd:binding="my:FirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:FirstName"/>
    </span>
            </div>
            <div>Last Name: <span class="xdTextBox" hideFocus="1" title="" 
               tabIndex="0" xd:CtrlId="CTRL6" xd:xctname="PlainText" 
               xd:binding="my:LastName" style="WIDTH: 130px">
        <xsl:value-of select="my:LastName"/>
    </span>
            </div>
            <div>Spouse First Name: <span class="xdTextBox" hideFocus="1" 
               title="" tabIndex="0" xd:CtrlId="CTRL7" xd:xctname="PlainText" 
               xd:binding="my:SpouseFirstName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseFirstName"/>
    </span>
            </div>
            <div>Spouse Last Name: <span class="xdTextBox" hideFocus="1" 
               title="" tabIndex="0" xd:CtrlId="CTRL8" xd:xctname="PlainText" 
               xd:binding="my:SpouseLastName" style="WIDTH: 130px">
        <xsl:value-of select="my:SpouseLastName"/>
    </span>
            </div>
            <div><input class="langFont" title="" 
               style="WIDTH: 114px; HEIGHT: 30px" type="button" size="3" 
               value="Insert Node" xd:CtrlId="Insert_Node" xd:xctname="Button" 
               tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 141px; HEIGHT: 30px" 
                  type="button" size="1" value="Remove Node" xd:CtrlId="Remove_Node" 
                  xd:xctname="Button" tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 102px; HEIGHT: 30px" 
                  type="button" size="3" value="Copy Node" xd:CtrlId="Copy_Node" 
                  xd:xctname="Button" tabIndex="0"/>
               <input class="langFont" title="" style="WIDTH: 119px; HEIGHT: 30px" 
                  type="button" size="6" value="Paste Node" xd:CtrlId="Paste_Node" 
                  xd:xctname="Button" tabIndex="0"/>
            </div>
            <div> </div>
            <div> </div>
            </div>
    </xsl:template>
    
  4. Save and close the View1.xsl file.
  5. Right-click the Manifest.xsf file, and then click Design.
  6. 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:
    • Do not change the view after you manually modify the View1.xsl transform file of the view.
    • Alternatively, modify the template to use the xd:preserve mode. This mode tells InfoPath to keep the changes intact.

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.

Modification Type:MinorLast Reviewed:7/28/2006
Keywords:kbhowto KB832122 kbAudDeveloper