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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Modifying XDP File as an XML Using XPath

Avatar

Not applicable
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

Level 10
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

Not applicable
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

Level 10
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

Not applicable
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

Level 10
Looks like your program is adding control chars to the XDP.

Avatar

Level 6
aspratap,



did you solved this?



Thank you

Avatar

Not applicable
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.