Environment: RelaxngValidatingReader .Net 2.0 Framework
I can't seem to get the validator to equal false, no matter how much I change the xml around. Am I missing some concept here?
Resource
https://github.com/mono/mono/tree/master/mcs/class/Commons.Xml.Relaxng
rnc compact format
start = root
root = element root { parent1* & parent2* }
parent1 = element parent1 { element field { attribute usecase_123 {text} } }
parent2 = element parent2 { element field { attribute usecase_AAA {text} } }
xml instance
<?xml version="1.0" encoding="utf-8" ?>
<root>
<parent1>
<hello/>
</parent1>
</root>
Main Program
static void Main(string[] args)
{
RncParser parser = new RncParser(new NameTable());
TextReader source = new StreamReader("test.rnc");
RelaxngPattern grammar = parser.Parse(source);
XmlReader instance = new XmlTextReader("XMLFile1.xml");
RelaxngValidatingReader reader = new RelaxngValidatingReader(instance, grammar);
Console.WriteLine("Was the xml valid? {0}", reader.Read());
}
You have to repeat
Read()
until End-of-file: