title: SchemaTron check preceding attributes
body: <pre><code>  &lt;ROOTNODE&gt;
     &lt;Blocks&gt;
       &lt;Block&gt;
      &lt;Ref/&gt;
        &lt;BlockDates Start="2015-10-20" End="2015-10-20" /&gt;
        &lt;Types&gt;
          &lt;Type TypeCode="SGL" /&gt;
        &lt;/Types&gt;
      &lt;/Block&gt;
  
      &lt;Block&gt;
        &lt;Ref/&gt;
        &lt;BlockDates Start="2015-10-19" End="2015-10-18"/&gt;
        &lt;Types&gt;
          &lt;Type TypeCode="SGL" /&gt;
         &lt;/Types&gt;
      &lt;/Block&gt;
     &lt;/Blocks&gt;
     &lt;/ROOTNODE&gt;
  </code></pre>
  
  <p>I need to report an error if the @Start date is less than the preceding @End date. But only if the @TypeCode is the same as the preceding @TypeCode. The above should generate an error. Below is what I have tried. Any help is appreciated!</p>
  
  <pre><code>   &lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"&gt;
                  &lt;sch:pattern&gt;
                      &lt;sch:rule context="BlockDates|Type"&gt;
                              &lt;sch:report test="translate(@Start, '-', '') &amp;lt;= translate(preceding::*/@End, '-', '') and @TypeCode = preceding::*/@TypeCode"&gt; Error start date is before end date and type codes match.     &lt;/sch:report&gt;                                                               
      &lt;/sch:rule&gt;                                    &lt;/sch:pattern&gt;                                                              
      &lt;/sch:schema&gt;
  </code></pre>