0

this xml file

<?xml version="1.0" encoding="utf-8"?>
<root>
  <a>Only Text</a>
  <a>
    <b>Child node</b>
  </a>
  <a>
    <b>Child node</b>
    Mixed content
  </a>
</root>

and this xsd file

<?xml version="1.0" encoding="UTF-8"?>
<iso:schema xmlns:iso="http://purl.oclc.org/dsdl/schematron">
  <iso:pattern id="children tests">
    <iso:rule context="a">
      <iso:assert test="empty(child::node())">
        Element has nodes
      </iso:assert>
      <iso:assert test="empty(child::*)">
        Element has child elements
      </iso:assert>
      <iso:assert test="empty(child::text())">
        Element has text
      </iso:assert>
      <iso:report test="child::text() and empty(child::*)">
        Element has only text
      </iso:report>
    </iso:rule>
  </iso:pattern>
</iso:schema>

and this code

  Validator validator = new Validator();
                //validator.XmlSchemas.Add("", @"C:\project\Schematron\ConsoleApplication2\shematron\pdfdogschematron.sch");
                validator.AddSchema(@"C:\project\Schematron\ConsoleApplication2\shematron\book.xsd");
                IXPathNavigable a = validator.Validate(new XmlTextReader(@"C:\project\Schematron\ConsoleApplication2\shematron\dog.xml"));

I am using NMatrix.Schematron validator but it's not correctly.The method don't exception always.

MiMo
  • 11,793
  • 1
  • 33
  • 48
bkiyak
  • 1
  • 2
  • Btw, the question where this samples are coming from has been updated: http://stackoverflow.com/questions/14651586/identify-xml-text-elements-with-schematron Maybe you get the Schematron exceptions with the updated rules from there... – Clemens Aug 18 '13 at 21:54

1 Answers1

0

The first problem I can suggest is that you're using NMatrix.Schematron, which is a native .NET Schematron 1.5 validator. It does not support ISO schematron. I suggest you use the XRouter SchemaTron (available here)

gap
  • 2,766
  • 2
  • 28
  • 37