esmith Posted September 28, 2010 Share Posted September 28, 2010 Here is a sample value for Field("String"): Munich Power & Light (MP&L®) does not endorse or warrant any manufacturer’s products and shall not be liable or responsible for any claims arising out of or related to the purchase, installation, use or performance of any such products. Measures receiving the MP&L rebate instantly, at the point-of-sale, do not qualify for a mail-in rebate. If I return that field value via the following basic rule: return Field("String"); I get: Munich Power & Light (MP&L®); does not endorse or warrant any manufacturer’s products and shall not be liable or responsible for any claims arising out of or related to the purchase, installation, use or performance of any such products. Measures receiving the MP&L; rebate instantly, at the point-of-sale, do not qualify for a mail-in rebate. I highlighted the "stray" semicolons that are appearing in the result for no apparent reason. This is a problem. I would like to replace all ampersands (that are NOT part of a pre-existing HTML code with it's HTML code equivalent. I was attempting to do this by using the following rule: var str = Field("String").replace(/&(?!([a-zA-Z]+|#[0-9]+|#x[0-9a-fA-F]+);)/g, "&"); return str; This works great to replace the first ampersand (Power & Light), and correctly passes over the (’) HTML code, but due to the stray semicolons being inserted by FP, it also skips over all the ampersands in the company initials (MP&L). I'm wondering if this is a bug in FP? I am positive that the data I am providing does not have the misplaced semicolons. Any ideas where they are coming from? More importantly, how do I get rid of them? Link to comment Share on other sites More sharing options...
esmith Posted September 28, 2010 Author Share Posted September 28, 2010 Note that this does NOT happen in a delimited file; only in a tagged text file. We are using XML data from a custom front end, but I can still confirm that the front end is not including the semicolons. Link to comment Share on other sites More sharing options...
Dan Korn Posted September 28, 2010 Share Posted September 28, 2010 Note that this does NOT happen in a delimited file; only in a tagged text file. We are using XML data from a custom front end, but I can still confirm that the front end is not including the semicolons. The problem is that your data file is not valid tagged markup. In order for it to be valid FusionPro markup, or valid XML, control characters such as ampersand, greater-than and less-than, and double quotes must ALREADY be escaped with entities. FusionPro's parser is seeing the ampersand in "(MP&L®)" and interpreting that as the start of an incomplete entity wihout the terminating semicolon, so it's adding that "extra" semicolon to complete it. If your data is already valid XML-like markup, then you shouldn't need to do any extra processing in JavaScript. You can just use the data field directly in a text frame, or return it from a rule with the "Treat returned strings as tagged text" box checked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.