Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Sample XML: data file in Preview tab

Avatar

Former Community Member

Hi,

how to parse data file imported via Preview tab through Javascript?

I use a Sample XML data connection and import xml data via Preview tab. Though, I'd like to manually parse the data file. Is it anyway possible? Or the only chance is to play with hidden text fields...

Thanks

5 Replies

Avatar

Level 5

Hi,

I didn't really understand what you trying to achieve. Can you run by that again?

Avatar

Former Community Member

I found a solution on my own! It's weird that these days many questions on the forum are left unanswered. Till a couple of years ago, there were many STAFF-people together with senior members taking care of us...

Anyway, following is what I did (though it may not be the best - in particular "resolveNode()" may deteriorate performance according to what I know).

First of all, I have a sample XML like this:

<Elements>

     <Element>

          <a>value1a</a>

          <b>value1b</b>

          <c>value1c</c>

          ...

     </Element>

     <Element>

          <a>value2a</a>

          <b>value2b</b>

          <c>value2c</c>

          ...

     </Element>

     <Element>

          <a>value3a</a>

          <b>value3b</b>

          <c>value3c</c>

          ...

     </Element>

     ...

</Elements>

I bind a field to this XML file. I import the same under File-->Form Properties...-->Preview-->Data File.

Now, this was the situation: the bound field (a drop-down box) displayed data as expected (let's say it was bonded to Element-->a) but I had another field left unbounded (a simple text field) on my form which I wanted to fill by script with Element--->b. Of course, I had to parse the XML file and get Element-->b1 if the drop-down had Element-->a1, Element-->b2 if the drop-down had  Element-->a2 and so on...

This is what I did:

var dropDown_rawValue = myDropDown.rawValue;

var i;

...iterate i...

var string = "$record.Element["+i+"]";

if (xfa.resolveNode(string).a.value == dropDown_rawValue){

     ...populate unbound field with corresponding Element[i]-->b...

}

If you got any better solutions, they are welcome!

Avatar

Level 5

Can't think in another solution for that right now.

I'm curious, though, why would the resolveNode() deteriorate performance? I couldn't find any reference. Can you share with us?

Avatar

Level 8

xfa.resolveNodes("xfa.datasets.data.root.child[*]") would give you a handle to the data, don't really understand what you're trying to do

Avatar

Former Community Member

Well,

I am also a bit confused... I have reviewed this subject very quickly as I am not developing huge applications. However here is what I have got:
1) http://blogs.adobe.com/formfeed/2008/12/object_expressions_in_xfa.html: this one links to the following;
2) http://blogs.adobe.com/formfeed/2009/04/performance_of_object_expressi.html (here you'll find test results).

The following links to John Brinkman's work but it seems to downgrade resolveNode() as I said:

3) http://www.assuredynamics.com/index.php/2011/05/som-expressions/

What do you think?