Expand my Community achievements bar.

XML arrays? ES2.5

Avatar

Level 2

Hello

I have ES2.5 installed

My methodology is this: I've got an XML Data File (File>Form Properties>Preview) that is like this:

<transaction xmlns...>

  <chapter>

    <verse>text 1...</verse>

    <verse>text 2...</verse>

    <verse>text 3...</verse>

    ....

    ....

  </chapter>

  <chapter>

    <verse>text 1...</verse>

    <verse>text 2...</verse>

    <verse>text 3...</verse>

    ....

    ....

  </chapter>

  <chapter>

    <verse>text 1...</verse>

    <verse>text 2...</verse>

    <verse>text 3...</verse>

    ....

    ....

  </chapter>

....

...and so on.

Now, I have a text field that I would like to populate with a user-requested chapter and verse; e.g., chapter 2 verse 3.

So, in the click event of a button I have this script:

TextField1.rawValue = $record.chapter[1].verse[2].value (this is before using variables in the square brackets):

Now this doesn't work, yet I'm sure that in the past I have entered index values into square brackets via the Object pallett: Object>Binding>Data Binding. The one difference was that I would have used a schema on that form, and Instances (I don't have access to that form anymore).

In any event, am I close to my objective or will I need to find a longer way?

Thanks.

4 Replies

Avatar

Level 2

Update: I've been reading that this should be the answer:

TextField1.rawValue = xfa.dataWindow.record(0).chapter.verse.value

...which indeed returns the first value, but should I change that integer parameter or use moveCurrentRecord or use gotoRecord; I get an "undefined" error message.

Thanks for reading my issue.

Avatar

Level 2

Further update: If I go into the XML Source in LiveCycle, and scroll down to the config opening tag: <config xmlns..., and then scroll down about another 1/3 of the page and then amend accordingly:

<common>

         <data>

            <record>chapter</record>

            <xsl>

               <uri/>

            </xsl>

            <outputXSL>

Now I can use the methods mentioned in my previous post. So now I can go to any verse of chapter 1; now I need to build on my script so that I to go to a particular chapter and verse.

Thanks for reading my issue.

Avatar

Level 2

...and the final chapter:

var c = 2, v = 3;

TextField1.rawValue = xfa.dataWindow.record(c).nodes.item(v).value;

Praise the Lord!

One thing: I read that dataGroup is deprecated, will this affect dataWindow in versions to come?

Avatar

Level 2

UPDATE: One draw back to the above solution is that if you have only LC ES2 & Reader 9, then it will only work in Preview within LiveCycle. Saving the form as a PDF or exporting to a Repository will give the same error messages* that I had before I had learned to place <record>chapter</record> in the XML.

My reasoning is that either LiveCycle or Reader ignores/removes: <record>chapter</record>

* Either out of range or outside the DataWindow.

Any comments on this is greatly appreciated.