<?xml version="1.0"?>
<!-- Validator for complex XHTML nesting requirements -->
<!-- Original templates by Rick Jelliffe, ricko@gate.sinica.edu.tw.
        Copyright (C) 1999 Rick Jelliffe and Academia Sinica
        Computing Centre. Free use granted under GPL or MPL.
-->

<!-- Template for XSL Validator -->
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/TR/WD-xsl" 
    xmlns="http://www.w3.org/TR/REC-html40" 
    result-ns="http://www.w3.org/Profiles/xhtml1-strict.dtd"  
><!-- add any other namespace declarations above -->
  <!-- Root template - start processing here -->
  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <meta http-equiv="Expires" content="0" />
        <title>Results of Validation (using XSL)</title>
      </head>
      <body>
        <h1>Results</h1>
        <p>Your XHTML document has been checked for elements
        which should not have been nested in other elements.
        The results follow. For more information on XHMTL
        refer to <a href="http://www.w3.org/TR/WD-html-in-xml"
        >http://www.w3.org/TR/WD-html-in-xml</a>, Appendix B.
        For more information on this script, see 
        <a href="http://www.ascc.net/xml/en/utf-8/XSLvalidation.html"
        >http://www.ascc.net/xml/en/utf-8/XSLvalidation.html</a>.
        <ul>
          <xsl:apply-templates/>    
        </ul> </p>
        <p>(end of check)</p>
        <br />
        <p>Made for the 
        <a href="http://www.ascc.net/xml/">Chinese XML Now!</a> project</p>
      </body>
    </html>
  </xsl:template>                        
     
  <xsl:macro name="element_warning_message" >
    The invalid element is found at tree location <xsl:number  level="multi" count="*" format="1." />
    <xsl:if test='.[@ID]'>
    The element's ID is <xsl:value-of select="@ID" />.
    </xsl:if>
    <xsl:if test='..[@ID]'> The element's parent's ID is <xsl:value-of select="../@ID" />.
    </xsl:if>
  </xsl:macro > 
  
  <!-- Check elements for which are not permitted -->
  
  <xsl:template match="a[ancestor(a)]">
    <li>        
    The element "a" has been found inside another element "a".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
  </xsl:template>
   
  <xsl:template match="label[ancestor(label)]">
    <li>        
    The element "label" has been found inside another element "label".
    <xsl:invoke macro="element_warning_message" />
    </li>
  <xsl:apply-templates/> 
    
  </xsl:template><xsl:template match="form[ancestor(form)]">
    <li>        
    The element "a" has been found inside another element "a".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
  </xsl:template> 
  
 <xsl:template match="img[ancestor(pre)]">
    <li>        
    The element "img" has been found inside another element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
  </xsl:template>
  
 
 <xsl:template match="object[ancestor(pre)]">
    <li>        
    The element "object" has been found inside another element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
 </xsl:template>
 
 <xsl:template match="big[ancestor(pre)]">
    <li>        
    The element "big" has been found inside an element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
 </xsl:template> 
 
 
 <xsl:template match="small[ancestor(pre)]">
    <li>        
    The element "small" has been found inside an element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
 </xsl:template>
 
 
 <xsl:template match="sub[ancestor(pre)]">
    <li>        
    The element "sub" has been found inside an element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>
  
 <xsl:template match="sup[ancestor(pre)]">
    <li>        
    The element "sup" has been found inside an element "pre".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>

 <xsl:template match="select[ancestor(button)]">
    <li>        
    The element "select" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>
        
 <xsl:template match="textarea[ancestor(button)]">
    <li>        
    The element "textarea" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>

 <xsl:template match="label[ancestor(button)]">
    <li>        
    The element "label" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>

 <xsl:template match="button[ancestor(button)]">
    <li>        
    The element "button" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>

 <xsl:template match="form[ancestor(button)]">
    <li>        
    The element "form" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template> 

 <xsl:template match="fieldset[ancestor(button)]">
    <li>        
    The element "fieldset" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>
       
 <xsl:template match="iframe[ancestor(button)]">
    <li>        
    The element "iframe" has been found inside an element "button".
    <xsl:invoke macro="element_warning_message" />
    </li>
    <xsl:apply-templates/> 
   </xsl:template>


  <xsl:template match="text()" priority="-1">
    <!-- strip characters -->
  </xsl:template>

</xsl:stylesheet>

