<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Code Train &#187; css</title>
	<atom:link href="http://thecodetrain.co.uk/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecodetrain.co.uk</link>
	<description>Where Neil Crosby talks about coding on the train...</description>
	<lastBuildDate>Sun, 03 Apr 2011 18:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Getting the CSS Validator running as a website</title>
		<link>http://thecodetrain.co.uk/2009/03/getting-the-css-validator-running-as-a-website/</link>
		<comments>http://thecodetrain.co.uk/2009/03/getting-the-css-validator-running-as-a-website/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 10:48:57 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[feci]]></category>
		<category><![CDATA[jigsaw]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tomcat]]></category>
		<category><![CDATA[validator]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[web-server]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=222</guid>
		<description><![CDATA[<p>A week or so I wrote about <a href="http://thecodetrain.co.uk/2009/02/running-the-w3c-css-validator-locally-from-the-command-line/">running the W3C CSS Validator on the command-line</a>.  Yes, I know I said I didn&#8217;t need to run it as a website, but as it turns out the command-line version doesn&#8217;t seem to want to validate local files — only files being served from a  web-server.</p>

<p>So, I went back to scratch and tried installing it on a web-server.  Since my normal stack is Apache, MySQL and PHP I didn&#8217;t have any of the Java-based web-servers suggested by the W3C.  My first attempt at getting the validator working was to use <a href="http://www.w3.org/Jigsaw/">Jigsaw</a> &#8211; the same web-server as the W3C uses to run their version on.  Unfortunately, it didn&#8217;t work for me.  Bugger.</p>

<p>So, I tried <a href="http://tomcat.apache.org/">Tomcat</a>.  After following <a href="http://wiki.apache.org/tomcat/TomcatOnMacOS#head-3bfa4851688758d9bd07a188d4f552806af8b30f">Basil Bourque&#8217;s instructions</a> on <a href="http://wiki.apache.org/tomcat">Apache&#8217;s Tomcat wiki pages</a>, I got Tomcat working.  I then followed the rest of the <a href="http://jigsaw.w3.org/css-validator/DOWNLOAD.html">CSS Validator installation instructions</a> for Tomcat, and the validator worked in my browser.  Excellent.</p>

<p>There was a fly in the ointment though.  Whilst the validator worked in my browser, the same could not be said of my attempts to get it working via cURL calls from PHP using POST data.  I was using the same code as I&#8217;d used to validate against the W3C&#8217;s HTML validator, so I knew that I was able to successfully push POST data across to servers.  If I tried using GET requests to send the data to my local validator, then that worked. I verified the same thing was happening on the live CSS validator to make sure the problem wasn&#8217;t with my installation.  I know you&#8217;re thinking &#8220;well, if GET worked, why not just make requests that way?&#8221;  Unfortunately, I know that later I&#8217;ll be asking to validate much larger CSS rulesets — ones that will be far too large to fit on a URL.  So, I needed to use POST.</p>

<p>After a fair bit of poking, I realised that the in-browser version of the CSS Validator was setting an <code>enc</code> attribute value of <code>multipart/form-data</code> on the form when it was uploading files or sending textual data.  Conversely, it turns out that PHP was sending <code>application/x-www-form-urlencoded</code> as the encoding type instead, and the W3C CSS Validator just isn&#8217;t set up to accept that.  After a long time of trying to work out how to send things in <code>multipart/form-data</code> format using PHP&#8217;s cURL functions, I happened upon <a href="http://us2.php.net/manual/en/function.curl-setopt.php#84916">a comment on PHP&#8217;s curl_setopt function</a> which told me that if I gave PHP an array instead of a string it would automagically start using <code>multipart/form-data</code>.  As if by magic, my problem was solved.</p>

<p>My problems setting up my programmatic connection to the CSS Validator could easily have been solved by clearer documentation.  Nowhere that I could find in the Validator&#8217;s documentation was there any mention of needing to make POST requests using <code>multipart/form-data</code>.  If this had been stated somewhere I would at least I have known the path I needed to be looking down.  Likewise, lack of anything other than user-generated documentation for the PHP <code>CURLOPT_POSTFIELDS</code> cURL option made life far more difficult than it should have been.</p>

<p>Still, in the end I have a local version of the W3C&#8217;s CSS validator running on my laptop, and I&#8217;m able to connect to it programmatically to run tests.  Which is nice.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>A week or so I wrote about <a href="http://thecodetrain.co.uk/2009/02/running-the-w3c-css-validator-locally-from-the-command-line/">running the W3C CSS Validator on the command-line</a>.  Yes, I know I said I didn&#8217;t need to run it as a website, but as it turns out the command-line version doesn&#8217;t seem to want to validate local files — only files being served from a  web-server.</p>

<p>So, I went back to scratch and tried installing it on a web-server.  Since my normal stack is Apache, MySQL and PHP I didn&#8217;t have any of the Java-based web-servers suggested by the W3C.  My first attempt at getting the validator working was to use <a href="http://www.w3.org/Jigsaw/">Jigsaw</a> &#8211; the same web-server as the W3C uses to run their version on.  Unfortunately, it didn&#8217;t work for me.  Bugger.</p>

<p>So, I tried <a href="http://tomcat.apache.org/">Tomcat</a>.  After following <a href="http://wiki.apache.org/tomcat/TomcatOnMacOS#head-3bfa4851688758d9bd07a188d4f552806af8b30f">Basil Bourque&#8217;s instructions</a> on <a href="http://wiki.apache.org/tomcat">Apache&#8217;s Tomcat wiki pages</a>, I got Tomcat working.  I then followed the rest of the <a href="http://jigsaw.w3.org/css-validator/DOWNLOAD.html">CSS Validator installation instructions</a> for Tomcat, and the validator worked in my browser.  Excellent.</p>

<p>There was a fly in the ointment though.  Whilst the validator worked in my browser, the same could not be said of my attempts to get it working via cURL calls from PHP using POST data.  I was using the same code as I&#8217;d used to validate against the W3C&#8217;s HTML validator, so I knew that I was able to successfully push POST data across to servers.  If I tried using GET requests to send the data to my local validator, then that worked. I verified the same thing was happening on the live CSS validator to make sure the problem wasn&#8217;t with my installation.  I know you&#8217;re thinking &#8220;well, if GET worked, why not just make requests that way?&#8221;  Unfortunately, I know that later I&#8217;ll be asking to validate much larger CSS rulesets — ones that will be far too large to fit on a URL.  So, I needed to use POST.</p>

<p>After a fair bit of poking, I realised that the in-browser version of the CSS Validator was setting an <code>enc</code> attribute value of <code>multipart/form-data</code> on the form when it was uploading files or sending textual data.  Conversely, it turns out that PHP was sending <code>application/x-www-form-urlencoded</code> as the encoding type instead, and the W3C CSS Validator just isn&#8217;t set up to accept that.  After a long time of trying to work out how to send things in <code>multipart/form-data</code> format using PHP&#8217;s cURL functions, I happened upon <a href="http://us2.php.net/manual/en/function.curl-setopt.php#84916">a comment on PHP&#8217;s curl_setopt function</a> which told me that if I gave PHP an array instead of a string it would automagically start using <code>multipart/form-data</code>.  As if by magic, my problem was solved.</p>

<p>My problems setting up my programmatic connection to the CSS Validator could easily have been solved by clearer documentation.  Nowhere that I could find in the Validator&#8217;s documentation was there any mention of needing to make POST requests using <code>multipart/form-data</code>.  If this had been stated somewhere I would at least I have known the path I needed to be looking down.  Likewise, lack of anything other than user-generated documentation for the PHP <code>CURLOPT_POSTFIELDS</code> cURL option made life far more difficult than it should have been.</p>

<p>Still, in the end I have a local version of the W3C&#8217;s CSS validator running on my laptop, and I&#8217;m able to connect to it programmatically to run tests.  Which is nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/03/getting-the-css-validator-running-as-a-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running the W3C CSS Validator locally from the command line</title>
		<link>http://thecodetrain.co.uk/2009/02/running-the-w3c-css-validator-locally-from-the-command-line/</link>
		<comments>http://thecodetrain.co.uk/2009/02/running-the-w3c-css-validator-locally-from-the-command-line/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:36:18 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[feci]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[validator]]></category>
		<category><![CDATA[w3c]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=203</guid>
		<description><![CDATA[<p>One of the things I&#8217;m currently working on is being able to run automated tests of FrontEnd Web Systems.  In order to carry out the first phase of this testing I need local installations of the <a href="http://validator.w3.org/">HTML Validator</a>, <a href="http://jigsaw.w3.org/css-validator/">CSS Validator</a> and <a href="http://jslint.com">JsLint</a> (when automatically running these tests many times a day it&#8217;s not fair to put that load on these free services).</p>

<p>I&#8217;m currently working on the CSS portion of the First Phase, so I&#8217;ve been looking at getting the W3C CSS Validator running locally on my machine.  Since there was a tiny bit more to it than there seemed from the <a href="http://jigsaw.w3.org/css-validator/DOWNLOAD.html">W3C&#8217;s setup instructions</a>, I thought I&#8217;d better write down how I did it.</p>

<ol>
<li><p><a href="http://www.w3.org/Jigsaw/#Getting-2-2-6">Download the Jigsaw web server</a> and unzip it to a location of your choice.  We&#8217;ll be needing the servlet.jar file from it later (it&#8217;s in <code>Jigsaw 2/classes/servlet.jar</code>)</p></li>
<li><p>Open a terminal window, and change directory to somewhere you&#8217;re happy to put the CSS Validator.  The CVS password, when prompted, is &#8220;anonymous&#8221;.</p>

<pre><code>CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs login
CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout \
2002/css-validator
cd 2002/css-validator
mkdir lib
cp {your servelet.jar location} lib
ant jar
</code></pre></li>
<li><p>Assuming nothing goes wrong, you&#8217;ve got yourself a self-contained, offline CSS Validator.  Awesome.</p></li>
<li><p>Test the validator by running the following:</p>

<pre><code>java -jar css-validator.jar --output=soap12 http://www.w3.org/
</code></pre></li>
<li><p>By running the following, you can see the options available to you from the validator:</p>

<pre><code>java -jar css-validator.jar
</code></pre>

<p>These options are explained in the <a href="http://jigsaw.w3.org/css-validator/manual.html">CSS Validator User Manual</a>.</p></li>
</ol>

<p>And that, as they say, is all there is to it.  From this, it shouldn&#8217;t be too difficult to set the validator up to run as a website if you want to, but that wasn&#8217;t necessary for me right now, so I didn&#8217;t do it myself.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>One of the things I&#8217;m currently working on is being able to run automated tests of FrontEnd Web Systems.  In order to carry out the first phase of this testing I need local installations of the <a href="http://validator.w3.org/">HTML Validator</a>, <a href="http://jigsaw.w3.org/css-validator/">CSS Validator</a> and <a href="http://jslint.com">JsLint</a> (when automatically running these tests many times a day it&#8217;s not fair to put that load on these free services).</p>

<p>I&#8217;m currently working on the CSS portion of the First Phase, so I&#8217;ve been looking at getting the W3C CSS Validator running locally on my machine.  Since there was a tiny bit more to it than there seemed from the <a href="http://jigsaw.w3.org/css-validator/DOWNLOAD.html">W3C&#8217;s setup instructions</a>, I thought I&#8217;d better write down how I did it.</p>

<ol>
<li><p><a href="http://www.w3.org/Jigsaw/#Getting-2-2-6">Download the Jigsaw web server</a> and unzip it to a location of your choice.  We&#8217;ll be needing the servlet.jar file from it later (it&#8217;s in <code>Jigsaw 2/classes/servlet.jar</code>)</p></li>
<li><p>Open a terminal window, and change directory to somewhere you&#8217;re happy to put the CSS Validator.  The CVS password, when prompted, is &#8220;anonymous&#8221;.</p>

<pre><code>CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs login
CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout \
2002/css-validator
cd 2002/css-validator
mkdir lib
cp {your servelet.jar location} lib
ant jar
</code></pre></li>
<li><p>Assuming nothing goes wrong, you&#8217;ve got yourself a self-contained, offline CSS Validator.  Awesome.</p></li>
<li><p>Test the validator by running the following:</p>

<pre><code>java -jar css-validator.jar --output=soap12 http://www.w3.org/
</code></pre></li>
<li><p>By running the following, you can see the options available to you from the validator:</p>

<pre><code>java -jar css-validator.jar
</code></pre>

<p>These options are explained in the <a href="http://jigsaw.w3.org/css-validator/manual.html">CSS Validator User Manual</a>.</p></li>
</ol>

<p>And that, as they say, is all there is to it.  From this, it shouldn&#8217;t be too difficult to set the validator up to run as a website if you want to, but that wasn&#8217;t necessary for me right now, so I didn&#8217;t do it myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/02/running-the-w3c-css-validator-locally-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

