本文整理汇总了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");
}
示例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));
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
示例7: SendValidationEvent
protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) {
if (eventHandling != null) {
eventHandling.SendEvent(e, severity);
}
else if (severity == XmlSeverityType.Error) {
throw e;
}
}
示例8: SendValidationEvent
private void SendValidationEvent(XmlSchemaException e) {
if (validationEventHandler != null) {
validationEventHandler(this, new ValidationEventArgs(e));
}
else {
throw e;
}
}
示例9: DtdParserProxy_SendValidationEvent
internal void DtdParserProxy_SendValidationEvent( XmlSeverityType severity, XmlSchemaException exception ) {
if ( DtdValidation ) {
this.SendValidationEvent( severity, exception );
}
}
示例10: SendValidationEvent
private void SendValidationEvent(XmlSchemaException e) {
SendValidationEvent(e, XmlSeverityType.Error);
}
示例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;
}
}
示例12: PermitOnlySerializationFormatter_GetObjectData
public void PermitOnlySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
xe.GetObjectData (null, sc);
}
示例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;
}
}
示例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;
}
}
}
示例15: FormatPosition
private string FormatPosition(XmlSchemaException xmlSchemaException)
{
return string.Format(" @ line:{0} column:{1}", xmlSchemaException.LineNumber, xmlSchemaException.LinePosition);
}