Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

get data stored in xml of pdf-form itself at the runtime

Avatar

Level 3

Hello,

I generate a pdf form with some data includet e.g. firstname = dave. personID = 12345.

all this data (import-parameter is a table) is "stored" in the xml of my form:

<?xml version="1.0" encoding="UTF-8"?>
<xfa:data xmlns:xfa="
http://www.xfa.org/schema/xfa-data/1.0/">

   <data>

      <IF_TABLE_PERSON>

           <DATA xfa:dataNode="dataGroup">

                <FIRSTNAME>Dave</RFIRSTNAME>

               <PERSONID>12345</PERSONID>

firstname is binded to a textfield therefore there is no problem to get it.

because it is a table i could get the value in several ways:

a) myFirstNameField.rawValue;

b) this.resolveNode("$record.IF_TABLE_PERSON.DATA[1]").FIRSTNAME.value;

The PartnerID must not be binded anywhere (no hidden fields!). The question is, how do i get the value of PERSONID directly from xml?

xfa.datasests.data ..... ????

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Looks like you have an extra data node in there .....try building the expression one piece at a time

Start with app.alert(xfa.datasets.data.data.saveXML("pretty"))

Onceyou get that then add the next node app.alert(xfa.datasets.data.data.IF_TABLE_PERSON.saveXML("pretty"))

Continue until you get to the actual node you want.

Paul

View solution in original post

8 Replies

Avatar

Former Community Member

xfa.dataset.data will give you the root of the data dom. I suggest that you put a large multiline filed on the form (this is for debug only) and you can see the structure of the dom in that field. Use this command to populate the field:

FieldName.rawValue = xfa.datasets.data.saveXML("pretty");

Now that you can see the structure you can navigate your way to the PERSONID node and grab the value.

something like this:

xfa.dataset.data.IF_TABL_PERSON.DATA.PERSONID.value

Remember it is the value property you want and not the rawValue for nodes in the dom.

Hope that helps

Paul

Avatar

Level 3

thank you for the fast reply.

I have already tried your solution (http://forums.adobe.com/thread/341785?tstart=-2)  ; ))

the xml-schema I posted above is from that field I placed on the form for debuging purpose.

The problem is, that javascript does not recognize the "nodes" of xml:

TypeError: xfa.datasets.data.IF_TABLE_PERSON.PERSONID.VALUE is undefined

what am I doing wrong?

Avatar

Correct answer by
Former Community Member

Looks like you have an extra data node in there .....try building the expression one piece at a time

Start with app.alert(xfa.datasets.data.data.saveXML("pretty"))

Onceyou get that then add the next node app.alert(xfa.datasets.data.data.IF_TABLE_PERSON.saveXML("pretty"))

Continue until you get to the actual node you want.

Paul

Avatar

Level 3

perfect!

it was: xfa.datasets.data.data.IF_TABLE_PERSON.PERSONID.value;

Thank you very much!

Avatar

Level 3

Just one more question to get it right:

<xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
   <data>
      <IF_TABLE_PERSON>
         <DATA>
            <FIRSTNAME/>
            <PERSONID>
          </DATA>

         <DATA>
            <FIRSTNAME/>
            <PERSONID>
          </DATA>

          ......

      </IF_TABLE_PERSON>

In case I want to get the content of IF_TABLE_PERSON -Tag I use xfa.datasets.data.data.IF_TABLE_PERSON.saveXML("pretty");

I have tried to get through to PERSONID like this:

xfa.datasets.data.data.IF_TABLE_PERSON.PERSONID.saveXML("pretty");  ---- it is undefined, because it is inside another DATA-tag and there are several of them

So I have to use something like an array?!

xfa.datasets.data.data.IF_TABLE_PERSON[1].PERSONID.saveXML("pretty");    --- doesn't work either

What is the correct way to "loop" trough the schema in this case?

Avatar

Former Community Member

The saveXML is only used if the node has child nodes. In the case of PERSONID then you want the value of the node and woudl use the value property.

In the case of repeating nodes liek you have you woudl use occurance numbers or change your tactic all together and use E4X. The expression in E4X are much easier and more powerful to use. I have included an example of using E4X to get to repeating nodes.

Paul

Avatar

Level 2

Hi,

Could you please let me know how to delete the node say (DATA[1]) from the XML above and copy the manipulated XML back into some text field?

Thanks.

Avatar

Level 1

Hi,

Its working... Thanks Lot

 

Its like this:

-<V_ZFP_TABLE>


-<DATA xfa:dataNode="dataGroup" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">

<NAME1_X>Helmerich & Payne Internationa</NAME1_X>

<KUNNR_X>qwdqwd</KUNNR_X>

</DATA>


-<DATA xfa:dataNode="dataGroup" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">

<NAME1_X>Latif Brothers</NAME1_X>

<KUNNR_X>qwdq</KUNNR_X>

</DATA>

 

------------------------------------------------------------

REPLACE ALL OCCURRENCES OF  '<DATA xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'
 IN lv_xml_data_string
 WITH '<item>'.

REPLACE ALL OCCURRENCES OF  '</DATA>'
 IN lv_xml_data_string
 WITH '</item>'.

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] ----