コード例 #1
0
        /// <summary>Setup Validation Reporting feature which saves the validation errors in an XML file</summary>
        /// <param name="destination"> destination where XML will be sent</param>

        public void SetValidityReporting(XmlDestination destination)
        {
            JInvalidityReportGenerator reporter = processor.Implementation.createValidityReporter();

            reporter.setReceiver(destination.GetReceiver(processor.Implementation.makePipelineConfiguration()));

            this.invalidityHandler = reporter;
        }
コード例 #2
0
        // internal constructor

        internal SchemaValidator(Processor processor)
        {
            this.config = processor.Implementation;
            Object obj = config.getConfigurationProperty(JFeatureKeys.USE_XSI_SCHEMA_LOCATION);

            useXsiSchemaLocation = ((java.lang.Boolean)obj).booleanValue();
            invalidityHandler    = new net.sf.saxon.lib.StandardInvalidityHandler(processor.Implementation);
        }
コード例 #3
0
        /// <summary>
        /// Run the validation of the supplied source document, optionally
        /// writing the validated document to the supplied destination.
        /// </summary>

        public void Run()
        {
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(source);

            aug.setSchemaValidationMode(lax ? JValidation.LAX : JValidation.STRICT);
            JReceiver receiver;
            JPipelineConfiguration pipe = config.makePipelineConfiguration();

            if (destination == null)
            {
                receiver = new JSink(pipe);
            }
            else if (destination is Serializer)
            {
                receiver = ((Serializer)destination).GetReceiver(config);
            }
            else
            {
                Result result = destination.GetReceiver(pipe);
                if (result is JReceiver)
                {
                    receiver = (JReceiver)result;
                }
                else
                {
                    throw new ArgumentException("Unknown type of destination");
                }
            }
            pipe.setUseXsiSchemaLocation(useXsiSchemaLocation);
            receiver.setPipelineConfiguration(pipe);
            JParseOptions parseOptions = null;

            if (errorList != null)
            {
                invalidityHandler = new net.sf.saxon.lib.InvalidityHandlerWrappingErrorListener(new ErrorGatherer(errorList));
            }
            parseOptions = new JParseOptions();
            parseOptions.setInvalidityHandler(invalidityHandler);

            JSender.send(aug, receiver, parseOptions);
        }
コード例 #4
0
 /// <summary>Set the InvalidityHandler to be used when validating instance documents</summary>
 /// <param name="inHandler">handler the InvalidityHandler to be used</param>
 public void SetInvalidityHandler(IInvalidityHandler inHandler)
 {
     this.invalidityHandler = new InvalidityHandlerWrapper(inHandler);
 }