<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron">

  <p>
    Copyright © 2007 Jarno Elovirta
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see &lt;http://www.gnu.org/licenses/>.  
  </p>
  
  <pattern is-a="self_nested_element">
    <param name="element" value="*[contains(@class, ' topic/xref ')]"/>
  </pattern>
  
  <pattern is-a="nested_element">
    <param name="element" value="*[contains(@class, ' topic/title ')]"/>
    <param name="descendant" value="*[contains(@class, ' topic/xref ')]"/>
  </pattern>

  <pattern is-a="deprecated_element">
    <param name="context" value="*"/>
    <param name="element" value="*[contains(@class, ' topic/boolean ')]"/>
    <param name="reason" value="'The state element should be used instead.'"/>
  </pattern>

  <pattern is-a="deprecated_attribute">
    <param name="context" value="*[contains(@class, ' topic/image ')]"/>
    <param name="attribute" value="'alt'"/>
    <param name="reason" value="'The alt element should be used instead.'"/>
  </pattern>

  <pattern is-a="deprecated_attribute">
    <param name="context" value="*[contains(@class, ' topic/link ')] |
                                 *[contains(@class, ' map/topicref ')]"/>
    <param name="attribute" value="'query'"/>
    <param name="reason" value="'It may be removed in the future.'"/>
  </pattern>

  <pattern abstract="true" id="self_nested_element">
    <rule context="$element">
      <report test="descendant::$element">
        The <name/> contains a <name/>. The results in processing are undefined.
      </report>
    </rule>
  </pattern>
  
  <pattern abstract="true" id="nested_element">
    <rule context="$element">
      <report test="descendant::$descendant">
        The <name/> contains <name path="descendant::$descendant"/>. Using <name path="descendant::$descendant"/> in this context is ill-adviced.
      </report>
    </rule>
  </pattern>

  <pattern abstract="true" id="deprecated_element">
    <rule context="$context">
      <report test="$element">
        The <name/> element is deprecated. <value-of select="$reason"/>
      </report>
    </rule>
  </pattern>
  

  <pattern abstract="true" id="deprecated_attribute">
    <rule context="$context">
      <report test="@*[name() = $attribute]">
        The <value-of select="$attribute"/> attribute is deprecated. <value-of select="$reason"/>
      </report>
    </rule>
  </pattern>

  <pattern>
    <rule context="*[not(@id)]">
      <report test="*[contains(@class, ' topic/title ')]" role="info" diagnostics="link_target">
       <name/> with a title should have an id attribute.
      </report>
    </rule>
  </pattern>
  
  <diagnostics>
    <diagnostic id="link_target">
      Elements with titles are candidate targets for elements level links.
    </diagnostic>
  </diagnostics>  

</schema>
