Focal Point
[CLOSED] HTML tags in HTML output

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/455101774

June 29, 2010, 12:04 PM
JJ
[CLOSED] HTML tags in HTML output
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.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
June 29, 2010, 02:34 PM
njsden
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.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
June 29, 2010, 02:36 PM
njsden
quote:
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.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
June 29, 2010, 02:40 PM
JJ
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.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
June 29, 2010, 05:54 PM
Waz
How many items could there be in the comment ?

Could you use a series of GETTOK's


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 29, 2010, 10:07 PM
Dan Satchell
You could turn the HTML tags into comments:

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,


WebFOCUS 7.7.05
June 29, 2010, 10:15 PM
Waz
Awesome solution if its an HTML report.
Good One


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!