I am trying to validate my website but cannot see how to fix the following errors regarding embedded views.
I have placed table tags round my view. When there are no documents to display the invalid HTML looks like this:
table
h2 No Documents Found /h2
/table
I can’t hide the unrequired tables tags without performing an expensive lookup to check for documents. Neither can I suppress the message.
If the view contents contain an ampersand, domino doesn’t encode it, so the validation fails e.g. it returns black&white rather than black&white. Is there any way round this other that doing a replacesubstring on all my columns?
So, your embedded view is treated as HTML returning individual table rows, right? A quick and easy way would be to modify your pass-through HTML like so:
table tr td
/table
Stop! Don’t say a word: This IS valid. It is valid if your view adds additional rows and it’s valid if Domino inserts its h2 tag.
What it is not though, is semantically meaningful. You could change the td tag to th and that would make it a little better from my point of view. And of course you could apply CSS formatting if needed to correct the rendering.
If you’re looking for a semantically clean solution, you are limited to either do a lookup or have a WQO agent generate all the HTML you need.
As for the second problem: Domino does as you told it. This is (valid) HTML already, keep your stinky fingers away from it. So, you really have to find a way to encode all relevant HTML entities. The only build-in function I am aware of is @UrlEncode, which will not provide the sort of encoding you’re looking for.
Many thanks. Even though the tr and td tags aren’t closed for No Documents Found it is indeed still valid. I notice that it does put a blank line in when there are docs in the view. However, I could eliminate this by removing the tr. td tag from the first cell in the embedded view.
Regarding encoding the data, I notice that if I enter black&white into a field, domino encodes this when opening the document for reading or editing to black&white. Similarly, if I preview a basic view on the web, it also encodes the data. However, if the form that contains this data is within Pass-Thru-HTML or if my view’s contents are treated as HTML it does not encode it.
“Even though the tr and td tags aren’t closed for No Documents Found it is indeed still valid.”
Right, closing tr, th and td tags are optional in HTML (not so in xhtml, of course), and you can mix both notations without affecting validity.
Pass-through HTML and treat contents as HTML really require you to provide valid HTML yourself. Domino just passes the text you compute through (hence the name) to the browser.
However, the only characters you should probably have to worry about concerning validity, are those that have a meaning in HTML: double quotes ("), ampersand (&) and left and right angle brackets (<>). So, the code to get rid of them is still about OK to handle: