WXS + Schematron

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:sch="http://www.ascc.net/xml/schematron">

  <xs:element name="zamestnanci">
    <xs:annotation>
      <xs:appinfo>
        <sch:pattern name="Máme dost na vyplacení platů">
          <sch:rule context="zamestnanci">
            <sch:report test="sum(zamestnanec/plat) &gt; 50000">Součet platů nemůže být větší než 50.000,-.
              Současný součet je <sch:value-of select="sum(zamestnanec/plat)"/></sch:report>
          </sch:rule>
        </sch:pattern>
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="zamestnanec" 
                    maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="jmeno" type="xs:string"/>
              <xs:element name="prijmeni" type="xs:string"/>
              <xs:element name="email" type="xs:string"
                          maxOccurs="unbounded"/>
              <xs:element name="plat" type="xs:decimal"
                          minOccurs="0"/>
              <xs:element name="narozen" type="xs:date"/>
            </xs:sequence>
            <xs:attribute name="id" type="xs:int" 
                          use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
</xs:schema>