Using Raw HTML with HTMLListener

by Lisa Nicholls Mon, February 27 2017 23:46

I am not sure why I never got around to doing this....

Yousfi Benameur has written to ask how he can use raw HTML tags (presumably in a memo or string field) and output richly-formatted HTML using HTML Listener.  

 

This sounds like it should be possible natively with no trouble at all, but all HTMLListsener does is take VFP FRX XML and transform it using XSLT.  XMLListener, which actually creates VFP FRX XML, escapes all text content, for good reasons.

To get your original HTML tags faithfully rendered by HTMLListener, therefore, you have to tell your XSLT to output the text content unescaped. 

So, okay, I've implemented it now/tonight.

To use this, all you really have to do is, a) use a new XSLT with slight changes over the Sedna or SP2 version, which I'll provide herein, and, b) tell it that a particular text object in the layout contains raw HTML tags and you don't want its contents escaped.  

No changes to any VCX or the Report Builder is needed for this.  I just created a custom attribute and told my new XSLT to pay attention to it.  Here's what that looks like in the Report Builder.  To work with the XSLT as currently created, it has to be a Yes-No Advanced property, it has to be called HTML.Raw, and it has to have the value Yes.

 

It probably has some limitations.  

This is not a very polished implementation. It's not burned into the various configuration details of the shipping HTMLListener, or Report Builder, so you just ... create the attribute on the fly.

I'm sure there are other things it can't do. For one thing, it doesn't work properly if you use textareas for stretching text contents in the designer.  The standard XSLT does this by default because everybody in the beta of VFP 9 wanted to make sure that every possible type of stretching content would show up the way they thought it should.

So, along with designating a custom XSLT file, you'll need to either not use stretching text objects or just tell the XSLT not to use textareas for stretching text objects.  

Think you can live with that?

Assuming so, your code basically becomes this:

... and here's the revised XSLT.

Et voilà, as some of us who knew how to spell properly used to say on FoxForum: 

xsltprocessoruser-sp2Plus.zip (7.77 kb) 

It's a little bit of a rush job but a nice example of how you can quickly extend the provided system without getting deep into the bowels of the provided component code.

 

 

 

 

Tags:

Reporting | Visual FoxPro | XML/XSLT