private void ProcessTokenizedType(XmlTokenizedType ttype, string name) { switch (ttype) { case XmlTokenizedType.ID: if (this.FindId(name) == null) { this.AddID(name, base.context.LocalName); return; } base.SendValidationEvent("Sch_DupId", name); return; case XmlTokenizedType.IDREF: if (this.FindId(name) != null) { break; } this.idRefListHead = new IdRefNode(this.idRefListHead, name, base.PositionInfo.LineNumber, base.PositionInfo.LinePosition); return; case XmlTokenizedType.IDREFS: break; case XmlTokenizedType.ENTITY: BaseValidator.ProcessEntity(base.schemaInfo, name, this, base.EventHandler, base.reader.BaseURI, base.PositionInfo.LineNumber, base.PositionInfo.LinePosition); break; default: return; } }
void ProcessTokenizedType( XmlTokenizedType ttype, string name ) { switch (ttype) { case XmlTokenizedType.ID: if (FindId(name) != null) { SendValidationEvent(Res.Sch_DupId, name); } else { AddID(name, context.LocalName); } break; case XmlTokenizedType.IDREF: object p = FindId(name); if (p == null) // add it to linked list to check it later { idRefListHead = new IdRefNode(idRefListHead, name, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); } break; case XmlTokenizedType.ENTITY: ProcessEntity(schemaInfo, name, this, EventHandler, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); break; default: break; } }
private void AssertDatatype (XmlSchema schema, int index, XmlTokenizedType tokenizedType, Type type, string rawValue, object parsedValue) { XmlSchemaElement element = schema.Items [index] as XmlSchemaElement; XmlSchemaDatatype dataType = element.ElementType as XmlSchemaDatatype; Assert.AreEqual (tokenizedType, dataType.TokenizedType, "#1"); Assert.AreEqual (type, dataType.ValueType, "#2"); Assert.AreEqual (parsedValue, dataType.ParseValue (rawValue, null, null), "#3"); }
private void AssertDatatype(XmlSchema schema, int index, XmlTokenizedType tokenizedType, Type type, string rawValue, object parsedValue) { XmlSchemaElement element = schema.Items [index] as XmlSchemaElement; XmlSchemaDatatype dataType = element.ElementType as XmlSchemaDatatype; Assert.AreEqual(tokenizedType, dataType.TokenizedType, "#1"); Assert.AreEqual(type, dataType.ValueType, "#2"); Assert.AreEqual(parsedValue, dataType.ParseValue(rawValue, null, null), "#3"); }
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)); } }
public static void CheckDefaultValue( SchemaAttDef attdef, SchemaInfo sinfo, IDtdParserAdapter readerAdapter ) { try { XmlSchemaDatatype dtype = attdef.Datatype; if (dtype == null) { return; // no reason to check } object typedValue = attdef.DefaultValueTyped; // Check special types XmlTokenizedType ttype = dtype.TokenizedType; if (ttype == XmlTokenizedType.ENTITY) { Uri baseUri = readerAdapter.BaseUri; string baseUriStr = (baseUri == null) ? string.Empty : baseUri.ToString(); if (dtype.Variety == XmlSchemaDatatypeVariety.List) { string[] ss = (string[])typedValue; foreach (string s in ss) { ProcessEntity(sinfo, s, readerAdapter, readerAdapter.EventHandler, baseUriStr, attdef.ValueLineNum, attdef.ValueLinePos); } } else { ProcessEntity(sinfo, (string)typedValue, readerAdapter, readerAdapter.EventHandler, baseUriStr, attdef.ValueLineNum, attdef.ValueLinePos); } } else if (ttype == XmlTokenizedType.ENUMERATION) { if (!attdef.CheckEnumeration(typedValue)) { XmlSchemaException e = new XmlSchemaException(Res.Sch_EnumerationValue, typedValue.ToString(), readerAdapter.BaseUri.ToString(), attdef.ValueLineNum, attdef.ValueLinePos); readerAdapter.SendValidationEvent(XmlSeverityType.Error, e); } } } #if DEBUG catch (XmlSchemaException ex) { Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); #else catch (Exception) { #endif XmlSchemaException e = new XmlSchemaException(Res.Sch_AttributeDefaultDataType, attdef.Name.ToString()); readerAdapter.SendValidationEvent(XmlSeverityType.Error, e); } }
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); } } }
internal static DatatypeImplementation FromXmlTokenizedTypeXsd(XmlTokenizedType token) { return(c_tokenizedTypesXsd[(int)token]); }
internal static XmlSchemaDatatype FromXmlTokenizedTypeXsd(XmlTokenizedType token) { return DatatypeImplementation.FromXmlTokenizedTypeXsd(token); }
internal XdrAttributeEntry(SchemaNames.Token a, XmlTokenizedType ttype, int schemaFlags, XdrBuildFunction build) { _Attribute = a; _Datatype = XmlSchemaDatatype.FromXmlTokenizedType(ttype); _SchemaFlags = schemaFlags; _BuildFunc = build; }
private void ProcessTokenizedType(XmlTokenizedType ttype, string name, bool attrValue) { switch (ttype) { case XmlTokenizedType.ID: if (!this.ProcessIdentityConstraints) { break; } if (this.FindId(name) == null) { if (this.IDs == null) { this.IDs = new Hashtable(); } this.IDs.Add(name, this.context.LocalName); return; } if (attrValue) { this.attrValid = false; } this.SendValidationEvent("Sch_DupId", name); return; case XmlTokenizedType.IDREF: if (!this.ProcessIdentityConstraints || (this.FindId(name) != null)) { break; } this.idRefListHead = new IdRefNode(this.idRefListHead, name, this.positionInfo.LineNumber, this.positionInfo.LinePosition); return; case XmlTokenizedType.IDREFS: break; case XmlTokenizedType.ENTITY: this.ProcessEntity(name); break; default: return; } }
private void CheckValue( string value, SchemaAttDef attdef ) { try { reader.TypedValueObject = null; bool isAttn = attdef != null; XmlSchemaDatatype dtype = isAttn ? attdef.Datatype : context.ElementDecl.Datatype; if (dtype == null) { return; // no reason to check } object typedValue = dtype.ParseValue(value, NameTable, nsManager, true); // Check special types XmlTokenizedType ttype = dtype.TokenizedType; if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) { if (dtype.Variety == XmlSchemaDatatypeVariety.List) { string[] ss = (string[])typedValue; for (int i = 0; i < ss.Length; ++i) { ProcessTokenizedType(dtype.TokenizedType, ss[i]); } } else { ProcessTokenizedType(dtype.TokenizedType, (string)typedValue); } } SchemaDeclBase decl = isAttn ? (SchemaDeclBase)attdef : (SchemaDeclBase)context.ElementDecl; if (!decl.CheckValue(typedValue)) { if (isAttn) { SendValidationEvent(Res.Sch_FixedAttributeValue, attdef.Name.ToString()); } else { SendValidationEvent(Res.Sch_FixedElementValue, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); } } if (dtype.Variety == XmlSchemaDatatypeVariety.Union) { typedValue = UnWrapUnion(typedValue); } reader.TypedValueObject = typedValue; } catch (XmlSchemaException) { if (attdef != null) { SendValidationEvent(Res.Sch_AttributeValueDataType, attdef.Name.ToString()); } else { SendValidationEvent(Res.Sch_ElementValueDataType, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); } } }
internal new static DatatypeImplementation FromXmlTokenizedType(XmlTokenizedType token) { return s_tokenizedTypes[(int)token]; }
public static void CheckDefaultValue( SchemaAttDef attdef, SchemaInfo sinfo, IValidationEventHandling eventHandling, string baseUriStr ) { try { if (baseUriStr == null) { baseUriStr = string.Empty; } XmlSchemaDatatype dtype = attdef.Datatype; if (dtype == null) { return; // no reason to check } object typedValue = attdef.DefaultValueTyped; // Check special types XmlTokenizedType ttype = dtype.TokenizedType; if (ttype == XmlTokenizedType.ENTITY) { if (dtype.Variety == XmlSchemaDatatypeVariety.List) { string[] ss = (string[])typedValue; for (int i = 0; i < ss.Length; ++i) { ProcessEntity(sinfo, ss[i], eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); } } else { ProcessEntity(sinfo, (string)typedValue, eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); } } else if (ttype == XmlTokenizedType.ENUMERATION) { if (!attdef.CheckEnumeration(typedValue)) { if (eventHandling != null) { XmlSchemaException e = new XmlSchemaException(Res.Sch_EnumerationValue, typedValue.ToString(), baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); eventHandling.SendEvent(e, XmlSeverityType.Error); } } } } #if DEBUG catch (XmlSchemaException ex) { Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); #else catch (Exception) { #endif if (eventHandling != null) { XmlSchemaException e = new XmlSchemaException(Res.Sch_AttributeDefaultDataType, attdef.Name.ToString()); eventHandling.SendEvent(e, XmlSeverityType.Error); } } }
void ProcessTokenizedType( XmlTokenizedType ttype, string name ) { switch(ttype) { case XmlTokenizedType.ID: if (FindId(name) != null) { SendValidationEvent(Res.Sch_DupId, name); } else { AddID(name, context.LocalName); } break; case XmlTokenizedType.IDREF: object p = FindId(name); if (p == null) { // add it to linked list to check it later idRefListHead = new IdRefNode(idRefListHead, name, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); } break; case XmlTokenizedType.ENTITY: ProcessEntity(schemaInfo, name, this, EventHandler, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); break; default: break; } }
private void ProcessTokenizedType(XmlTokenizedType ttype, string name, bool attrValue) { switch(ttype) { case XmlTokenizedType.ID: if (ProcessIdentityConstraints) { if (FindId(name) != null) { if (attrValue) { attrValid = false; } SendValidationEvent(Res.Sch_DupId, name); } else { if (IDs == null) { //ADD ID IDs = new Hashtable(); } IDs.Add(name, context.LocalName); } } break; case XmlTokenizedType.IDREF: if (ProcessIdentityConstraints) { object p = FindId(name); if (p == null) { // add it to linked list to check it later idRefListHead = new IdRefNode(idRefListHead, name, positionInfo.LineNumber, positionInfo.LinePosition); } } break; case XmlTokenizedType.ENTITY: ProcessEntity(name); break; default: break; } }
private void ProcessTokenizedType(XmlTokenizedType ttype, string name) { switch (ttype) { case XmlTokenizedType.ID: if (!this.processIdentityConstraints) { break; } if (this.FindId(name) == null) { this.AddID(name, base.context.LocalName); return; } base.SendValidationEvent("Sch_DupId", name); return; case XmlTokenizedType.IDREF: if (!this.processIdentityConstraints || (this.FindId(name) != null)) { break; } this.idRefListHead = new IdRefNode(this.idRefListHead, name, base.PositionInfo.LineNumber, base.PositionInfo.LinePosition); return; case XmlTokenizedType.IDREFS: break; case XmlTokenizedType.ENTITY: BaseValidator.ProcessEntity(base.schemaInfo, name, this, base.EventHandler, base.Reader.BaseURI, base.PositionInfo.LineNumber, base.PositionInfo.LinePosition); break; default: return; } }
void ProcessTokenizedType( XmlTokenizedType ttype, string name ) { switch(ttype) { case XmlTokenizedType.ID: if (FindID(name) != null) { SendValidationEvent(Res.Sch_DupId, name); } else { AddID(name, context.Name.Name); } break; case XmlTokenizedType.IDREF: object p = FindID(name); if (p == null) { // add it to linked list to check it later AddForwardRef(context.Name.Name, context.Prefix, name, (reader as IXmlLineInfo).LineNumber, (reader as IXmlLineInfo).LinePosition, false, ForwardRef.Type.ID); } break; case XmlTokenizedType.ENTITY: ProcessEntity(SchemaInfo, name, this, validationEventHandler); break; default: break; } }
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 dtype = attdef.Datatype; if (dtype == null) { return; // no reason to check } if (dtype.TokenizedType != XmlTokenizedType.CDATA) { value = value.Trim(); } if (value.Length == 0) { 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; for (int i = 0; i < ss.Length; ++i) { ProcessEntity(sinfo, ss[i], sender, eventhandler, baseUri, lineNo, linePos); } } else { ProcessEntity(sinfo, (string)typedValue, sender, eventhandler, baseUri, lineNo, linePos); } } else if (ttype == XmlTokenizedType.ENUMERATION) { if (!attdef.CheckEnumeration(typedValue)) { XmlSchemaException e = new XmlSchemaException(SR.Sch_EnumerationValue, typedValue.ToString(), baseUri, lineNo, linePos); if (eventhandler != null) { eventhandler(sender, new ValidationEventArgs(e)); } else { throw e; } } } attdef.DefaultValueTyped = typedValue; } #if DEBUG catch (XmlSchemaException ex) { Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); #else catch { #endif XmlSchemaException e = new XmlSchemaException(SR.Sch_AttributeDefaultDataType, attdef.Name.ToString(), baseUri, lineNo, linePos); if (eventhandler != null) { eventhandler(sender, new ValidationEventArgs(e)); } else { throw e; } } }
private void CheckValue( string value, SchemaAttDef attdef ) { try { reader.TypedValueObject = null; bool isAttn = attdef != null; XmlSchemaDatatype dtype = isAttn ? attdef.Datatype : context.ElementDecl.Datatype; if (dtype == null) { return; // no reason to check } if (dtype.TokenizedType != XmlTokenizedType.CDATA) { value = value.Trim(); } if (value.Length == 0) { return; // don't need to check } object typedValue = dtype.ParseValue(value, NameTable, _nsManager); reader.TypedValueObject = typedValue; // Check special types XmlTokenizedType ttype = dtype.TokenizedType; if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) { if (dtype.Variety == XmlSchemaDatatypeVariety.List) { string[] ss = (string[])typedValue; for (int i = 0; i < ss.Length; ++i) { ProcessTokenizedType(dtype.TokenizedType, ss[i]); } } else { ProcessTokenizedType(dtype.TokenizedType, (string)typedValue); } } SchemaDeclBase decl = isAttn ? (SchemaDeclBase)attdef : (SchemaDeclBase)context.ElementDecl; if (decl.MaxLength != uint.MaxValue) { if (value.Length > decl.MaxLength) { SendValidationEvent(SR.Sch_MaxLengthConstraintFailed, value); } } if (decl.MinLength != uint.MaxValue) { if (value.Length < decl.MinLength) { SendValidationEvent(SR.Sch_MinLengthConstraintFailed, value); } } if (decl.Values != null && !decl.CheckEnumeration(typedValue)) { if (dtype.TokenizedType == XmlTokenizedType.NOTATION) { SendValidationEvent(SR.Sch_NotationValue, typedValue.ToString()); } else { SendValidationEvent(SR.Sch_EnumerationValue, typedValue.ToString()); } } if (!decl.CheckValue(typedValue)) { if (isAttn) { SendValidationEvent(SR.Sch_FixedAttributeValue, attdef.Name.ToString()); } else { SendValidationEvent(SR.Sch_FixedElementValue, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); } } } catch (XmlSchemaException) { if (attdef != null) { SendValidationEvent(SR.Sch_AttributeValueDataType, attdef.Name.ToString()); } else { SendValidationEvent(SR.Sch_ElementValueDataType, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); } } }
internal static XmlSchemaDatatype FromXmlTokenizedTypeXsd(XmlTokenizedType token) { return(DatatypeImplementation.FromXmlTokenizedTypeXsd(token)); }
internal new static DatatypeImplementation FromXmlTokenizedTypeXsd(XmlTokenizedType token) { return c_tokenizedTypesXsd[(int)token]; }
internal XdrAttributeEntry(SchemaNames.Token a, XmlTokenizedType ttype, XdrBuilder.XdrBuildFunction build) { this._Attribute = a; this._Datatype = XmlSchemaDatatype.FromXmlTokenizedType(ttype); this._SchemaFlags = 0; this._BuildFunc = build; }