當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。