Sitecore 6 XHTML Validation and the Embed HTML Element

Published by on
Tags:

The embed HTML element is not a valid XHTML element, this creates a problem when you want to insert objects into your Rich Text fields such as You Tube videos. To validate XHTML sitecore uses the file /sitecore/shell/schemas/sitecore xhtml.xsd. By editing this file we can allow usage of the embed element.

Beneath the /xs:schema node add a definition for the embed element:

 <xs:element name="embed">
    <xs:complexType mixed="true">
      <!-- from http://www.htmlref.com/Reference/AppA/tag_embed.htm -->
      <xs:attribute name="align" type="xs:string" />
      <xs:attribute name="alt" type="xs:string" />
      <xs:attribute name="class" type="xs:string" />
      <xs:attribute name="code" type="xs:string" />
      <xs:attribute name="codebase" type="xs:string" />
      <xs:attribute name="height" type="xs:string" />
      <xs:attribute name="hspace" type="xs:string" />
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="language" type="xs:string" />
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="src" type="xs:string" />
      <xs:attribute name="style" type="xs:string" />
      <xs:attribute name="title" type="xs:string" />
      <xs:attribute name="unselectable" type="xs:string" />
      <xs:attribute name="vspace" type="xs:string" />
      <xs:attribute name="width" type="xs:string" /
      <!-- used by you tube -->
      <xs:attribute name="type" type="xs:string" />
      <xs:attribute name="allowscriptaccess" type="xs:string" />
      <xs:attribute name="allowfullscreen" type="xs:string" />
    </xs:complexType>
  </xs:element>

This definition was created based on the attributes list at http://www.htmlref.com/Reference/AppA/tag_embed.htm and some attributes used by You Tube. You may need to define additional attributes as needed.

Next we need to add a reference to the new embed definition in the object definition. Find the definition and replace the first part with the following which has the embed reference:

  <xs:element name="object">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="embed" />
        <xs:element ref="param" />
        <xs:group ref="block" />
        <xs:element ref="form" />
        <xs:group ref="inline" />
        <xs:group ref="misc" />
      </xs:choice>
   ...

Save the file and your embed element problems should disappear. Remember however that doing this will mean that your site is no longer XHTML strict.

 

All blogs tagged with ' validation'

Projects

Have you read?

Images and JavaScript



Blogs by date