Expand my Community achievements bar.

SOLVED

URGENT - livecycle parser/xml special character causing problems

Avatar

Former Community Member

HI,

My livecycle output is being processed via a custom python xml system.

This has been throwing up issues with the xml special characters:

'  and

<

>

My programmer is pointing the finger elsewhere (ie at livecycle) as they do, and has said that the issue arises as

"it should escape the XML special characters i.e. should never see apos in field data, always &apos; (which should later be converted back by the parser)."

is there something that i can do in livecycle to ensure that when the user enters an apostrophy or an < > it is converted to &apos or whatever is standard for xml purposes without the user seeing &apos gibberish

the forms will not be reader extended or rendered vi Forms - just reader 9.0

any suggestion  welcomed/anyone else encountered this?

I am hoping that this is a simple case of changing a setting so the xml is exported as &apos for emample (mostly seems to be the ' that is the problem).

i guess another, cruder work around would be to have a custom email submit button with some code on the mouseup event to do a global find and replace on apostrophies in the users data and switch in the &apos as it is sent

something that works like this - on mouseup, read all user entered data, if any 's are found substitute &apos for those 's and then send email with &apos's subbed into each instance.

can someething like that be done globally/relatively simply - this would need to be added to 40+ forms with hundreds of fields - so hand coding is not an option, it must work in java programatically (all our forms are Java and we cant change this.)

anyone know how to do this - sounds like GREP style of thing but im a bit lost.....

thanks 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Greg and Bruce,

Here is an example of what I was trying to set out. I had to change a few items to get it to work. https://acrobat.com/#d=Ni54Ohqw*txor9fJq2zgcw

I created two buttons,  so that you could run one script in the preSubmit event and the another in the postSubmit event. That way the user won't be alarmed that there data has suddenly had '&apos' added to it.

I tried to access the className == "textEdit" to make it more efficient, but failed, so I just stuck with className == "field".

I started this before I heard the results of the rugby match , so I won't be offended at all if you feel the need to change the names of the functions .

For those who missed it (including myself) Ireland were thrashed by the New Zealand All Blacks 66-28. I will be weeping into my Guinness later.

Safari.png

View solution in original post

15 Replies

Avatar

Former Community Member

Odd approach considering you already have a custom python system parsing the xdp. Add a function which replaces these of characters.

Avatar

Former Community Member

that's going to be a massive pain - im told, given the setup we already have in place. also we work from the .xml not xpd.

I REALLY need something to fix this from livecycle's end - hence my thought that you coudl essentially validate the apostrophy's out on sending.

I had hoped there might be a function tucked away,, but if not surely someone knows how to attach a find and replace all apostrophies with &apos.

regards

Avatar

Level 10

Hi,

You could try this loop,

var wordArray = YOUROBJECT.split("'"); // looks for '

var wordIndex = wordArray.length;

var vNewString = "";


for (i=0; i < wordIndex; i++)

{

    vNewString += wordArray[i] + "&apos"; // replaces ' with &apos

}

I have a version of this looking for spaces and replacing with %20. Needless to say, I didn't come up with this ;-)

Niall

Avatar

Former Community Member

Hi Niall,

that looks great to me but one question---

does the presence of the YOUROBECT mean that it would need to be told for

each form what fields to search over manually. That would be a nightmare...

or have i misunderstood.

essentially, we need it to automatically determine the text fields and scan

and replace them all on submit....

perhaps i've got a hold of the wrong end of the stick?

thanks

Avatar

Level 10

Sorry Greg,

I missed that aspect in your original post.

Yes this is script that is hardwired into the form. However I think that you could create a function to do this.

If you look at Paul's Lock All Fields function. It passes the name of the root node and then the function works its way through the form and sets the access to all of the fields to readOnly.

I believe that you can set up a similar function - instead of locking fields it would look for each textfield and then scan the data in the textfield. If it contained a ', then it would change it to &apos.

One problem is that this would change the visual appears of the user's inputted data on the form. You might want to run a postSubmit script to change &apos back to '.

I don't have the experience in server XML or python processing, so can't help there.

Good luck,

Niall

Avatar

Former Community Member

HI Niall,

I'll have a look at pauls lock all and see if i can bodge something (fingers

crossed) together.

if i can kill off the apos issue in livecycle the rest of the python and

databasing process is working (touch wood) pretty well.

will have a bash and come back if i get lost.

thanks again, much appreciated.

greg

Avatar

Former Community Member

Hi Niall,

I seem to be suffering from brain fade ... do you perhaps have a hardwired working sample i could take a look at. Im just wanting to succeed with a hardwired proof of solution in a for (will worry about building in pauls code next week), but somehow stuffed it up (again...)

I know you wont hold the fact that our All Blacks are about to thump Ireland's finest against me .

Cheers (from NZ)

Greg

.

Avatar

Level 10

Hi,  I am probably mis-understanding something here, are you doing a email submission with a format of xml.  If so the angle brackets are escaped.  The apostrophe character can be escaped with &apos; in xml but this is not normal and is only required if you are using xml attributes and using single quotes to delimit the value, that is something like <part id='123&apos;B'> but Designer generates attribute values with double quotes so you wont ever see any &apos; entities.

This wont help your problem if you can't change your parser but maybe you can get some comfort in knowing you are coding around their bug not yours.

Avatar

Former Community Member

thanks for that. Yes it seems strange for a humble apos to throw a spanner,

but there it is. Hopefully I can get Niall's solution running.

cheers

Avatar

Level 10

Hi again, Another approach which may be worth trying is changing all the apostrope characters to something else as they are entered.  This might depend of the font you are using but maybe you can get away with an acute accent character instead.  So in the change event of all you text fields have some JavaScript like;

if

(xfa.event.change === "'") xfa.event.change = "´";

Doesn't show up very well in the blog but change character U0027 to U00B4.

This would mean that you wont have to change the &apos; back after the email has been sent.

Good luck ... hope you don't have that many text fields.

Bruce

Avatar

Former Community Member

Hi,

Many text fields (hence the headache.)

That approach may very well work- thanks. From a glance the sample code

changes an apos U0027 to U00B4 but has no (current) facility to filter

across the entered text - ie the user will probably enter "This is Jim's cat

not Tim's" so, that code would need to be juggled to deal with the variable

content ?

cheers

Avatar

Former Community Member

Sorry, ignore last. Brain in neutral.

thanks for suggestion. may be a good workaround if i can find the right text

to complement the ` substitution.

cheers

Avatar

Level 10

Hi,  The change event is raised character by character when typing, which is what I was thinking with my script but your comment reminded me that when you paste into your field when there is only one change event.  So this will work in both cases.

xfa.event.change

= xfa.event.change.replace(/'/g,"´");

Bruce

Avatar

Correct answer by
Level 10

Hi Greg and Bruce,

Here is an example of what I was trying to set out. I had to change a few items to get it to work. https://acrobat.com/#d=Ni54Ohqw*txor9fJq2zgcw

I created two buttons,  so that you could run one script in the preSubmit event and the another in the postSubmit event. That way the user won't be alarmed that there data has suddenly had '&apos' added to it.

I tried to access the className == "textEdit" to make it more efficient, but failed, so I just stuck with className == "field".

I started this before I heard the results of the rugby match , so I won't be offended at all if you feel the need to change the names of the functions .

For those who missed it (including myself) Ireland were thrashed by the New Zealand All Blacks 66-28. I will be weeping into my Guinness later.

Safari.png

Avatar

Former Community Member

Once again, thanks Niall, that's a really great help. I'm testing it on the

pre and post submit functions and it's working well (the desktop email

obscures the fact you're mucking with their data.)

Thanks also to Bruce for a usefull workaround.

Regards

Greg