Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Storing a value of one xml document field into another xml document

kc
Level 8
Level 8
Hi all,



I have run into a problem trying to create a process that converts a form with one schema into another form with the same basic schema (and some extra fields). Therefore I have created a process that takes a form and exports the data to a document. I have created two xml variables (one with the old xml + data) and another one which is empty (containing only the new schema). Next I need to map the values of the old xml/form to a new form.



I am not sure using these xml variables is a good idea as I seem to get some problems populating the new xml file with xpath-expression values.



Can you help me figuring out what to do to achieve this conversion?



Sincerely

Kim Christensen

Dafolo A/S

Denmark
0 Replies
kc
Level 8
Level 8
Hi again,



I hope I did not confuse you with my post. If you find it difficult to understand, I would gladly try to elaborate if any of you need it to help out.



Thank you in advance



Kim Christensen

Dafolo A/S

Denmark
Jasmin_Charbonn
Level 10
Level 10
Kim you can use xPath to do that. Let's say you have two XML variables XML1 and XML2 with the following content.







then you can use the following xPath to copy the value from one XML to the other:
/process_data/XML1/Data/Node1 = /process_data/XML2/Data/Node1/*

The /* is to copy the children node so you don't end up with Node1 under Node1.

Jasmin
kc
Level 8
Level 8
Hi again Jasmin and thankyou for your help,



However what you suggest does not seem to work.



If I try to do as you suggest and if I assign a string variable to the value of /process_data/XML1/Data/Node 1 in the same "Set Value" task I get a null value when I check in a variablelogger.



I set the following under the set value:

Location:

/process_data/XML1/Data/Node1

Expression:

/process_data/XML2/Data/Node1/*



Location:

/process_data/@myTestVar

Expression:

/process_data/XML2/Data/Node1



However when the variable logger writes out the xml in XML1 it shows that there *is* data in the field.



I feel stupid as I do not get what I am doing wrong...



Sincerely

Kim Christensen

Dafolo A/S

Denmark
Jasmin_Charbonn
Level 10
Level 10
When you put /*, it copies all the child node underneath Node1 under XML1/Data/Node1. If you don't have child noded then you should just be able to do XML1/Data/Node1 = XML2/Data/Node1.



What I think is happening is because the /*, copies all nodes under XML2/Data/Node1 and the /process_data/XML2/Data/Node1 refers to a node and not a value.



If Node1 only contains a value a not child node the use XML1/Data/Node1 = XML2/Data/Node1 instead.



Let me know if I don't understand your structure right.



Jasmin
HowardTreisman
Level 9
Level 9
Hi kcdc

I'm going to let you and Jasmin continue forward with the SetValue approach, but I'm going to suggest a couple of other approaches.



1. Why not use the more complex XML in both cases. If you use an xml document in a form, it will simply ignore any fields that are not bound, so it doesn't really do any harm.



2. You could use an XSLT transformation to do the transform. One of the advantages of this is that there are several tools that will help you to write the transform. eg XMLSpy. The Adobe XSLT component will allow you to test your transform on sample data.



3. Avoka have a newly developed XQuery component (currently in beta). If you're interested in trying this, please email: info@avoka.com



Howard

http://www.avoka.com
kc
Level 8
Level 8
Hi again Jasmin,



I can't get it right. No matter if I use the expression with the slash star (/*) or without I get no values in the xml-node. I will test it out some more and try some of Howards suggestions aswell.



If you have other ideas of achieving the wanted result you are welcome to elaborate.



Thanks in advance



Sincerely Kim
Jasmin_Charbonn
Level 10
Level 10
Can you post the content of you two XML variables and I give it a try.



Jasmin
Not applicable
Hi Jasmin..just wanted to thank you.



I found this post and your advices really helped me 🙂



Thanks...



Alessio
_jerome_dinnat_
Level 5
Level 5
Hi,

I have the same problem.

I work with xml schema. If I map field one by one I have no problem but it's very boring.

An example what my xml look like :




....



...

...


If I do this (I have two variables formInit and formStape2):

location :

process_data/......formStape2/FormA/New/login

expression :

process_data/.......formInit/FormA/New/login

and the same for all my fields under New and the other nodes, it works but not very well to do.

If I do this :

location :

process_data/......formStape2/FormA/New

expression :

process_data/.......formInit/FormA/New/*

All my fields stay empty

If I do this :

location :

process_data/......formStape2/FormA/New/*

expression :

process_data/.......formInit/FormA/New

I have all my information (login and the other field ) in the first field under New IE login

If i do this :

location :

process_data/......formStape2/FormA/New

expression :

process_data/.......formInit/FormA/New

All my fields stay empty

Can you help me ?

Thanks a lot :).
Not applicable
Are you using Livecycle Server Sp2? Or just the no-sp version?



Cause it changes how it implements xdatapath expressions...



If you tell me the version I can solve your problem
_jerome_dinnat_
Level 5
Level 5
For now, I work on the evaluate version and I don't know if it's the sp2 version or not. I download and install the jboss turnkey version a few days ago, less than a week if it could help to know the version.
Not applicable
Ok...so it's not the sp version.



Ok..try it like this.



location:



process_data/......formStape2/FormA



expression :



process_data/.......formInit/FormA/New



It should work.



Basically you set the father in the location and the branch you want to attach in the expression.



With sp2 it changes a little.



Hope it helps.



Alessio
_jerome_dinnat_
Level 5
Level 5
OK, It works fine.

Thank you very much for the help 🙂