On 09/19/2019 06:11 PM, Leif Halvard Silli wrote:


Good. Would it be possible to download your schema with the type@style
support pretty soon? Or, perhaps a "keep using HTML 5.*" addon (while we
wait for next release)?



Please replace files xhtml5.xsd and xhtml5.sch found in <XXE_install_dir>/addon/config/xhtml/xsd/5/ by attached files.

On the Mac, <XXE_install_dir> is in fact XMLmind.app/Contents/Resources/xxe/. In order to access this folder, you need to open a Finder window, right-click (or Ctrl-click) the XMLmind.app icon and select entry "Show Package Contents" from the popup menu.

IMPORTANT: after doing that, please start XXE and *clear* *the* *schema* *cache* (Options|Preferences, Advanced|Cached data, Schema cache "Clear" button) before opening any of your (X)HTML5 documents in XXE.


<?xml version="1.0" encoding="utf-8"?>

<!-- =====================================================================
     A Schematron for XHTML5 which complements xhtml5.xsd.
     Corresponds to the HTML Living Standard 2019-07-18+
     (https://html.spec.whatwg.org/).

     Authors: Hussein Shafie

     Copyright (c) 2019 XMLmind Software.

     This file is part of the XMLmind XML Editor project.
     For conditions of distribution and use, see the accompanying
     legal.txt file.
     ===================================================================== -->

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron";
          xmlns:htm="http://www.w3.org/1999/xhtml";>
  <s:ns prefix="htm" uri="http://www.w3.org/1999/xhtml"/>

  <s:pattern>
    <s:rule context="/">
      <s:report test="count(//htm:base) &gt; 1">There must be no more 
      than one base element per document.</s:report>

      <s:report test="count(//htm:meta[@charset]) &gt; 1">There must not be 
      more than one meta element with a charset attribute 
      per document.</s:report>

      <s:report test="//htm:meta[@charset] and 
                      //htm:meta[@http-equiv='content-type' or 
                                 @http-equiv='Content-Type']">A document 
     must not contain both a meta element with an http-equiv='content-type' 
     attribute and a meta element with the charset attribute present.</s:report>

      <s:report test="count(//htm:main[not(@hidden)]) &gt; 1">A document must 
      not have more than one main element that does not have the hidden 
      attribute specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:base">
      <s:assert test="@href or @target">A base element must have either 
      an href attribute, a target attribute, or both.</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:link">
      <s:assert test="count(@rel|@itemprop) = 1">A link element must have 
      either a rel attribute or an itemprop attribute, but not both.</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:meta">
      <s:assert test="count(@name|@http-equiv|@charset|@itemprop) = 1">Exactly
      one of the name, http-equiv, charset, and itemprop attributes 
      must be specified.</s:assert>

      <s:report test="(@name or @http-equiv or @itemprop) and not(@content)">If
      either name, http-equiv, or itemprop is specified, then 
      the content attribute must also be specified.</s:report>

      <s:report test="(@http-equiv='content-type' or 
                       @http-equiv='Content-Type') and 
                      not(starts-with(@content, 'text/html;'))">A meta element 
      with an http-equiv='content-type' must have a content attribute 
      which starts with 'text/html;'.</s:report>

      <s:assert test="not(@charset) or 
                      lower-case(@charset)='utf-8'">The charset attribute 
      must be an ASCII case-insensitive match for the string "utf-8".</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:style[@type]">
      <s:assert test="@type='' or 
                      lower-case(@type)='text/css'">The type attribute
      must be either the empty string nor an ASCII case-insensitive match 
      for "text/css".</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:a | htm:button">
      <s:report test=".//htm:a[@href]|
                      .//htm:audio[@controls]|
                      .//htm:button|
                      .//htm:details|
                      .//htm:embed|
                      .//htm:iframe|
                      .//htm:img[@usemap]|
                      .//htm:input|
                      .//htm:label|
                      .//htm:object[@usemap]|
                      .//htm:select|
                      .//htm:textarea|
                      .//htm:video[@controls]|
                      .//htm:*[@tabindex]">A 
      <s:value-of select="local-name()"/> element may not have
      interactive content descendants.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:a | htm:area">
      <s:report test="not(@href) and (@target or @download or @ping or @rel or
                      @hreflang or @type or @referrerpolicy)">The target, 
      download, ping, rel, hreflang, type, and referrerpolicy attributes 
      must be omitted if the href attribute is not present.</s:report>

      <s:report test="@itemprop and not(@href)">If the itemprop attribute 
      is specified on an <s:value-of select="local-name()"/> element, 
      then the href attribute must also be specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:dfn">
      <s:report test=".//htm:dfn">A dfn element may not have dfn element 
      descendants.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:time">
      <s:report test="not(@datetime) and ./*">A time element that does not have
      a datetime attribute must not have any element descendants.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:img[@ismap]">
      <s:assert test="ancestor::htm:a[@href]">The ismap attribute must not be 
      specified on an img element that does not have an ancestor a element 
      with an href attribute.</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:img[@usemap] | htm:object[@usemap]">
      <s:let name="pointer" value="substring-after(@usemap,'#')"/>
      <s:assert test="//htm:map[@name=$pointer]">Attribute usemap must point to
      a map element having 
      name=&quot;<s:value-of select="$pointer"/>&quot;.</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:embed">
      <s:report test="@itemprop and not(@src)">If the itemprop attribute 
      is specified on an embed element, then the src attribute must also 
      be specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:object">
      <s:assert test="@data or @type">At least one of either the data 
      attribute or the type attribute must be present.</s:assert>

      <s:report test="@itemprop and not(@data)">If the itemprop attribute 
      is specified on an object element, then the data attribute must 
      also be specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:video | htm:audio">
      <s:report test=".//htm:video | .//htm:audio">Element 
      <s:value-of select="local-name()"/> may not have media element 
      descendants.</s:report>

      <s:assert test="count(@src|./htm:source[1]) = 1">Element 
      <s:value-of select="local-name()"/> must have either a src attribute 
      or some source child elements, but not both.</s:assert>

      <s:report test="@itemprop and not(@src)">If the itemprop attribute 
      is specified on a <s:value-of select="local-name()"/> element, 
      then the src attribute must also be specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:map">
      <s:report test="@id != '' and @id != @name">If the id attribute is 
      specified on a map element, both id and name attributes must have 
      the same value.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:area">
      <s:assert test="ancestor::htm:map">Element area must be a descendant 
      of element map.</s:assert>

      <s:report test="@href and not(@alt)">If the area element has 
      an href attribute, the alt attribute must be present.</s:report>

      <s:report test="not(@href) and @alt">If the area element has no href 
      attribute, then the alt attribute must be omitted.</s:report>

      <s:report test="@shape and @shape != 'default' and not(@coords)">Missing 
      coords attribute.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:caption">
      <s:report test=".//htm:table">Element caption may not have 
      descendant table elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:colgroup">
      <s:report test="@span and ./htm:col">Element colgroup having 
      a span attribute may not have col child elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:dialog">
      <s:report test="@tabindex">The tabindex attribute must not be 
      specified on dialog elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:canvas">
      <s:report test=".//htm:audio[@controls]|
                      .//htm:details|
                      .//htm:embed|
                      .//htm:iframe|
                      .//htm:label|
                      .//htm:object[@usemap]|
                      .//htm:textarea|
                      .//htm:video[@controls]">A canvas element may not have
      interactive content descendants (with some exceptions such as 
      a elements, img elements with usemap attributes, etc).</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:form">
      <s:report test="descendant::htm:form">Element form may not have 
      descendant form elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:label">
      <s:report test="descendant::htm:label">Element label may not have 
      descendant label elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:input">
      <s:report test="((@type='hidden' and name='_charset_') or
                        @type='file' or
                        @type='image') and @value">The value attribute 
      must be omitted for this kind of input element.</s:report>

      <s:report test="@type='image' and not(@src)">Missing 
      src attribute.</s:report>

      <s:report test="@type='image' and not(@alt)">Missing 
      alt attribute.</s:report>

      <s:report test="@type='button' and not(@value)">Missing 
      value attribute.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:button">
      <s:report test="@type and @type != 'submit' and
                      (@formaction or @formenctype or @formmethod or 
                       @formnovalidate or @formtarget)">The formaction, 
      formenctype, formmethod, formnovalidate, and formtarget attributes 
      must not be specified unless the type of the button 
      is &quot;submit&quot;.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:option">
      <s:let name="text" value="string(.)"/>

      <!-- Not sure about this one:
      <s:report test="@label and @value and $text != ''">An option element 
      having label and value attributes may not contain some text.</s:report>
      -->

      <s:report test="(not(@label) or not(@value)) and $text = ''">An option 
      element having no label attribute or no value attribute 
      must contain some text.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:textarea">
      <s:report test="@wrap='hard' and not(@cols)">If the wrap attribute 
      is equal to &quot;hard&quot;, the cols attribute 
      must be specified.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:progress">
      <s:report test="descendant::htm:progress">Element progress may not have 
      descendant progress elements.</s:report>
    </s:rule>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:meter">
      <s:report test="descendant::htm:meter">Element meter may not have 
      descendant meter elements.</s:report>
    </s:rule>
  </s:pattern>

  <!-- idrefs ============================================================ -->
  <!-- (Not implemented for aria-* attributes.) -->

  <s:pattern abstract="true" id="idrefs">
    <s:rule context="$context">
      <s:let name="ids" value="tokenize($attr, '\s+')"/>
      <s:assert test="count($ids) = count(//htm:*[@id = $ids])">Did not find 
      some or all of the elements having one of the IDs specified in 
      the <s:value-of select="local-name($attr)"/> attribute.</s:assert>
    </s:rule>
  </s:pattern>

  <s:pattern is-a="idrefs">
    <s:param name="context" value="htm:*[@itemref]"/>
    <s:param name="attr" value="@itemref"/>
  </s:pattern>

  <s:pattern is-a="idrefs">
    <s:param name="context" value="htm:output[@for]"/>
    <s:param name="attr" value="@for"/>
  </s:pattern>

  <s:pattern>
    <s:rule context="htm:td[@headers] | htm:th[@headers]">
      <s:let name="ids" value="tokenize(@headers, '\s+')"/>
      <s:let name="table" value="(ancestor::htm:table)[last()]" />
      <!-- Not perfect. Matches IDs from subtables. -->
      <s:assert test="count($ids) = count($table//htm:th[@id = $ids])">Did not 
      find some or all of the elements having one of the IDs specified in 
      the headers attribute.</s:assert>
    </s:rule>
  </s:pattern>

</s:schema>

Attachment: xhtml5.xsd
Description: XML document

--
XMLmind XML Editor Support List
xmleditor-support@xmlmind.com
https://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to