4

The sitemap of my company's brand's website seems to be fine when I look at it at first glance. I don't particularly see any errors as such. However, SEMrush, the SEO tool, reports that our sitemap is not in the correct format. SEMrush doesn't tell me what's wrong. It just says that the format is incorrect.

So, I submitted the sitemap to this online validator:

https://www.xml-sitemaps.com/index.php?op=validate-xml-sitemap&go=1&sitemapurl=http%3A%2F%2Fwww.photojaanic.com%2Fsitemap.xml&submit=Validate+Sitemap

It says no issues found. But, when I run it through another tool:

http://tools.seochat.com/tools/site-validator/

It returns several errors for the lastmod tags. Here's one of them:

<url><loc>http://www.photojaanic.com/photo-gifts/keychains</loc>
<lastmod>2017-07-24T04:37Z</lastmod><changefreq>yearly</changefreq></url>

Error 1826: Element '{http://www.sitemaps.org/schemas/sitemap/0.9}lastmod': '2017-07-24T04:37Z' is not a valid value of the union type '{http://www.sitemaps.org/schemas/sitemap/0.9}tLastmod'. on line: 5 column: 0

Could this be the reason why the sitemap is wrong? I wonder why the date-time format is wrong.

I also tried another validator. Even that one returns many errors along with the lastmod issue:

http://freetools.webmasterworld.com/tools/site-validator

I'm not so concerned about the other errors as they're related to video or images. That could be rectified. What I'm concerned is about the lastmod tag.

A way to get around the lastmod issue could be to simply exclude the time. However, I'd like to know why there's an error.

1
  • 2
    Google doesn't even use the lastmod field in sitemaps. Just take it out along with priority and changefreq. Just leave in the url and any hreflangs. Jan 23, 2018 at 12:49

3 Answers 3

4

Per the schema, tLastMod is the union of xsd:date and xsd:dateTime.

Since you provide hours, you are not in the first case, so your string should conform to the XSD dateTime type, and it does not: you need to specify the part with seconds.

See https://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/#dateTime-lexical-mapping for the full format.

So, if you try with 2017-07-24T04:37:00Z the validation error on this element should go away.

11
  • 1
    The link you quote is note the norm, just a note. The norm I have referenced clearly say the seconds are mandatory. Note that your note is from 2007, the norm from 2012. Jan 23, 2018 at 15:17
  • 1
    Yes, but this W3C Note is referenced by the sitemaps specification page as well as by the schema, which says (in xsd:documentation): "The date must conform to the W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime)." So the sitemaps specification references exactly this W3C Note, but specifies the schema in a different way. -- My interpretation is that the spec (not the schema) is normative for authors (it’s what they read/follow after all; most probably don’t read the schema itself).
    – unor
    Jan 23, 2018 at 21:18
  • 1
    The xsd:documentation is not the normative part, and it can be ignored. The sitemap schema uses xsd:date and xsd:dateTime and you have xmlns:xsd="http://www.w3.org/2001/XMLSchema" on top so this is the only norm to follow. If you go there you can follow to https://www.w3.org/TR/xmlschema11-2/ aka "W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes" and its dateTime part has the full definition. This is the norm, do not rely on what you find in documentation. The sitemap doc was written before so its documentation referenced something else, now obsolete. Jan 23, 2018 at 21:25
  • 1
    The subject comes regularly, like in IETF circles or such. The normative part of a definition is always the schema (or equivalent, since there are multiple ways to write it), not the accompanying text/documentation. Because the later could be ambiguous to parse, where the former should not be. The text is here to help understand the schema, but the schema is the king. Jan 23, 2018 at 21:29
  • 1
    In fact from the same norm you can read about xsd:documentation or its parent xsd:annotation. Quote: "Annotations do not participate in ·validation· as such. Provided an annotation itself satisfies all relevant ·Schema Component Constraints· it cannot affect the ·validation· of element information items.". You can remove xsd:annotation elements from any XML schema file, and things will work the exact same way validation-wise. Jan 23, 2018 at 21:34
2

The tool http://tools.seochat.com/tools/site-validator/ gives no error when also specifying the seconds:

<lastmod>2017-07-24T04:37:00Z</lastmod>

Are the seconds required for a datetime? There is a conflict in the spec vs. the schema:

2

Make sure none of your values are blank. I troubleshooted this for a while and realized my "last edit date" field for certain entries was blank and thus it was causing markup errors in the XML file due to nothing populating for certain URLs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.