Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date validation fails #11

Open
gregorko opened this issue Aug 17, 2015 · 1 comment
Open

Date validation fails #11

gregorko opened this issue Aug 17, 2015 · 1 comment

Comments

@gregorko
Copy link

Hello,

the following code snippet causes a date validation failure. I guess its because the seconds are 0 and missing in the rendered date string.

        WebSitemapGenerator generator = WebSitemapGenerator.builder(
                "https://github.com", new File( filePath ))
                .autoValidate(true).build();
        generator.addUrl(
                new WebSitemapUrl.Options("https://github.com/dfabulich/sitemapgen4j")
                        .lastMod(new Date(1408464120000L))
                        .build() );
        generator.write();

The error:

Caused by: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 46; cvc-datatype-valid.1.2.3: "2014-08-19T18:02+02:00" ist kein gültiger Wert des Vereinigungsmengentyps "tLastmod".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:458)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3237)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3152)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3062)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2140)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:859)
    at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:584)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
    at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.validate(ValidatorHandlerImpl.java:730)
    at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:102)
    at javax.xml.validation.Validator.validate(Validator.java:124)
    at com.redfin.sitemapgenerator.SitemapValidator.validateXml(SitemapValidator.java:75)
    at com.redfin.sitemapgenerator.SitemapValidator.validateWebSitemap(SitemapValidator.java:61)
    at com.redfin.sitemapgenerator.SitemapGenerator.writeSiteMap(SitemapGenerator.java:238)
@dfabulich
Copy link
Owner

It's not clear to me what to do about this. I think the XSD validator is in disagreement with http://www.w3.org/TR/NOTE-datetime which explicitly calls out "1997-07-16T19:20+01:00" as valid.

I'm 99% sure major search engines will accept it anyway, so I'm not inclined to fix it right away; a patch would be welcome.

In the meantime, the workaround is to specify a W3C DateFormat that includes seconds, or to skip XSD validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants