Expand my Community achievements bar.

maxOccurs = unbounded and xfaForm variable

Avatar

Level 3

Here is a snip of my form's XML schema:

   <xsd:complexType name="tableRow">
      <xsd:sequence>
         <xsd:element maxOccurs="unbounded" name="row">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="Group" type="xsd:string"/>
                  <xsd:element name="DocumentName" type="xsd:string"/>

               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>

I want to be able to have multiple rows in XML.  Something along the lines of:

<TableData>

     <row>

          <Group>A</Group>

          <DocumentName>doc1.doc</DocumentName>

     </row>

     <row>

          <Group>B</Group>

          <DocumentName>doc2.doc</DocumentName>

     </row>

</TableData>

The problem I am running into is when I want to assign values into the xfaForm when I am prepopulating the form.  For instance, if I try to add data into .../xdp/datasets/data/Assign/TableData/row/Group it does not appear on the loaded form.  When I do a record and playback on the process I find this getting added into my datadoc:

<TableData><row/></TableData>

Does anyone know how I can add multiple rows?

Any help is greatly appreciated.  Thanks in advance!

11 Replies

Avatar

Former Community Member

You have to import your schema into the DataConnection of the form, then bind the fields on the form to the nodes in the data connection. This will inform the form of the structure of the data that you want to use as well as how to map it.

Paul

Avatar

Level 3

Yep, I am doing that Paul.  In my DataConnection I have:

TableData

     row

          Group

          DocumentName

These are bound to a dynamic table.  I have tested it with sample XML and it does populate the table with the correct amount of rows based on the number of 'row's I have in XML.

My problem happens when I'm trying to tie in the PDF to a workflow process.  The xfaForm variable (which uses the schema from the pdf) in the process does not seem to allow for multiple rows.  It seems to only allow for a 1 - 1 relationship.  I have attached a picture of what the XPath Builder looks like when adding a value to TableData.  Instead of being able to put in multiple rows the value would just get overwritten with whatever is last input (and even the last value is not showing up in the generated XML when the process executes).

Maybe this is more of a process management or workbench question?

Avatar

Former Community Member

Remember that the xpath builder is only showing you structure not that actual data. So from a structure perspective it is correct. Are you trying to add multiple rows of data into the xml file for merging on the server side?

Paul

Avatar

Level 3

Yes.  I have a custom render process where I do prepopulation for the form.  I am looking to be able to add multiple rows of data into the XML file at this stage.

Avatar

Former Community Member

Are you adding the rows of information one by one, or do you have an XML structure that you will add to the data file that represents the repeating rows?

In other words will there be a single operation of adding repeating rows to the data file or numerous operations (one per row)?

Paul

Avatar

Level 3

What I have been doing is adding information one by one into the xfaForm variable.   Once I have all the information I need in the variable, I am mapping a data document to the xfaForm.

Avatar

Former Community Member

There is no ability to create new nodes in an existing xml structure but you can concatinate two xml structures together . XPath is limiting in that way .....you ar now dealing with how to manipulate the XML through XPath. Remember that it is giving you the structure of XML not teh actual values.

Another option is to write a java program using the Scripting operation. There you coudl load a DataDom if you find that easier.

Paul

Avatar

Level 3

Thanks for the information Paul.  Can you elaborate on how I would be able to concatinate two xml structures together?

Also, where can I find more information on loading a DataDom?  I have written a few scripts in Java using the Execute Script service but am still getting use to it.

Avatar

Former Community Member

So you woudl have each part of the XML in system vars. In a setValue operation (on the left hand side) you woudl have the location where you want to insert the xml (Process Variable/path to the node that you want). On the right hand side would be the process var that has the xml that you want to add. You coudl take a subset of it by pathing to the xml node that you want. You may have to put a /* on the end of the expression so that all nodes below the one named will be included. You can do a search in the web for XPath and you will see what you can and canot do. I think that it is XPath version 2.1that is implemented.

I do not know how to load the Dom through java, I have seen it done but I am not a programmer nor do I have the code to do it. I only know that it can be done.

Paul

Avatar

Level 3

I tried having a second schema with only the row information and I did the following:

Location

Expression
/process_data/XMLAttachments/row/DocumentName"doc1.xml"
/process_data/XMLAttachments/row/Group"1"
/process_data/tempXFA/object/data/xdp/datasets/data/Assign/TableData/row/process_data/XMLAttachments/row
/process_data/XMLAttachments2/row/DocumentName"doc2.xml"
/process_data/XMLAttachments2/row/Group"2"
/process_data/tempXFA/object/data/xdp/datasets/data/Assign/TableData/row/process_data/XMLAttachments2/row
/process_data/@inDataDoc/process_data/tempXFA/object/data/xdp


Now I'm running into the problem that it is overwriting the row information each time, so only the second document is showing up.  I tried putting in the /*, but that seems to be a wildcard, so all the information from the second attachment was just going into the DocumentName of the first one.  I also tried having the rows numbered, so put it into row[1] and row[2], but that generates an error.  Is there a way to keep the row information that is currently there and add in the second row information?

Avatar

Level 3

A small update.  I tried using an attribute value to be able to distinguish the difference between each of the siblings that would be created, but I ended up running into the problem of setting XML attributes using XPath .  I am going to revert to elements again and see if I can find a solution.