Home/Support/

Forums

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (5 pts)
6 Replies Last post: Nov 5, 2009 12:50 PM by armyCoder  
Superfly-FR User 8 posts since
Jul 30, 2002
Currently Being Moderated

Apr 15, 2009 4:52 PM

XHTML formatting does not work

XHTML formatting text parameter for query fields does not seems to work (MS SQL ntext containing fckeditor HTML text).

- My DB is MS SQL, code page FRENCH (may be the issue ?), tested both nvarchar(max) and text field types.

- I've tried both direct cfr invocation and cfreport (+ styling techniques: external Css or "cfset inline CSS" ).

- I've set the XHTML Text Format for the field within the report builder

 

Anyone had the same problem or any similar issue ?

Thanks in advance.

 

Edit, 4 hours later ...

 

I found the problem (by inserting different combinations of HTML instructions in the DB string).
While a trivial <p>toto</p><i>titi</i> will work, the whole string will be escaped (<p> = &lt;p&gt; ) as soon as an unrecognized sequence (as &aacute; ) will be found. So the problem is identified ... not the solution yet.

BrianO User 91 posts since
Jul 23, 2003
Currently Being Moderated
3. Jun 12, 2009 1:58 PM in response to: Superfly-FR
Re: XHTML formatting does not work

Antoine, Good post. I'm doing a cfform that uses cftextarea richtext="yes", like is being used in this forum, storing that in SQL Server and pulling it to a cfreport using the XHTML Text Formatting attribute. I see what you are saying and even used the function you posted above to get me further along. My users need to be able to add a page break, but of course the code for that causes the conversion to break. I hate to have to convert every character, especially since I don't know what a user might add, (e.g., an image) and not sure if that would work fully anyway. We must be missing something here. Has anyone found a solution or workaround related to passing html code to Report Builder? CF has a few html manipulation functions and I played with trying some combinations, but no luck. I wonder if it is being addressed in CF9. Passing html code to Report Builders seems like a basic issue. Adobe?

BrianO User 91 posts since
Jul 23, 2003
Currently Being Moderated
5. Jun 12, 2009 4:01 PM in response to: Superfly-FR
Re: XHTML formatting does not work

No, not a line break, a page break for which the rich text editor generates the following code:

 

<div style="page-break-after: always"><span style="display: none"> </span></div>

 

Also the following tags work fine as long as there are no attributes

 

<div><span> <span></div><p>test test</p>

armyCoder User 4 posts since
Jul 14, 2009
Currently Being Moderated
6. Nov 5, 2009 1:11 PM in response to: Superfly-FR
Re: XHTML formatting does not work

Hoping I can add something to this discussion. This is an issue that should not require 5 hours of banging my head against the wall. CF Report Builder should natively support dumping HTML into a field....but it only works if the supported tags are included, as has been mentioned.

 

Since the report builder automatically kills its attempt at rendering the HTML once it encouters a foreign tag, we need to amend this function so that it will do it's best to convert what it can, and clean the rest out so the output can have a chance at displaying properly.

 

So, to build on Antoine's function...I added just a few more items to the ASCII and HTML lists:

 

<cfargument name="source" required="yes">
<cfset char_ASCII="  ,&,<,>,« , »,oeu,Œ,…,œ,€,’,Æ,Á,Â,À,Å,Ã,Ä,Ç,Ð,É,Ê,È,Ë,Í,Î,Ì,Ï,Ñ,Ó,Ô,Ò,Ø,Õ,Ö,Þ,Ú,Û,Ù,Ü,Ý,á,â ,æ,à,å,ã,ä,ç,é,ê,è,ð,ë,í,î,ì,ï,ñ,ó,ô,ò,ø,õ,ö,ß,þ,ú,û,ù,ü,ý,ÿ,¡,£,¤,¥,¦,§,¨,©,ª, « ,¬,­,®,¯,°,±,²,³,´,µ,¶,·,¸,¹,º,»,¼,½,¾,¿,×,÷,¢">

<!---PUT THE NBSP back together, it wouldn't display properly on the forum--->

<cfset char_HTML="& nbsp; ,&amp;,&lt;,&gt;,&laquo; , &raquo;,&oelig;u,&OElig;,...,&oelig;,&euro;,',&AElig;,&Aacute;,&Acirc;,&Agrave; ,&Aring;,&Atilde;,&Auml;,&Ccedil;,&ETH;,&Eacute;,&Ecirc;,&Egrave;,&Euml;,&Iacut e ;,&Icirc;,&Igrave;,&Iuml;,&Ntilde;,&Oacute;,&Ocirc;,&Ograve;,&Oslash;,&Otilde;, & Ouml;,&THORN;,&Uacute;,&Ucirc;,&Ugrave;,&Uuml;,&Yacute;,&aacute;,&acirc;,&aelig ; ,&agrave;,&aring;,&atilde;,&auml;,&ccedil;,&eacute;,&ecirc;,&egrave;,&eth;,&eum l ;,&iacute;,&icirc;,&igrave;,&iuml;,&ntilde;,&oacute;,&ocirc;,&ograve;,&oslash;, & otilde;,&ouml;,&szlig;,&thorn;,&uacute;,&ucirc;,&ugrave;,&uuml;,&yacute;,&yuml; , &iexcl;,&pound;,&curren;,&yen;,&brvbar;,&sect;,&uml;,&copy;,&ordf;,&laquo;,&not ; ,&shy;,&reg;,&macr;,&deg;,&plusmn;,&sup2;,&sup3;,&acute;,&micro;,&para;,&middot ; ,&cedil;,&sup1;,&ordm;,&raquo;,&frac14;,&frac12;,&frac34;,&iquest;,&times;,&div i de;,&cent;">


<cfset clean = '#ReplaceList(source,char_HTML,char_ASCII)#'>

<cfreturn clean>

 

Note the nbsp, lt, and gt tags that weren't included. Once I added those, some of my results actually started to render. Imagine my excitement! But then, came disappointment once again and I realized that some still weren't working properly. Then I realized...some of the tags weren't supported and it was throwing the whole thing off. So...I added a line to the end of the function. BTW, I renamed his variable to 'clean'

 

<cfset clean = '#ReplaceList(source,char_HTML,char_ASCII)#'>
<cfset clean = '#ReReplaceNoCase(clean,"<[^>]*>","","ALL")#'>
<cfset clean = '#ReReplaceNoCase(clean,"&.*;","","ALL")#'>
<cfreturn clean>

 

So this takes any results that have extra...funky tas and strips them out. This worked well for me because  it counts the tags I need it to see and wipes out the funky ones...including any other &.....; tags that aren't include in the function.

More Like This

  • Retrieving data ...