Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

data binding problem when parent node and child node have the same name

Avatar

Former Community Member
Hi, Expert,<br /><br />I am using Adobe Designer 7.1. The XML data I want to merge with template is like:<br /><br /><book><br /> <name>Designer Tip</name><br /> <author><br /> <name>anonymous</name><br /> <email>...</email><br /> </author><br /></book><br /><br />In the template I write the script as follows:<br /><br />var text = xfa.record.author.name.value;<br /><br />I expect 'text' returns null or empty string "" or throw exception when <name> node under <author> doesn't exist. But strangely it returns 'Designer Tip' instead (note that two nodes have the same name 'name'). I know by default binding rule will search direct ancestor node when reference node doesn't exist. My question is how I can disable this behaviour?<br /><br />Thanks a lot in advance<br />John
4 Replies

Avatar

Level 6
I tried to duplicate the behaviour that you described, but I'm not seeing what you're seeing. For me, xfa.record.author.name.value returns null when there's no corresponding tag (//book/author/name), even if there is a value in the //book/name tag.

Avatar

Former Community Member
Hi, Jared,<br /><br />Thank you very much for the reply. My actual merged data is much complicated than the sample. Let me give another sample to duplicate the issue I found:<br /><br />book<br /> toplevel<br /> seclevel<br /> title<br /> ID: Designer Tip<br /> /title<br /> author<br /> id: id<br /> title<br /> ID: anonymous<br /> /title<br /> /author<br /> /seclevel<br /> /toplevel<br />/book<br /><br />Script is like:<br /><br />var authorNode = xfa.record.toplevel.seclevel.author.all.item(0);<br />var idNode = authorNode.title.ID;<br />xfa.host.messagebox(idNode.value);<br /><br />Running the script shows the string "anonymous". Commenting the title node under <author>, script strangely shows "Designer Tip".<br /><br />Thanks again<br />John

Avatar

Level 6
Okay now I can reproduce the issue. Weird. I can only guess that it's a side-effect of how Acrobat/Reader handily tries to fit the data to the form. When it could not find the node that you asked for, it looked up the tree to find another match.



Here's another approach that seems to work.



var oSecLevelXML = XMLData.parse(xfa.record.toplevel.seclevel.saveXML(), false);

var oIDNode = XMLData.applyXPath(oSecLevelXML,"//seclevel/author/title/ID");

if (oIDNode == null)

xfa.host.messageBox("null");

else

xfa.host.messageBox(oIDNode.value);



Jared Langdon

www.jlangdon.ca

Avatar

Former Community Member
Thanks Jared. I will try the solution you proposed.



Anyway I think Adobe Reader/Acrobat should give an option to disable this data binding mechanism in XML form because sometimes it will return unwanted data and it is very hard to find the root cause.



Best regards

John