You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Gard Arneson Haugen <ga...@magentanews.com> on 2003/01/27 11:43:56 UTC

XML/XSL - html

Hi,

I'm using XML/XSL in Apache-asp to genereate HTML-pages. 

Is there a way to include NOT-well-formed html in the XLS template ?
I need this because some of the pages should include input from the users, and I would like to allow them to use html in this input.

If this isn't possible, is there a way to secure that the html gets well-formed?

Best Regards,
Gard Arneson Haugen



Re: XML/XSL - html

Posted by Philip Mak <pm...@aaanime.net>.
On Mon, Jan 27, 2003 at 09:33:38AM -0800, Josh Chamas wrote:
> do some runtime XML validation like running it through XML::Simple
> in an eval {} or something to catch the error, so that users are
> warned that they need to input properly escaped XHTML.

If the users are not programmer types, I'm thinking for the sake of
usability, the application should probably give the user the option of
having his invalid XML automatically fixed for him, using an algorithm
maybe like this:

1. If a tag is being closed, but it's not the one you expect to be
closed, then close the one(s) you expect to be closed first.

2. If a tag is being closed that was never opened, then discard the
closing tag.

3. If any tags are unclosed at the end of the document, close them.

The above algorithm would change <b><i>test</b></i> to
<b><i>test</i></b>, which is what one would expect.

The above could be accomplished by running the document through some
sort of HTML or XML parser (there are some CPAN modules for this).

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: XML/XSL - html

Posted by Josh Chamas <jo...@chamas.com>.
Gard Arneson Haugen wrote:
> Hi,
> 
> I'm using XML/XSL in Apache-asp to genereate HTML-pages. 
> 
> Is there a way to include NOT-well-formed html in the XLS template ?
> I need this because some of the pages should include input from the users, and I would like to allow them to use html in this input.
> 

One of the points of XML is that anything that isn't XML won't be validated.
You might try therefore to escape common tags like <br> and <img> to <br/>
and <img .../>, but also do some runtime XML validation like running it through
XML::Simple in an eval {} or something to catch the error, so that users are
warned that they need to input properly escaped XHTML.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org