[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

HTML and CSS validation

Bil Kleb

12/25/2004 12:03:00 PM

What's the best method to automate the validation
of HTML (and CSS)?

In 2001, someone mentioned hooking up to W3's validation
service, http://validat..., but my lame search
abilities have failed to find anything more...

Thanks,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...
16 Answers

Shajith

12/25/2004 12:21:00 PM

0

Hi!

On Sat, 25 Dec 2004 21:06:54 +0900, Bil Kleb <Bil.Kleb@nasa.gov> wrote:
> What's the best method to automate the validation
> of HTML (and CSS)?
>
I'm not sure what you mean by 'automate' (are you looking for some RPC
service to call upon?), but http://validat... does have an
online validator service.
I.e., following a link like
http://validat...check?uri=www.metafilter.com
leads to a page containing validation results for metafilter.com. You
can also use
http://validat...check/referer
to fetch and validate the referring page.

HTH
-Shajith


James Britt

12/25/2004 3:20:00 PM

0

Bil Kleb wrote:
> What's the best method to automate the validation
> of HTML (and CSS)?
>
> In 2001, someone mentioned hooking up to W3's validation
> service, http://validat..., but my lame search
> abilities have failed to find anything more...


I don't have any suggestions for CSS (though I believe their are
Web-based validators out there someplace), but for local validation I
sometimes use RXP.

It's a fast validating XML parser, written in C, that runs on a variety
of platforms. I like it because there is a Windows version, and I can
quickly check an XML file against a DTD.

http://www.cogsci.ed.ac.uk/~richar...

It's not automated, though running it via backticks and grepping the
output should be easy. Writing a proper Ruby binding shouldn't be too
hard either; hell, there's a Python binding, so there can't be anything
too tricky.

Of course, I say this while not planning to do it myself.

James



>
> Thanks,



Bil Kleb

12/25/2004 7:04:00 PM

0

CT wrote:
> Hi!

Hello.

> Bil Kleb wrote:
>>
>>What's the best method to automate the validation
>>of HTML (and CSS)?
>
> I'm not sure what you mean by 'automate'

Here's my scenario: I work on some RHTMLs and run some
ERB Ruby to get some HTMLs. Then I "publish", i.e.,
upload to the webserver.

I'd like this RHTML -> HTML Ruby code to also report on
the validity of the generated HTMLs via something like
W3's validation service, /before/ I publish them.

I'd really like to do the validation without requiring
a network connection but for now, I'd be happy just
automating the validation process.

Regards,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...

Bil Kleb

12/25/2004 7:19:00 PM

0

CT wrote:
> I.e., following a link like
> http://validator.w3.org/check?uri=www.meta...
> leads to a page containing validation results for metafilter.com.

Ah. If I can figure out how to send a file to their
file upload interface,

http://validator.w3.org/file-u...

without manually using the form, I'd be in business.

--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...

Sam Goldman

12/26/2004 12:39:00 AM

0

You can do this with cURL (man curl), and I suppose one of the Ruby cURL
bindings.

- Sam

Bil Kleb wrote:
> CT wrote:
>
>> I.e., following a link like
>> http://validator.w3.org/check?uri=www.meta...
>> leads to a page containing validation results for metafilter.com.
>
>
> Ah. If I can figure out how to send a file to their
> file upload interface,
>
> http://validator.w3.org/file-u...
>
> without manually using the form, I'd be in business.
>


Bil Kleb

12/26/2004 1:56:00 PM

0

Sam Goldman wrote:
> You can do this with cURL (man curl), and I suppose one of the Ruby cURL
> bindings.

Actually /I/ can't. I lack the knowledge and apparently, the ability
to learn how to do this -- mostly due to the requirement to change the
form encoding type to handle the file upload part...

Regards,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...

Bil Kleb

12/26/2004 1:57:00 PM

0

James Britt wrote:
>
> I don't have any suggestions for CSS (though I believe their are
> Web-based validators out there someplace), but for local validation I
> sometimes use RXP. [..]
>
> http://www.cogsci.ed.ac.uk/~richar...

Hmm. Thanks, I'll take a look.

Regards,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...

John W. Long

12/27/2004 3:11:00 AM

0

I personally like:

http://www.htmlhelp.com/tools/...

Be sure to check the "Validate entire site" option.

--
John Long
http://wiseheart...



Bil Kleb

12/27/2004 3:48:00 AM

0

John W. Long wrote:
> I personally like:
>
> http://www.htmlhelp.com/tools/...

Thanks for the tip, I hadn't found that one in
my prior searches.

But my twist is that I would like to automate the
validation check /before/ publishing the pages
to a webserver.

Right now I have to manually use one of the file
upload validators interfaces such as,

http://www.htmlhelp.com/tools/...upload.html
http://validator.w3.org/file-u...

because I'm reluctant to install W3's source due
to it's large dependency chain and I'm too stupid
to figure out how to automate the interaction
with these file upload interfaces.

From looking at their form source and reading a bit
about file upload forms, I gather that I have to send
a form with enctype="multipart/form-data", but it
is unclear just how to do this.

Regards,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...

Carlos

12/27/2004 4:34:00 AM

0

Bil Kleb wrote:

> http://www.htmlhelp.com/tools/validator/u...
> http://validator.w3.org/file-u...
>
> because I'm reluctant to install W3's source due
> to it's large dependency chain and I'm too stupid
> to figure out how to automate the interaction
> with these file upload interfaces.
>
> From looking at their form source and reading a bit
> about file upload forms, I gather that I have to send
> a form with enctype="multipart/form-data", but it
> is unclear just how to do this.


Your request should be something like this (not tested):

# let's say that what you write to stdout goes to the server
# ('validator-page' is the path that appears in the 'action'
# attribute of the <form>
separator = "----------------------86428764287643287642"
print "POST /validator-page HTTP/1.1\r\n"
# you first send a header for your request
print "Host: www.example.org\r\n" # the server, probably www.htmlhelp.com
print "User-Agent: RubyValidator/1.0 :)\r\n"
print "Content-Type: multipart/form-data; boundary=", separator, "\r\n"
print "\r\n"
# and then goes every form field, prefixed by separator and a header
print separator, "\r\n"
print "Content-Disposition: form-data; name=\"fieldname\"\r\n" # the
name in the form field
print "Content-Type: text/plain; charset=UTF-8\r\n" # for almost every
field type
print "Content-Transfer-Encoding: 8 bit\r\n"
print "\r\n"
print "These are the contents of the text field.\r\n"
# for a file upload, the headers change slightly
print separator, "\r\n"
print "Content-Disposition: form-data; name=\"fieldname\"" # the name in
the form field
print "; filename=\"file-name.html\"\r\n" # ..and in
this case the filename
print "Content-Type: application/octet-stream\r\n" # the content type
also changes...
# ...but I guess you can put "text/html; charset=..." as well
print "Content-Transfer-Encoding: 8 bit\r\n" # or whatever
print "\r\n"
print your_file_in_a_string
print "\r\n"
# you finalize your request with the separator plus two dashes
print separator, "--\r\n"

A tip: create a simple webrick servlet that only outputs its request.
Then copy any form you want to automate to your local machine, and
change its "action" attribute to point to your servlet. Then you'll know
exactly what you need to send.

Good luck.