I have to create a report off of a table that has a field with HTML tags. How do I display data without HTML tags? See sample data below:
ID : 1234567
NAME : ABCDEF
COMMENT : [b]AAAAAAAAAAA[/b]<br><br> <ul> [b]BBBBBBBBBBB:[/b]<br> <ul> NA<br> </ul>
[b]CCCCCCCCCCCC:[/b]<br> <ul> NA </ul> </ul> <br> <br> DDDDDDDDDDD.
Thank you,This message has been edited. Last edited by: Kerry,
WebFOCUS 8.2.05 Windows 2003 Excel, HTML, PDF
June 29, 2010, 12:45 PM
Darin Lee
There's a strip function, but I believe that only removes a specific character from a string. You might try the STRREP function, replacing any HTML tags that might exists with spaces and then use SQUEEZ to remove extraneous spaces.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
June 29, 2010, 01:23 PM
JJ
Darin, Thank you for your quick response. If I use STRREP function, I have to hard code all the HTML tags which is very difficult. Is there a way to use HTML formatting in the field values instead?
Thanks again,
WebFOCUS 8.2.05 Windows 2003 Excel, HTML, PDF
June 29, 2010, 01:30 PM
trob
Can you give us an example of your report/code? I don't quite understand what you are trying to do.
If what you're producing is an HTML report, those tags will be sent as they are by WF and will be resolved and rendered by your browser. There is a potential risk of not having "well formed" HTML tags in your data which may impact your final output so you'll have to watch out for that.
DEFINE FILE CAR
NEW_MODEL/A40 = STRREP(24, MODEL, 4, 'DOOR', 11, '<b>DOOR</b>', 40, NEW_MODEL);
COMMENTS/A80 = IF CAR EQ 'JAGUAR' THEN '<ul><li>Nice Car</li><li>Good-looking</li></ul>' ELSE
IF CAR EQ 'PEUGEOT' THEN '<ul><li>Good-looking</li></ul>' ELSE ' ';
END
TABLE FILE CAR
PRINT CAR
COUNTRY
NEW_MODEL
COMMENTS
END
The silly code above produces some output with embedded HTML tags and they are rendered normally in my IE browser.
If I use STRREP function, I have to hard code all the HTML tags which is very difficult
What is your database? It might also be possible to create a view which filters those tags out at the database side before the records are sent to WebFOCUS.
MYTABLE has three fields(ID, NAME & COMMENTS), and COMMENT field has HTML tags. I am trying to display COMMENT in a readable format to the user and links as active links.
Thanks,
WebFOCUS 8.2.05 Windows 2003 Excel, HTML, PDF
June 29, 2010, 02:48 PM
trob
I think if you want the most control of the formatting you are going to have to strip out all the html code, however if you want to leave the html code as is in the field just output the report as html or htmtable. Like njsden stated the html tags will be passed along with your data to the browser.
DEFINE FILE CAR
ID/A7 WITH COUNTRY = '1234567';
NAME/A7 WITH COUNTRY = 'ABCDEF';
COMMENT/A150 WITH COUNTRY = '[b]AAAAAAAAAAA[/b]<br><br> <ul> [b]BBBBBBBBBBB:[/b]<br> <ul> NA<br> </ul> [b]CCCCCCCCCCCC:[/b]<br> <ul> NA </ul> </ul> <br> <br> DDDDDDDDDDD.';
COMMENT1/A200 = STRREP(150,COMMENT,1,'<',4,'<!--',200,'A200');
COMMENT2/A250 = STRREP(200,COMMENT1,1,'>',3,'-->',250,'A250');
END
-*
TABLE FILE CAR
PRINT COUNTRY ID NAME COMMENT COMMENT2
WHERE RECORDLIMIT EQ 1 ;
END
Edit: There are a couple of caveats. First, this technique won't work if your comment field has '<' or '>' characters that are not part of HTML tags. Second, this technique won't work if any of the HTML tags span text (<div ... </div, for example). Finally, you must make sure to increase the size of the output field to account for the number of extra characters that will be added to the input field by replacing single characters ('<' and '>') with multiple characters ('<!--' and '-->').This message has been edited. Last edited by: Dan Satchell,