Problem with inserting element in a repeating choice group - InfoPath Dev
in

InfoPath Dev

Problem with inserting element in a repeating choice group

Last post 02-01-2010 08:39 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-28-2010 10:11 AM

    Problem with inserting element in a repeating choice group

    I've got a problem with my InfoPath form where I am unable to isnert a choice section between two choice sections of the same kind in a repeating choice group.  When I insert the section, I receive the following error:

    InfoPath cannot insert the section or row because of an error

    The attempted fragment operation cannot be completed because there is no valid insertion point for the fragment

    My XSD Date Source for the form is as follows:

     <xs:schema>
      <xs:element name="richBody">
        <xs:complexType>
          <xs:sequence>
            <xs:choice maxOccurs="unbounded">
              <xs:element name="element1" maxOccurs="unbounded"/>
              <xs:element name="element2" maxOccurs="unbounded"/>
            </xs:choice>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

    When my form opens, element1 is the default choice section, and is automatically inserted into "richBody".  Now I want to insert another element1 section after my first element1.  I now want to insert element2 after the first element1.  This is when I get the error.  The error doesn't occur if I add element2 after element1, then add a second element1 after element2.

    Hopefully this makes sense, and somebody can help me out with the problem.  I'm running close to a deadline, and I am not sure what to do at this point.  Thanks in advance!!

     

  • 01-29-2010 01:07 PM In reply to

    Re: Problem with inserting element in a repeating choice group

    Anybody know why I'm having this issue?

  • 01-31-2010 09:56 AM In reply to

    Re: Problem with inserting element in a repeating choice group

    Nobody can help me with this issue?

  • 02-01-2010 08:39 AM In reply to

    Re: Problem with inserting element in a repeating choice group

    The problem is that your schema is not properly defined. The key issue is that you are marking your individual elements as repeating (i.e. maxOccurs="unbounded"). These are not what gets repeated, it is the choice that gets repeated. If you did nothing other than remove the unbounded from element1 and element2, you'd stop getting your error.

    However, the safest thing to do is to create a choice schema in the InfoPath designer and then model yours after the way InfoPath "likes and expects" the schema to be. That is how I figured out why yours wasn't working. I just compared yours against one created in InfoPath.

    Below is an example of your schema upgraded to look more like the way InfoPath would design one. Note that the main difference is that the choice is inside a group and not directly off the root--but that isn't required.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="richBody">
      <xs:complexType>
       <xs:sequence>
        <xs:element name="group" minOccurs="0">
         <xs:complexType>
          <xs:choice maxOccurs="unbounded" minOccurs="0">
           <xs:element name="element1" type="xs:string" minOccurs="0"/>
           <xs:element name="element2" type="xs:string" minOccurs="0"/>
          </xs:choice>
         </xs:complexType>
        </xs:element>
       </xs:sequence>
      </xs:complexType>
     </xs:element>
    </xs:schema>

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.