Example #1
0
        private void InitFromConfiguration(IPreloadedConverterConfiguration configuration)
        {
            if (configuration.TransformStylesheetPath == null)
            {
                throw new ArgumentNullException("configuration.TransformStylesheetPath");
            }
            try {
                XsltSettings   xsltSettings = new XsltSettings(true, true);
                XmlUrlResolver resolver     = new XmlUrlResolver();

                _closeSourceStream = configuration.CloseSourceStream;
                _transform         = new XslCompiledTransform();
                //Tries to load the transformation path, if the path is not absolute and the file
                //does not exists then try with the appdomain base directory as root folder
                string transformationPath = configuration.TransformStylesheetPath;
                if (!Path.IsPathRooted(transformationPath) && !File.Exists(transformationPath))
                {
                    transformationPath = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + transformationPath;
                    transformationPath = Path.GetFullPath(transformationPath);
                }

                _transform.Load(transformationPath, xsltSettings, resolver);

                IValidator resultSchemaValidator = null;
                if (TryInitSchemaValidator(configuration.ResultSchemaConfiguration, out resultSchemaValidator))
                {
                    _resultValidators.Add(resultSchemaValidator);
                }

                IValidator sourceSchemaValidator = null;
                if (TryInitSchemaValidator(configuration.SourceSchemaConfiguration, out sourceSchemaValidator))
                {
                    _sourceValidators.Add(sourceSchemaValidator);
                }

                IEnumerable <ISchematronValidatorConfiguration> resultSchematrons = configuration.GetResultSchematronConfigurations();
                if (resultSchematrons != null)
                {
                    foreach (ISchematronValidatorConfiguration schematronConfiguration in resultSchematrons)
                    {
                        SchematronValidator validator = new SchematronValidator(schematronConfiguration);
                        _resultValidators.Add(validator);
                    }
                }

                IEnumerable <ISchematronValidatorConfiguration> sourceSchematrons = configuration.GetSourceSchematronConfigurations();
                if (sourceSchematrons != null)
                {
                    foreach (ISchematronValidatorConfiguration schematronConfiguration in sourceSchematrons)
                    {
                        SchematronValidator validator = new SchematronValidator(schematronConfiguration);
                        _sourceValidators.Add(validator);
                    }
                }
            }
            catch (Exception ex) {
                throw new ConverterException("Initiation of the Converter failed, used stylesheetpath=" + configuration.TransformStylesheetPath, ex);
            }
        }
Example #2
0
 public PreloadedConverter(IPreloadedConverterConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     InitFromConfiguration(configuration);
 }
Example #3
0
 public TypedPreloadedConverter(IPreloadedConverterConfiguration configuration)
 {
     Init();
     _innerConverter = new PreloadedConverter(configuration);
 }
Example #4
0
        public PreloadedConverter()
        {
            IPreloadedConverterConfiguration configuration = (IPreloadedConverterConfiguration)ConfigurationManager.GetSection(PreloadedConverterAppConfiguration.PreloadedConverterConfigurationName);

            InitFromConfiguration(configuration);
        }