/// <summary> /// Initializes a new instance of the SchemaValidator. /// </summary> /// <param name="fileFormat">The target Open XML format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception> internal SchemaValidator(FileFormatVersions fileFormat) { if (fileFormat == FileFormatVersions.Office2007) { this._sdbSchemaDatas = SdbSchemaDatas.GetOffice2007SchemaDatas(); } else if (fileFormat == FileFormatVersions.Office2010) { this._sdbSchemaDatas = SdbSchemaDatas.GetOffice2010SchemaDatas(); } else if (fileFormat == FileFormatVersions.Office2013) { this._sdbSchemaDatas = SdbSchemaDatas.GetOffice2013SchemaDatas(); } else { string message = String.Format(System.Globalization.CultureInfo.CurrentUICulture, ExceptionMessages.FileFormatNotSupported, fileFormat); throw new ArgumentOutOfRangeException(nameof(fileFormat), message); } this._schemaTypeValidator = new SchemaTypeValidator(this._sdbSchemaDatas); #if DEBUG this._fileFormat = fileFormat; #endif }
/// <summary> /// simple content CT, OpenXmlLeafTextElement /// </summary> private static void ValidateSimpleContextComplexType(ValidationContext validationContext) { // first check whether there are invalid children under this OpenXmlLeafTextElement. ValidateEmptyComplexType(validationContext); var element = (OpenXmlLeafTextElement)validationContext.Stack.Current.Element; var state = new LeafAccessor(element); SchemaTypeValidator.ValidateValue(validationContext, element.ParsedState.Metadata.Validators, state.Value, state, false); }
internal static void Validate(ValidationContext validationContext, SimpleTypeRestriction simpleTypeConstraint) { // first check whether there are invalid children under this OpenXmlLeafTextElement. EmptyComplexTypeValidator.Validate(validationContext); OpenXmlLeafTextElement element = (OpenXmlLeafTextElement)validationContext.Element; OpenXmlSimpleType value = element.InnerTextToValue(element.Text); string qname = element.XmlQualifiedName.ToString(); SchemaTypeValidator.ValidateValue(validationContext, simpleTypeConstraint, value, qname, false); }
/// <summary> /// simple content CT, OpenXmlLeafTextElement /// </summary> private static void ValidateSimpleContextComplexType(ValidationContext validationContext) { // first check whether there are invalid children under this OpenXmlLeafTextElement. ValidateEmptyComplexType(validationContext); var element = (OpenXmlLeafTextElement)validationContext.Stack.Current.Element; var value = element.InnerTextToValue(element.Text); var state = new ElementProperty <OpenXmlSimpleType>(element.NamespaceId, element.LocalName, 0, element.ElementData.Info.Validators, new ElementPropertyAccessor <OpenXmlSimpleType>(_ => value, (_, __) => throw new NotImplementedException(), value.GetType())); SchemaTypeValidator.ValidateValue(validationContext, element.ElementData.Info.Validators, value, state, false); }
internal static void Validate(ValidationContext validationContext, SimpleTypeRestriction simpleTypeConstraint) { // first check whether there are invalid children under this OpenXmlLeafTextElement. EmptyComplexTypeValidator.Validate(validationContext); var element = (OpenXmlLeafTextElement)validationContext.Element; var value = element.InnerTextToValue(element.Text); var qname = element.XmlQualifiedName.ToString(); var state = new ElementProperty <OpenXmlSimpleType>(element.NamespaceId, element.LocalName, 0, element.ElementData.Info.Validators, new ElementPropertyAccessor <OpenXmlSimpleType>(_ => value, (_, __) => throw new NotImplementedException(), value.GetType())); SchemaTypeValidator.ValidateValue(validationContext, element.ElementData.Info.Validators, value, qname, state, false); }
/// <summary> /// Initializes a new instance of the SchemaValidator. /// </summary> /// <param name="fileFormat">The target Open XML format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception> public SchemaValidator(FileFormatVersions fileFormat) { _sdbSchemaDatas = SdbSchemaData.GetSchemaData(fileFormat); _schemaTypeValidator = new SchemaTypeValidator(_sdbSchemaDatas); }
/// <summary> /// Initializes a new instance of the SchemaValidator. /// </summary> /// <param name="fileFormat">The target Open XML format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception> public SchemaValidator(FileFormatVersions fileFormat) { _schemaTypeValidator = new SchemaTypeValidator(fileFormat); }