Search code examples
phpxmlschematron

Validate an XML against a Schematron using PHP


There are a lot of resources about Schematron... however I cant find anything related or an example on how to validate an xml against a Schematront .sch file.

Anyone?

I already found 1 or 2 very old classes that return errors... so if anyone knows how to do this, please help.


Solution

  • I use the 'ANT' option..

    Build.xml

    <project name="myName" default="all" basedir=".">
      <taskdef name="schematron"
              classname="com.schematron.ant.SchematronTask"
              classpath="lib/ant-schematron-2010-04-14.jar;lib/saxon9he.jar"/>
    
      <target name="all" description="test it">
        <schematron schema="sch/test.sch" failonerror="false" debugMode="true">
          <fileset dir="./xml" includes="*.xml"/>
        </schematron>
      </target>
    
    </project>
    

    debugMode=true shows you the intermediate XSLT file