I'm having issues inserting a new record into an exisiting XML variable.
For example I already have an XML variable with two records:
<UserData>
<UserInfo>
<Name>Jim</Name>
<Phone>111-111-1111</Phone>
</UserInfo>
<UserInfo>
<Name>Mike</Name>
<Phone>222-222-2222</Phone>
</UserInfo>
</UserData>
Now if I wanted to add a third record:
<UserData>
<UserInfo>
<Name>Sam</Name>
<Phone>333-333-3333</Phone>
</UserInfo>
</UserData>
I've tried a couple of things in the XPath Builder...I know you can reference each record by an index number, but I don't find any functions for adding the Record
Anyone have any suggestions on how to handle this?
Solved! Go to Solution.
Views
Replies
Total Likes
This is far more difficult than you might imagine since XPath and XSLT do not support the notion of insertion.
You are left to write a Custom Script or create a utility service that can be re-used. The process for that utility service would look like this...
I parse the XML to extract each <UserData>, add the string to a List of strings, add the new user to the end of the List, parse the List to build an xml string, and finally serialize the xml string to xml. Ugly but true.
If you would like a copy of the .lca, please send an email to stwalker.adobe@gmail.com.
Steve
Views
Replies
Total Likes
This is far more difficult than you might imagine since XPath and XSLT do not support the notion of insertion.
You are left to write a Custom Script or create a utility service that can be re-used. The process for that utility service would look like this...
I parse the XML to extract each <UserData>, add the string to a List of strings, add the new user to the end of the List, parse the List to build an xml string, and finally serialize the xml string to xml. Ugly but true.
If you would like a copy of the .lca, please send an email to stwalker.adobe@gmail.com.
Steve
Views
Replies
Total Likes
Steve,
Is it possible to send me the lca which resolves adding a new record to an xml variable in workbench?
Or are there in the meanwhile better solutions to this problem? I've already sent an email but got no reply and it's pretty urgent.
Thanks in advance!
With kind regards,
Kristof Rasschaert
Views
Replies
Total Likes
Or, you could create a custom component that does all that xml manipulation.
This would make you process a bit cleaner.
Jasmin
Views
Replies
Total Likes
Can I please still get the LCA? It's urgent and I'm not a good
java coder at all!
But is this link (http://www.adobe.com/devnet/livecycle/articles/dsc_development.html) a good start for making your own components?
Thanks
Kristof
Views
Replies
Total Likes
Yes. That's a good start.
Steve is on the west coast (US), so he'll get online in a few hours.
Jasmin
Views
Replies
Total Likes
Thanks a lot Jasmin!
I have another problem, maybe you know a solution.
I've already posted it on the forum but got no replies, you can find it here: http://forums.adobe.com/thread/617825?tstart=0
It's about the data from a pdf getting lost after flattening.
Can you take a look at it?
Thanks
Kristof
Views
Replies
Total Likes
The process has two inputs, as shown below, and produces an output xml data type that inserts the new user.
1) inputXml
<UserData>
<UserInfo>
<Name>Jim</Name>
<Phone>111-111-1111</Phone>
</UserInfo>
<UserInfo>
<Name>Mike</Name>
<Phone>222-222-2222</Phone>
</UserInfo>
</UserData>
2) newUser
<UserData>
<UserInfo>
<Name>Sam</Name>
<Phone>333-333-3333</Phone>
</UserInfo>
</UserData>
The .xml and the .lca are attached.
Steve
Views
Replies
Total Likes
Thanks Steve!! I got it working.
Kristof
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies