com.bitplan.w3ccheck
Class W3CValidator

java.lang.Object
  extended by com.bitplan.w3ccheck.W3CValidator

public class W3CValidator
extends Object

Wrapper for W3C Validator Soap responses see W3C Markup Validation Service Request Format

Author:
wf the JaxB annotations of this Wrapper are designed to be able to unmarshal a W3C Markup Validation Service Soap 1.2 response to this Java Object on the class level the root node of the SOAP message is covered:
 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 ...
 </env:Envelope>
 
 
According to W3C Markup Validation Service Request Format documentation: A SOAP response for the validation of a document (invalid) will look like this:
 <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
      <env:Body>
        <m:markupvalidationresponse
          env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" 
          xmlns:m="http://www.w3.org/2005/10/markup-validator">
            <m:uri>http://qa-dev.w3.org/wmvs/HEAD/dev/tests/xhtml1-bogus-element.html</m:uri>
            <m:checkedby>http://validator.w3.org/</m:checkedby>
            <m:doctype>-//W3C//DTD XHTML 1.0 Transitional//EN</m:doctype>
            <m:charset>utf-8</m:charset>
            <m:validity>false</m:validity>
            <m:errors>
              <m:errorcount>1</m:errorcount>
              <m:errorlist>
              		          
                <m:error>
                  <m:line>13</m:line>
                  <m:col>6</m:col>                                           
                  <m:source><![CDATA[
                    &#60;foo<strong title="Position where error was detected.">&#62;</strong>This phrase is enclosed in a bogus FOO element.&#60;/foo&#62;
                  ]]>
                  </m:source>                                           
                  <m:explanation>
                    <![CDATA[
                    <p> ... </p<p>
                    ]]>
                  </m:explanation>                                           
                  <m:messageid>76</m:messageid>                                           
                  <m:message>element "foo" undefined</m:message>
               </m:error>
          </m:errorlist>
        </m:errors>
        <m:warnings>
          <m:warningcount>0</m:warningcount>
          <m:warninglist>	        
            ...		        
          </m:warninglist>
        </m:warnings>
      </m:markupvalidationresponse>
     </env:Body>
  </env:Envelope>
		
 
the structure of this W3CValidator class is aligned to this format

Nested Class Summary
static class W3CValidator.Body
          structure for the Body node of the message {@code ...
 
Field Summary
 W3CValidator.Body body
          field that holds the structure for the Body node of the message {@code ...
static boolean debug
          set to true if Logging should be enabled
protected static Logger LOGGER
          Logging may be enabled by setting debug to true
 
Constructor Summary
W3CValidator()
           
 
Method Summary
static W3CValidator check(String url, String html)
          create a W3CValidator result for the given url with the given html
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
set to true if Logging should be enabled


LOGGER

protected static Logger LOGGER
Logging may be enabled by setting debug to true


body

public W3CValidator.Body body
field that holds the structure for the Body node of the message
 <env:Body>
 ...
 </env:Body>
 
 

Constructor Detail

W3CValidator

public W3CValidator()
Method Detail

check

public static W3CValidator check(String url,
                                 String html)
                          throws JAXBException
create a W3CValidator result for the given url with the given html

Parameters:
url - - the url of the validator e.g. "http://validator.w3.org/check"
html - - the html code to be checked
Returns:
- a W3CValidator response according to the SOAP response format or null if the http response status of the Validation service is other than 200 explained at response http://validator.w3.org/docs/api.html#requestformat
Throws:
JAXBException - if there is something wrong with the response message so that it can not be unmarshalled


Copyright © 2014. All rights reserved.