Schematron is a language and toolkit for making assertions about the presence or absense of patterns in XML documents.
Schematron can be used instead of DTDs or W3C XML Schemas, but also to complement them. Schematron schemas can represent many useful structures that DTDs or W3C XML Schemas cannot: for example, relationships between attribute values and elements.
For documentation on Schematron, see http://www.ascc.net/xml/schematron.
There is a mail-list for Schematron developers and people interested in rule-based schema languages: The Schematron Love-In.
One of Schematron's strengths is that it is almost trivially implementable on top of XSLT processors, so it is widely available. You can take take the XSLT code and schemas in this distribution and use them in server environments, hosted in Perl, Java, Python or even from .BAT files or UNIX shell scripts. The XLST scripts and Schematron schemas in this distribution are Open Source.
(Note. The current version of the Topologi Schematron Validator framework is not Open Source; Topologi is using this tool for internal development work on route to future products; please check out the Topologi website at http://www.topologi.com/ for updates.)