Ejemplo n.º 1
0
        public ValidationResult Validate(string xmlFileToValidate)
        {
            var input = new XmlDocument();

            input.Load(xmlFileToValidate);
            var output = new XmlDocument();

            _mananger.Validate(_xsltFileProvider.Path, input, output);

            var result = SchematronValidationResult.Parse(output);


            return(new ValidationResult());
        }
Ejemplo n.º 2
0
        public static SchematronValidationResult Parse(XmlDocument schematronResultDocument)
        {
            var navigator = schematronResultDocument.CreateNavigator();

            var result = new SchematronValidationResult();

            navigator.MoveToFirstChild();
            var ns = navigator.NamespaceURI;

            if (navigator.LocalName != "schematron-output")
            {
                throw new IndexOutOfRangeException("Not a schematron result file.");
            }

            navigator.MoveToFirstChild();
            while (navigator.NodeType != XPathNodeType.Element)
            {
                navigator.MoveToNext();
            }

            do
            {
                switch (navigator.LocalName)
                {
                case "ns-prefix-in-attribute-values":
                    result.NamespaceUri    = navigator.GetAttribute("uri", ns);
                    result.NamespacePrefix = navigator.GetAttribute("prefix", ns);
                    break;

                case "active-pattern":
                    result.Patterns.Add(SchematronValidationResultPattern.Parse(navigator));
                    break;
                }
            } while (navigator.MoveToNext());

            return(result);
        }