当前位置: 首页>>代码示例>>C#>>正文


C# Schema.XmlSchemaException类代码示例

本文整理汇总了C#中System.Xml.Schema.XmlSchemaException的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaException类的具体用法?C# XmlSchemaException怎么用?C# XmlSchemaException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlSchemaException类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DenyUnrestricted

		public void DenyUnrestricted ()
		{
			// can we call everything without a SecurityException ?
			XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
			Assert.AreEqual (0, xe.LineNumber, "LineNumber");
			Assert.AreEqual (0, xe.LinePosition, "LinePosition");
			Assert.IsNotNull (xe.Message, "Message");
			Assert.IsNull (xe.SourceSchemaObject, "SourceSchemaObject");
			Assert.IsNull (xe.SourceUri, "SourceUri");
		}
开发者ID:xzkmxd,项目名称:mono,代码行数:10,代码来源:XmlSchemaExceptionCas.cs

示例2: CheckDefaultValue

 public static void CheckDefaultValue(string value, SchemaAttDef attdef, SchemaInfo sinfo, XmlNamespaceManager nsManager, XmlNameTable NameTable, object sender, ValidationEventHandler eventhandler, string baseUri, int lineNo, int linePos)
 {
     try
     {
         XmlSchemaDatatype datatype = attdef.Datatype;
         if (datatype != null)
         {
             if (datatype.TokenizedType != XmlTokenizedType.CDATA)
             {
                 value = value.Trim();
             }
             if (value.Length != 0)
             {
                 object pVal = datatype.ParseValue(value, NameTable, nsManager);
                 XmlTokenizedType tokenizedType = datatype.TokenizedType;
                 if (tokenizedType == XmlTokenizedType.ENTITY)
                 {
                     if (datatype.Variety == XmlSchemaDatatypeVariety.List)
                     {
                         string[] strArray = (string[]) pVal;
                         for (int i = 0; i < strArray.Length; i++)
                         {
                             BaseValidator.ProcessEntity(sinfo, strArray[i], sender, eventhandler, baseUri, lineNo, linePos);
                         }
                     }
                     else
                     {
                         BaseValidator.ProcessEntity(sinfo, (string) pVal, sender, eventhandler, baseUri, lineNo, linePos);
                     }
                 }
                 else if ((tokenizedType == XmlTokenizedType.ENUMERATION) && !attdef.CheckEnumeration(pVal))
                 {
                     XmlSchemaException ex = new XmlSchemaException("Sch_EnumerationValue", pVal.ToString(), baseUri, lineNo, linePos);
                     if (eventhandler == null)
                     {
                         throw ex;
                     }
                     eventhandler(sender, new ValidationEventArgs(ex));
                 }
                 attdef.DefaultValueTyped = pVal;
             }
         }
     }
     catch
     {
         XmlSchemaException exception2 = new XmlSchemaException("Sch_AttributeDefaultDataType", attdef.Name.ToString(), baseUri, lineNo, linePos);
         if (eventhandler == null)
         {
             throw exception2;
         }
         eventhandler(sender, new ValidationEventArgs(exception2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:53,代码来源:XdrValidator.cs

示例3: CheckDefaultValue

 public static void CheckDefaultValue(SchemaAttDef attdef, SchemaInfo sinfo, IValidationEventHandling eventHandling, string baseUriStr)
 {
     try
     {
         if (baseUriStr == null)
         {
             baseUriStr = string.Empty;
         }
         XmlSchemaDatatype datatype = attdef.Datatype;
         if (datatype != null)
         {
             object defaultValueTyped = attdef.DefaultValueTyped;
             XmlTokenizedType tokenizedType = datatype.TokenizedType;
             if (tokenizedType == XmlTokenizedType.ENTITY)
             {
                 if (datatype.Variety == XmlSchemaDatatypeVariety.List)
                 {
                     string[] strArray = (string[]) defaultValueTyped;
                     for (int i = 0; i < strArray.Length; i++)
                     {
                         BaseValidator.ProcessEntity(sinfo, strArray[i], eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition);
                     }
                 }
                 else
                 {
                     BaseValidator.ProcessEntity(sinfo, (string) defaultValueTyped, eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition);
                 }
             }
             else if (((tokenizedType == XmlTokenizedType.ENUMERATION) && !attdef.CheckEnumeration(defaultValueTyped)) && (eventHandling != null))
             {
                 XmlSchemaException exception = new XmlSchemaException("Sch_EnumerationValue", defaultValueTyped.ToString(), baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition);
                 eventHandling.SendEvent(exception, XmlSeverityType.Error);
             }
         }
     }
     catch (Exception)
     {
         if (eventHandling != null)
         {
             XmlSchemaException exception2 = new XmlSchemaException("Sch_AttributeDefaultDataType", attdef.Name.ToString());
             eventHandling.SendEvent(exception2, XmlSeverityType.Error);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:DtdValidator.cs

示例4: WarningDetails

 internal static string WarningDetails(XmlSchemaException exception, string message) {
     string details;
     XmlSchemaObject source = exception.SourceSchemaObject;
     if (exception.LineNumber == 0 && exception.LinePosition == 0) {
         details = GetSchemaItem(source, null, message);
     }
     else {
         string ns = null;
         if (source != null) {
             while (source.Parent != null) {
                 source = source.Parent;
             }
             if (source is XmlSchema) {
                 ns = ((XmlSchema)source).TargetNamespace;
             }
         }
         details = Res.GetString(Res.SchemaSyntaxErrorDetails, ns, message, exception.LineNumber, exception.LinePosition);
     }
     return details;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:20,代码来源:SchemaCompiler.cs

示例5: RaiseValidationEvent

		public static void RaiseValidationEvent(ValidationEventHandler handle,
			Exception innerException,
			string message,
			XmlSchemaObject xsobj,
			object sender,
			string sourceUri,
			XmlSeverityType severity)
		{
			XmlSchemaException ex = new XmlSchemaException (
				message, sender, sourceUri, xsobj, innerException);
			ValidationEventArgs e = new ValidationEventArgs(ex,message,severity);
			if(handle == null)
			{
				if (e.Severity == XmlSeverityType.Error)
					throw e.Exception;
			}
			else
			{
				handle(sender,e);
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:21,代码来源:ValidationHandler.cs

示例6: ProcessEntity

        protected static void ProcessEntity(SchemaInfo sinfo, string name, IValidationEventHandling eventHandling, string baseUriStr, int lineNumber, int linePosition) {
            SchemaEntity en;
            string errorResId = null;
            if (!sinfo.GeneralEntities.TryGetValue(new XmlQualifiedName(name), out en)) {
                // validation error, see xml spec [68]
                errorResId = Res.Sch_UndeclaredEntity;

            }
            else if (en.NData.IsEmpty) {
                errorResId = Res.Sch_UnparsedEntityRef;
            }
            if (errorResId != null) {
                XmlSchemaException e = new XmlSchemaException(errorResId, name, baseUriStr, lineNumber, linePosition);

                if (eventHandling != null) {
                    eventHandling.SendEvent(e, XmlSeverityType.Error);
                }
                else {
                    throw e;
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:BaseValidator.cs

示例7: SendValidationEvent

 protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) {
     if (eventHandling != null) {
         eventHandling.SendEvent(e, severity);
     }
     else if (severity == XmlSeverityType.Error) {
         throw e;
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:BaseValidator.cs

示例8: SendValidationEvent

 private void SendValidationEvent(XmlSchemaException e) {
     if (validationEventHandler != null) {
         validationEventHandler(this, new ValidationEventArgs(e));
     } 
     else {
         throw e;
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:8,代码来源:xmlschemacollection.cs

示例9: DtdParserProxy_SendValidationEvent

 internal void DtdParserProxy_SendValidationEvent( XmlSeverityType severity, XmlSchemaException exception ) {
     if ( DtdValidation ) {
         this.SendValidationEvent( severity, exception );
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:5,代码来源:xmltextreaderimpl.cs

示例10: SendValidationEvent

 private void SendValidationEvent(XmlSchemaException e) {
     SendValidationEvent(e, XmlSeverityType.Error);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:3,代码来源:XsdBuilder.cs

示例11: SendValidationEvent

 private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity)
 {
     _SchemaInfo.ErrorCount++;
     if (_validationEventHandler != null)
     {
         _validationEventHandler(this, new ValidationEventArgs(e, severity));
     }
     else if (severity == XmlSeverityType.Error)
     {
         throw e;
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:XdrBuilder.cs

示例12: PermitOnlySerializationFormatter_GetObjectData

		public void PermitOnlySerializationFormatter_GetObjectData ()
		{
			StreamingContext sc = new StreamingContext (StreamingContextStates.All);
			XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
			xe.GetObjectData (null, sc);
		}
开发者ID:xzkmxd,项目名称:mono,代码行数:6,代码来源:XmlSchemaExceptionCas.cs

示例13: SendValidationEvent

 private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) {
     if (validationEventHandler != null) {
         validationEventHandler(null, new ValidationEventArgs(e, severity));
     }
     else if (severity == XmlSeverityType.Error) {
         throw e;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:8,代码来源:validator.cs

示例14: CheckDefaultValue

        internal static void CheckDefaultValue(
            string              value,
            SchemaAttDef        attdef,
            SchemaInfo          sinfo,
            XmlNamespaceManager     nsManager,
            XmlNameTable        nameTable,
            object              sender,
            ValidationEventHandler  eventhandler
        ) {
#if DEBUG
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, string.Format("Validator.CheckDefaultValue(\"{0}\")", value));
#endif
            try {

                XmlSchemaDatatype dtype = attdef.Datatype;
                if (dtype == null) {
                    return; // no reason to check
                }
                if (sinfo.SchemaType != SchemaType.XSD) {
                    if (dtype.TokenizedType != XmlTokenizedType.CDATA) {
                        value = value.Trim();
                    }
                    if (sinfo.SchemaType == SchemaType.XDR && value == string.Empty) {
                        return; // don't need to check
                    }
                }

                object typedValue = dtype.ParseValue(value, nameTable, nsManager);

                // Check special types
                XmlTokenizedType ttype = dtype.TokenizedType;
                if (ttype == XmlTokenizedType.ENTITY) {
                    if (dtype.Variety == XmlSchemaDatatypeVariety.List) {
                        string[] ss = (string[])typedValue;
                        foreach(string s in ss) {
                            ProcessEntity(sinfo, s, sender, eventhandler);
                        }
                    }
                    else {
                        ProcessEntity(sinfo, (string)typedValue, sender, eventhandler);
                    }
                }
                else if (ttype == XmlTokenizedType.ENUMERATION) {
                    if (!attdef.CheckEnumeration(typedValue)) {
                        XmlSchemaException e = new XmlSchemaException(Res.Sch_EnumerationValue, typedValue.ToString());
                        if (eventhandler != null) {
                            eventhandler(sender, new ValidationEventArgs(e));
                        }
                        else {
                            throw e;
                        }
                    }
                }
                attdef.DefaultValueTyped = typedValue;
            }
#if DEBUG
            catch (XmlSchemaException ex) {
                Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceError, ex.Message);
#else
            catch  {
#endif
                XmlSchemaException e = new XmlSchemaException(Res.Sch_AttributeDefaultDataType, attdef.Name.ToString());
                if (eventhandler != null) {
                    eventhandler(sender, new ValidationEventArgs(e));
                }
                else {
                    throw e;
                }
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:70,代码来源:validator.cs

示例15: FormatPosition

 private string FormatPosition(XmlSchemaException xmlSchemaException)
 {
     return string.Format(" @ line:{0} column:{1}", xmlSchemaException.LineNumber, xmlSchemaException.LinePosition);
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:4,代码来源:ConfigurationValidator.cs


注:本文中的System.Xml.Schema.XmlSchemaException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。