0

このxmlファイル

<?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>

そしてこのxsdファイル

<?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>

そしてこのコード

  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"));

NMatrix.Schematron バリデーターを使用していますが、正しくありません。メソッドは常に例外ではありません。

4

1 に答える 1