XHTML output

Hi,

I would like to have CGI.rb outputs XHTML 1.0 code. Anybody did it already ?

Francois

Hi,

I would like to have CGI.rb outputs XHTML 1.0 code. Anybody did it already ?

I am testing it.

http://www.ruby-lang.org/~wakou/lib/test/

require "cgi"
cgi = CGI.new

require "cgi/session"
session = CGI::Session.new(cgi)

require “html/xhtml1"
html = HTML::XHtml1.new(:check=>$DEBUG, :pretty=>$DEBUG, :cgi=>cgi) do
html do
head{ title{“TITLE”} }
body do
h1{“head 1”}
p do
"some text"
end
p do
pcdata(:escape){”<Ruby’s home page> is “}
a(“http://www.ruby-lang.org/"){"here”}
pcdata(:escape){”."}
end
form do
fieldset do
textarea(“field_name”)
br
submit
end
end
pre do
pcdata(:escape){cgi.params.inspect} # auto escape &"<>
end
end
end
end
cgi.out{html.to_s}

HTML::XHtml1.new(:check=>true) --> check HTML error

$ cat test.rb
require “html/xhtml1”

HTML::XHtml1.new(:check=>true) do
html do
p do
end
end
end

$ ruby test.rb
test.rb:6
undefined method `p’ for #HTML::XHtml1:0x402bb658
You can use these elements here.
head, body

···

On Wed, Aug 07, 2002 at 10:14:53PM +0900, Francois GORET wrote:


Wakou Aoyama wakou@ruby-lang.org

What I do to make XHTML 1.0-compliant output in CGI scripts would be to
build documents not using the CGI.rb module, but by using something like
REXML, and build up an object model of your XHTML document using it,
then serialize the object model into XML text.

···

On Wed, Aug 07, 2002 at 10:14:53PM +0900, Francois GORET wrote:

Hi,

I would like to have CGI.rb outputs XHTML 1.0 code. Anybody did it already ?


Rafael R. Sevilla +63(2)8123151
Software Developer, Imperium Technology Inc. +63(917)4458925

I would like to have CGI.rb outputs XHTML 1.0 code. Anybody did it
already ?

I am testing it.
http://www.ruby-lang.org/~wakou/lib/test/
[snip]
require “html/xhtml1"
html = HTML::XHtml1.new(:check=>$DEBUG, :pretty=>$DEBUG, :cgi=>cgi) do
html do
head{ title{“TITLE”} }
body do
h1{“head 1”}
p do
"some text"
end
p do
pcdata(:escape){”<Ruby’s home page> is "}
[snip]
$ cat test.rb
require “html/xhtml1”

HTML::XHtml1.new(:check=>true) do
html do
p do
end
end
end

$ ruby test.rb
test.rb:6
undefined method `p’ for #HTML::XHtml1:0x402bb658
You can use these elements here.
head, body

I love all this-- especially the validation against the DTD! Is it
something that can/will be rolled into the core CGI module when the
testing is complete, so that those of us using CGI can simply change from
cgi = CGI.new(“html4”)
to
cgi = CGI.new(“xhtml1”)
?

side question: is there any way to force the existing CGI module to output
tags and attributes in lowercase?

  • -michael
···

On Wednesday 07 August 2002 15:54, Wakou Aoyama wrote:

On Wed, Aug 07, 2002 at 10:14:53PM +0900, > Francois GORET wrote:

++++++++++++++++++++++++++++++++++++++++++
Michael C. Libby x@ichimunki.com
public key: http://www.ichimunki.com/public_key.txt
web site: http://www.ichimunki.com
++++++++++++++++++++++++++++++++++++++++++