validator / validator.github.io Goto Github PK
View Code? Open in Web Editor NEWSee https://github.com/validator/validator
See https://github.com/validator/validator
The JAR file available in the releases is not available on Maven Central. Could you please upload it to there so that other Maven projects can depend on it?
http://maven.apache.org/guides/mini/guide-central-repository-upload.html
Thanks.
I try to use the Validator on Travis. My script is simple:
script:
- "wget -O vnu.zip https://github.com/validator/validator.github.io/releases/download/20140222/vnu-20140222.zip"
- "unzip vnu.zip"
- "java -jar ./vnu/vnu.jar index.html"
Validator tells me what’s wrong with my invalid file:
"file:/home/travis/build/penibelst/jekyll-noita/index.html":5.1-5.1: error: Non-space characters found without seeing a doctype first. Expected “<!DOCTYPE html>”.
"file:/home/travis/build/penibelst/jekyll-noita/index.html":5.1-5.1: error: XHTML element “head” is missing a required instance of child element “title”.
But then I see:
The command "java -jar ./vnu/vnu.jar index.html" exited with 0.
I expect a non-zero return code on errors. Does vnu.jar
always return zero? Is there any option for make it scream on errors?
I’m not familiar with Java, so maybe my command is wrong.
When I run this repeatedly, about one in three times I get this OutOfMemoryError.
The file I'm testing against is this: https://www.dropbox.com/s/uin00m2c5bvmzyt/test_render_not_valid-16.html?dl=0
$ java -jar /Users/peterbe/Downloads/vnu/vnu.jar /var/folders/l7/9ffkzwg965gf0zl261g34n_m0000gp/T/outputtestingclient/test_render_not_valid-16.html
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:57)
at java.nio.ByteBuffer.allocate(ByteBuffer.java:331)
at sun.nio.cs.StreamDecoder.<init>(StreamDecoder.java:250)
at sun.nio.cs.StreamDecoder.<init>(StreamDecoder.java:230)
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:69)
at java.io.InputStreamReader.<init>(InputStreamReader.java:100)
at java.util.ServiceLoader.parse(ServiceLoader.java:297)
at java.util.ServiceLoader.access$200(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:349)
at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:439)
at java.nio.charset.Charset$1.getNext(Charset.java:355)
at java.nio.charset.Charset$1.hasNext(Charset.java:370)
at java.nio.charset.Charset$2.run(Charset.java:413)
at java.nio.charset.Charset$2.run(Charset.java:411)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.charset.Charset.lookupViaProviders(Charset.java:410)
at java.nio.charset.Charset.lookup2(Charset.java:487)
at java.nio.charset.Charset.lookup(Charset.java:475)
at java.nio.charset.Charset.isSupported(Charset.java:517)
at com.ibm.icu.charset.CharsetProviderICU.getJavaCanonicalName(CharsetProviderICU.java:225)
at com.ibm.icu.charset.CharsetProviderICU.getCharset(CharsetProviderICU.java:149)
at com.ibm.icu.charset.CharsetProviderICU.putCharsets(CharsetProviderICU.java:291)
at com.ibm.icu.charset.CharsetProviderICU.charsets(CharsetProviderICU.java:308)
at java.nio.charset.Charset$4.run(Charset.java:593)
at java.nio.charset.Charset$4.run(Charset.java:585)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.charset.Charset.availableCharsets(Charset.java:584)
at nu.validator.htmlparser.io.Encoding.<clinit>(Encoding.java:104)
at nu.validator.htmlparser.io.MetaSniffer.tryCharset(MetaSniffer.java:147)
at nu.validator.htmlparser.impl.MetaScanner.handleTagInner(MetaScanner.java:819)
at nu.validator.htmlparser.impl.MetaScanner.handleTag(MetaScanner.java:809)
at nu.validator.htmlparser.impl.MetaScanner.stateLoop(MetaScanner.java:507)
Version here:
$ java -jar /Users/peterbe/Downloads/vnu/vnu.jar --version
20140901
If I use the validator jar on the command line for parsing HTML5 files (local or URL based), I get a XHTML error:
java -jar ~/software/vnu/vnu/vnu.jar --html /software/vnu/vnu/index.html/software/vnu/vnu/index.html":140.23-140.23: error: XHTML element “style” not allowed as child of XHTML element “p” in this context. (Suppressing further errors from this subtree.)
"file:
If instead I run using the http client against a locally running standalone vnu instance I get an error which doesn't reference XHTML:
java -cp ~/software/vnu/vnu/vnu.jar nu.validator.client.HttpClient /software/vnu/vnu/index.html/software/vnu/vnu/index.html":140.1-140.23: error: Element "style" not allowed as child of element "p" in this context. (Suppressing further errors from this subtree.)
"
Why the difference in error reporting?
Hi Michael,
It seems that the validator does not detect all the orphan attributes that should point to another element with an attribute of type ID.
For instance, this gist:
https://gist.github.com/cavweb20/d3d5b2e457bce4b603bd
does not throw any error.
We have compiled (@cleancoderocker) a list of the relevant HTML 5 attributes, in case it helps you:
https://github.com/webcc/wcag20/wiki/HTML5-attributes-pointing-to-elements-with-ID
There seems to be a bug in the latest release with --format flag.
Test file: https://gist.github.com/cavweb20/a24915082675227cc65a#file-gistfile1-html
Running:
java -jar vnu.jar test_01.html
gives correctly:
"file:test_01.html":9.12-9.12: error: The element “header” must not appear as a descendant of the “footer” element.
But:
java -jar vnu.jar --format json test_01.html
gives an exception:
"file:test_01.html":-1:-1: warning: Illegal state for callback.
Exception in thread "main" org.xml.sax.SAXException: Illegal state for callback.
at nu.validator.json.Serializer.endObject(Serializer.java:227)
at nu.validator.messages.JsonMessageEmitter.endMessages(JsonMessageEmitter.java:107)
at nu.validator.messages.MessageEmitterAdapter.end(MessageEmitterAdapter.java:639)
at nu.validator.client.SimpleCommandLineValidator.end(SimpleCommandLineValidator.java:205)
at nu.validator.client.SimpleCommandLineValidator.main(SimpleCommandLineValidator.java:175)
Also:
java -jar vnu.jar --format xml test_01.html
gives an exception:
Exception in thread "main" java.util.NoSuchElementException
at java.util.LinkedList.getFirst(LinkedList.java:242)
at nu.validator.htmlparser.sax.XmlSerializer.startPrefixMappingPrivate(XmlSerializer.java:728)
at nu.validator.htmlparser.sax.XmlSerializer.startElement(XmlSerializer.java:554)
at nu.validator.messages.XmlSaxEmitter.startElement(XmlSaxEmitter.java:49)
at nu.validator.messages.XmlMessageEmitter.startMessage(XmlMessageEmitter.java:92)
at nu.validator.messages.MessageEmitterAdapter.startMessage(MessageEmitterAdapter.java:1575)
at nu.validator.messages.MessageEmitterAdapter.messageWithoutExtract(MessageEmitterAdapter.java:798)
at nu.validator.messages.MessageEmitterAdapter.message(MessageEmitterAdapter.java:731)
at nu.validator.messages.MessageEmitterAdapter.messageFromSAXParseException(MessageEmitterAdapter.java:698)
at nu.validator.messages.MessageEmitterAdapter.error(MessageEmitterAdapter.java:507)
at nu.validator.messages.MessageEmitterAdapter.error(MessageEmitterAdapter.java:469)
at org.whattf.checker.Checker.err(Checker.java:106)
at org.whattf.checker.schematronequiv.Assertions.startElement(Assertions.java:1584)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at com.thaiopensource.xml.sax.ForkContentHandler.startElement(Unknown Source)
at nu.validator.htmlparser.sax.SAXStreamer.elementPushed(SAXStreamer.java:146)
at nu.validator.htmlparser.sax.SAXStreamer.elementPushed(SAXStreamer.java:35)
at nu.validator.htmlparser.impl.TreeBuilder.push(TreeBuilder.java:4505)
at nu.validator.htmlparser.impl.TreeBuilder.appendToCurrentNodeAndPushElementMayFoster(TreeBuilder.java:5248)
at nu.validator.htmlparser.impl.TreeBuilder.startTag(TreeBuilder.java:2058)
at nu.validator.htmlparser.impl.Tokenizer.emitCurrentTagToken(Tokenizer.java:1138)
at nu.validator.htmlparser.impl.Tokenizer.stateLoop(Tokenizer.java:1653)
at nu.validator.htmlparser.impl.Tokenizer.tokenizeBuffer(Tokenizer.java:1351)
at nu.validator.htmlparser.io.Driver.runStates(Driver.java:302)
at nu.validator.htmlparser.io.Driver.tokenize(Driver.java:219)
at nu.validator.htmlparser.sax.HtmlParser.tokenize(HtmlParser.java:480)
at nu.validator.htmlparser.sax.HtmlParser.parse(HtmlParser.java:423)
at nu.validator.validation.SimpleDocumentValidator.checkAsHTML(SimpleDocumentValidator.java:320)
at nu.validator.validation.SimpleDocumentValidator.checkHtmlFile(SimpleDocumentValidator.java:277)
at nu.validator.client.SimpleCommandLineValidator.checkHtmlFile(SimpleCommandLineValidator.java:266)
at nu.validator.client.SimpleCommandLineValidator.checkFiles(SimpleCommandLineValidator.java:218)
at nu.validator.client.SimpleCommandLineValidator.main(SimpleCommandLineValidator.java:174)
This is using the latest version from https://github.com/validator/validator.github.io .
Calling .setHtml(true)
when initializing the MessageEmitterAdapter
seems to cause the repetition of the first letter in the sentence of some validation messages:
Here's the main relevant part of my code, although I think the bug should be reproducible without it: https://github.com/cvrebert/lmvtfy/blob/master/src/main/scala/com/chrisrebert/lmvtfy/validation/Html5Validator.scala
It's in Scala but heavily based on your SimpleCommandLineValidator
. I'm happy to help out if you have any trouble reproducing the problem. I have a couple of reliable Specs2 testcases that catch the bug.
X-Ref: validator/validator#2
Is there some JavaDoc available so that I could wrap the validator in another project?
$ java -jar vnu.jar http://jsbin.com/giquho/2/
"http://jsbin.com/giquho/2":20.6-20.6: error: Stray start tag “body”.
"http://jsbin.com/giquho/2":20.6-20.6: error: An “body” start tag seen but an element of the same type was already open.
Note the An “body”
, which is grammatically incorrect.
X-Ref: validator/validator#1
Hello - newfag here, trying to build on raspberry pi 2:
"python ./build/build.py --stacksize=16384 build" does work.
"python ./build/build.py --stacksize=16384 run" does work
"python ./build/build.py --stacksize=16384 test" crashes with stackoverflow error
so i can't build it with the "all" option.
what can i do to resolve this error?
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.