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.

Modifying XDP File as an XML Using XPath

Avatar

Former Community Member
Hello,<br /><br />I have a requirement, in which I need to have form which has got pre-populated elements and some manual-entry elements. These forms will be designed/maintained by Business users. So at the time of Designing the forms, they bound only the pre-populated elements to the Schema, and not the manual-entry fields. There are lot of manual entry elements on the form. <br /><br />For manual entry fields, I created a program which adds bindings for manual entry elements programattically using XPath expressions. <br /><br />Somehow when I add "<bind>" tags, XDP layout is getting changed and also some junk characters are getting added. <br /><br />Please someone comment on the above approach whether it is good to programmatically modify the XDP file or not. And also is there any way to avoid the issues. <br /><br />Thanks in advance.<br />Sivajee.
7 Replies

Avatar

Former Community Member
There is nothing technically wrong with your approach - although you really have to know what you are doing when you modify the XDP. Why can't the business users do the binding in the Designer ....wouldn't that be easier (and safer).

Avatar

Former Community Member
Thanks Paul for responding to me.



The forms which we have, got a lot of manual fields. To speed up the process of form-design and ease the business-users task, we opted the modifying XDP programatically.



But still I am getting that error-messages when trying to save the modified XDP. Did anyone faced similar issues? Please comment on this.



Regards

Sivajee.

Avatar

Former Community Member
Very few people will modify the native XDP ...you must be writing out the tags incorrectly. If you look at the XDP in XMLSpy it should tell you if the XML is well formed. Then try and open it in Designer and it will tell you which line of the XDP is causing the issue.

Avatar

Former Community Member
Yes I already did that, when I opened the file in XMLSpy, I got a popup saying that the file has got offending characters <br />(0xA0),<squaresymbol>(0x90). XMLSpy need to do an automatic replacement of those characters, in order to open the file. <br /><br />Think I am doing something wrong during saving of the modified document into new File. What I am doing is, after the modification of the XML Document, I am converting into String and then writing the String content to the File. <br /><br />I will explore on the option of directly writing the modified Document content to the file, instead of String conversion. If this doesn't help then do I left with anyother options?<br /><br />Sivajee

Avatar

Former Community Member
Looks like your program is adding control chars to the XDP.

Avatar

Level 6
aspratap,



did you solved this?



Thank you

Avatar

Former Community Member
Yes.



This is how I solved it:



Earlier what I did was, converted the modified XDP document to a String and then wrote that string to the File.



I fixed it by directly writing the modified document to the file instead of converting into String and then writing to File.



Thank you.