Validation may fail for items with HTML5 tags in their presenation

  • Description

    When using HTML5 in item presentation or adding HTML5 tags to item fields (for example, a Rich Text field), default Sitecore item and field validation may fail.

    This may also prevent items from being approved in a workflow state. The following messages may appear in the validation results:

    • Is rendered item valid XHTML document
      The item must render as a valid XHTML document.
    • Is valid XHtml
      Field must be a valid XHtml document.

    The issue occurs because Sitecore validates the item markup and field contents using an XSD scheme validator which fails for HTML5-specific tags such as <article>, <details>, <dialog>, etc.

  • There is no validation schema for HTML5 available yet. However, it is possible to extend the current XSD schema that Sitecore uses for XHTML validation to allow some of the HTML5 tags. The original schema file is located and specified in the XHtmlSchemaFile setting in web.config:

    <setting name="XHtmlSchemaFile" value="/sitecore/shell/schemas/sitecore xhtml.xsd" />

    For example,  to allow the <article> tag, you should modify the schema file as follows:

    1. Create a new xs:element node under the root node for the <article> tag:
      <xs:element name="article">
          <xs:complexType mixed="true">
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="block" />
              <xs:group ref="inline" />
              <xs:group ref="misc" />
            </xs:choice>
            <xs:attributeGroup ref="coreattrs" />
          </xs:complexType>
        </xs:element>
    2. Add the newly created element definition to the group of block elements:
      <xs:group name="block">
          <xs:choice>
            <xs:element ref="p" />
            <xs:group ref="heading" />
            <xs:element ref="div" />
            <xs:group ref="lists" />
            <xs:group ref="blocktext" />
            <xs:element ref="fieldset" />
            <xs:element ref="table" />
            <xs:element ref="article" />
          </xs:choice>
        </xs:group>

    Alternatively, it is possible to disable XHTML validation so that items with HTML5 markup can be approved in a workflow. To do this, remove Full Page XHtml and Is Xhtml rules from the Workflow field of the following items:

    • /sitecore/system/Settings/Validation Rules/Field Types/Rich Text
    • /sitecore/system/Settings/Validation Rules/Global Rules

Applies to:

CMS 6+

January 06, 2016
January 06, 2016

Reference number:

353612

Keywords: 

  • CMS