Expand my Community achievements bar.

SOLVED

Binding XML Schema to Repeating Elements - What am I doing wrong?

Avatar

Former Community Member

I managed to successfully bind a schema to a basic form and aside from some Reader Enabled issues it works as expected.

My next project is to do the same but with a form that features repeating subforms.

I have written my schema and validated and all seems well.  When I bind it to the form though it makes certain fields behave in an odd way.

The form is made up of three sections.  The first is a single subform of non repeating fields.  Parts Two is a table with repeating rows and Part Three is a collection of fields with an Add/Delete button using the instance manager script.

When I bind these fields and add rows I get strange results.  In Part Two pressing the Add button copies the entire row rather than creating a new one.  Changing the value of one row changes the others.

In Part Three I can create entirely new subforms using the Add button but the this.parent.index +1; script stops working.

Does anyone know why this might be happening and how I can resolve it?

The schema is below:

<xsd:element name = "RemoteWorking">
<xsd:complexType>
  <xsd:sequence>
   <xsd:element name = "PartZero">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name = "RequireAddHardWare" />
      <xsd:element name = "RequireRemoteWork" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  
   <xsd:element name = "PartOne">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name = "Surname" />
      <xsd:element name = "FirstName" />
      <xsd:element name = "UserName" />
      <xsd:element name = "JobTitle" />
      <xsd:element name = "Role" />
      <xsd:element name = "LineManager" />
      <xsd:element name = "Directorate" />
      <xsd:element name = "PersonnelCategory" />
      <xsd:element name = "CONumber" />
      <xsd:element name = "TelephoneNumber" />
      <xsd:element name = "BuildingCode" />
      <xsd:element name = "RoomNumber" />
      <xsd:element name = "WorkingHours" />
      <xsd:element name = "AltContact" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  
   <xsd:element name = "PartTwo" maxOccurs = "unbounded">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name = "AdditionalHardware" maxOccurs = "unbounded" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

   <xsd:element name = "PartThree" maxOccurs = "unbounded">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name = "ItemRequired" />
      <xsd:element name = "UserAccountName" />
      <xsd:element name = "CostCentre" />
      <xsd:element name = "BusinessCase" />
      <xsd:element name = "Device" />
     </xsd:sequence>
     <xsd:attribute name="ItemNo" type="xsd:integer" use="required"/>
    </xsd:complexType>
   </xsd:element>
 
   <xsd:element name = "PartFour">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name = "Unite" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The binding expressions needs to indicate that you can have more than one PartTwo section. To accomplish this you will need to add a [*] to the binding expressions that use teh PartTwo node. If you want to keep it simply, bind the subform that holds th information for PartTwo to the PartTwo node, then add the [*] to the end of the expression. Then al children of that node will get expressions like $.Name of the Node that it is referencing.

Hope that helps

Paul

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

The binding expressions needs to indicate that you can have more than one PartTwo section. To accomplish this you will need to add a [*] to the binding expressions that use teh PartTwo node. If you want to keep it simply, bind the subform that holds th information for PartTwo to the PartTwo node, then add the [*] to the end of the expression. Then al children of that node will get expressions like $.Name of the Node that it is referencing.

Hope that helps

Paul

Avatar

Former Community Member

Ah!  Now I understand.  This does work but produces a strange result when imported into Excel but I think that's the result of my XML structure more than anything though.  I didn't think about binding the schema to the subform, thanks!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----