HttpClient, CSS validation

R

Roedy Green

I want to have a Java program do an online validation of a CSS file at
http://jigsaw.w3.org/css-validator/validator

In Firefox, I can do

http://jigsaw.w3.org/css-validator/validator?text=h2{margin-left:233px;}

and I get an HTML page back, saying all is OK.

Now, how can I find out how to build a request from Java, with
HttpClient from http://hc.apache.org/httpclient-3.x/ ?
I try to send the CSS file over, which seems to work, but I only get
an HTTP error 500 back.

I do this kind of thing all the time using
http://mindprod.com/products1.html#HTTP

for example look at the code in
http://mindprod.com/products1.html#SUBMITTER
http://mindprod.com/products1.html#FILETRANSFER

You will need Wireshark
http://mindprod.com/jgloss/wireshark.html

to snoop on the communications between your browser and the website.
You then know precisely what you have to emulate.

see http://mindprod.com/jgloss/http.html
for background

also see
http://mindprod.com/jgloss/screenscraping.html#WEB

If you find this overwhelming, I will write a class to your specs for
$20.

There is another approach. I think the W3C people will give you the
source code for their validator. You could then exec it. The catch
is, it is probably written in C, and would require a version for each
platform.
 
T

Tom Anderson

I want to have a Java program do an online validation of a CSS file at
http://jigsaw.w3.org/css-validator/validator

In Firefox, I can do

http://jigsaw.w3.org/css-validator/validator?text=h2{margin-left:233px;}

and I get an HTML page back, saying all is OK.

Now, how can I find out how to build a request from Java, with
HttpClient from http://hc.apache.org/httpclient-3.x/ ?
I try to send the CSS file over, which seems to work, but I only get
an HTTP error 500 back.

That general approach can be made to work. Post the code which embodies
your specific approach (and i do mean *the* code - please don't post
snippets or paraphrases), and we'll see if we can see what's wrong with
it.

tom
 
E

Erik

http://jigsaw.w3.org/css-validator/validator
POST /css-validator/validator HTTP/1.1
Host: jigsaw.w3.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://jigsaw.w3.org/css-validator/
Content-Type: multipart/form-data; boundary=---------------------------20822292916541
Content-Length: 3213
-----------------------------20822292916541
Content-Disposition: form-data; name="file"; filename="stylesheet.css"
Content-Type: text/css

@font-face {
font-weight: bold%3B
font-style: normal%3B
font-family: "HelveticaBold" %3B
src: url(fonts/HelveticaNeueLTStd-Bd.otf) %3B
}
@font-face {
font-weight: normal%3B
font-style: normal%3B
font-family: "Helvetica" %3B
src: url(fonts/HelveticaNeueLTStd-Roman.otf) %3B
}

@font-face {
font-weight: bold%3B
font-style: normal%3B
font-family: "MyriadProBold" %3B
src: url(fonts/MyriadPro-Bold.otf) %3B
}

body
{
font-size:10pt%3B
}

h1 { font-size:20pt%3B margin-bottom:20px%3B font-weight: bold%3B font-family: "MyriadProBold" , sans-serif%3B text-align: right%3B}

h2
{
font-size:14pt%3B
margin-bottom:10pt%3B
font-weight: bold%3B
font-family: "HelveticaBold" , sans-serif %3B
text-align: right%3B
page-break-before:always%3B

}
h3 , .Preface
{
font-size:14pt%3B
font-weight: bold%3B
margin-bottom:5pt%3B
margin-left:10pt%3B
font-family: "Helvetica" , Serif%3B
}
h4
{
font-size:12pt%3B
font-weight: normal%3B
margin-bottom:5pt%3B
font-family: "Helvetica" , Serif%3B
}

.par
{
margin-left:30px%3B
margin-bottom: 0pt%3B
margin-top:0pt%3B
}

.p_toc, .level2, .level3
{
margin-right:10pt%3B
margin-left:10pt%3B
text-align:left%3B
font-size: 8pt%3B
margin-bottom: 0pt%3B
margin-top:0pt%3B
}
p
{
margin-right:10pt%3B
margin-left:0pt%3B
margin-bottom: 4pt%3B
margin-top:4pt%3B
text-align:left%3B
}
.Section, .level0, level1
{
font-weight: bold%3B
font-family: "MyriadProBold" , sans-serif%3B
margin-top:5px%3B
margin-left:0pt%3B
font-size: 10pt%3B
margin-bottom: 3pt%3B

}
p.Url
{
margin-left:25px%3B
}
pre
{
font-weight: normal%3B
font-style: normal%3B
font-size: 8pt%3B
font-family: "Helvetica" , sans-serif%3B
margin-left:10px%3B
margin-right: 10px%3B
}
span
{
font-weight: bold%3B
font-style: normal%3B
font-size: 8pt%3B
font-family: "HelveticaBold" , Serif%3B
}
p.JavaSeries
{
margin-right:30pt%3B
margin-bottom:5pt%3B
margin-left:20pt%3B
font-size:8pt%3B
}
table.NormalTable
{
border-width: 1px 1px 1px 1px%3B
border-style: solid%3B
border-spacing:0pt%3B
border-color:black%3B
}
td.bordered
{
border-width: 1px 1px 1px 1px%3B
border-style: solid%3B
border-color:black%3B
}

td.head
{
border-width: 1px 1px 1px 1px%3B
border-style: solid%3B
font-weight: bold%3B
font-size:12pt%3B
}
ul
{
list-style-type: disc%3B
margin-left:6pt%3B
list-style-position:inside%3B
}
ol
{

margin-left:6pt%3B
list-style-position:inside%3B
}
table.note
{
margin-left: 0px%3B
}
-----------------------------20822292916541
Content-Disposition: form-data; name="profile"

css21
thnx great help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top