Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

XHTML Strict?

by peschkaj (Pilgrim)
on Nov 04, 2002 at 02:57 UTC ( [id://210107]=perlquestion: print w/replies, xml ) Need Help??

peschkaj has asked for the wisdom of the Perl Monks concerning the following question:

Short of using a here document, or modifying the source of the module, is there a way to get CGI to produce valid XHTML 1.0 Strict code?

If you make something idiot-proof, eventually someone will make a better idiot.
I am that better idiot.

Replies are listed 'Best First'.
Re: XHTML Strict?
by grep (Monsignor) on Nov 04, 2002 at 03:24 UTC

    It would be nice to know what exactly fails with CGI and XHTML Strict? You can also send a bug report about it.

    If you are concerned about staying in the XHTML Strict spec, you can gain control of the output (without HEREDOCS) by going to a templating system. This also gains you the advantages of removing your presentation from your program logic, shortening your code, reuse of your XHTML, and overall easier maintainence.

    You can choose from several excellent Templating Systems.

  • Template Toolkit
  • Mason
  • HTML::Template


  • grep
    Mynd you, mønk bites Kan be pretti nasti...
      The Doctype is incorrect. CGI produces the XHTML-Basic Doctype, however it also places a lang attribute in the html tag, thus invalidating the XHTML-Basic doctype.

      I would prefer to not have to install more modules on the system that I am on. I'm using HP-UX at work and every module that I need to install requires writing up a change request form and scheduling a migration date so that I can get a hold of root to do my installs.

      If you make something idiot-proof, eventually someone will make a better idiot.
      I am that better idiot.

        Which version of CGI.pm do you have? With the latest version (2.89), I get this:

        $ perl -MCGI=:standard -le 'print header, start_html' Content-Type: text/html; charset=ISO-8859-1 <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"><head><title>Untitled Document</title> </head><body>

        which looks right to me.

        The list of changes includes this:

        Version 2.81

        1. Removed extraneous slash from end of stylesheet tags generated by start_html in non-XHTML mode.
        2. Changed behavior of CGI::Carp with respect to eval{} contexts so that output behaves properly in mod_perl environments.
        3. Fixed default DTD so that it validates with W3C validator.
        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

        there's nothing stopping you from installing modules yourself. you just can't put them in the main library.

        tar zxvf SomeModule.tar.gz cd SomeModule perl Makefile.PL PREFIX=/some/directory/you/can/write/to make make install
        and then, in your code:
        use lib qw(/some/directory/you/can/write/to); use Some::Module;

        anyway, having HTML::Template or Template::Toolkit installed are probably well worth whatever paperwork you have to go through.

        anders pearson

        If it really bothers you, you can always modify CGI.pm's source code. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://210107]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-23 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found