Example #1
0
        /// <summary>
        /// 使用Schema检查XML
        /// </summary>
        public void ValidateXml()
        {
            if (!File.Exists(_schemaUri))
            {
                Console.WriteLine("SchemaFile '{0}' not found!");
                return;
            }
            if (SchemaUsed)
            {
                string       targetNamespace = ParseUtil.IfNullOrEmpty(SchemaTargetNamespace(), "http://tempuri.org/schema.xsd");
                XmlSchemaSet schemas         = new XmlSchemaSet();
                schemas.Add(targetNamespace, _schemaUri);

                _xmlDoc.Schemas = schemas;
                StringBuilder sbStr = new StringBuilder();
                _xmlDoc.Validate(new ValidationEventHandler((obj, e) =>
                {
                    if (e.Severity == XmlSeverityType.Error)
                    {
                        sbStr.AppendLine(e.Message);
                    }
                    else
                    {
                        sbStr.AppendLine(e.Message);
                    }
                }));

                if (_parseErrorExit && sbStr.Length > 0)
                {
                    throw new ParseErrorException(sbStr.ToString());
                }
            }
        }
Example #2
0
        protected override Cell CreateEntity()
        {
            BaseEntity  container = _upperElement.CurrentEntity;
            ProductRule prodRule  = container.ProductRule;

            _entity = new Cell(prodRule, container, new Location(_data.GetAttribute("location")));
            parseSource(_data.GetAttribute("source"));
            _entity.DataIndex   = ParseUtil.ParseInt(_data.GetAttribute("index"), 0);
            _entity.ValueAppend = ParseUtil.ParseBoolean(_data.GetAttribute("valueAppend"), false);
            _entity.Value       = ParseUtil.IfNullOrEmpty(_data.GetAttribute("value"));
            _entity.FillType    = ParseUtil.ParseEnum <FillType>(_data.GetAttribute("fill"), FillType.Origin);
            return(_entity);
        }