Beispiel #1
0
        public static void LoadSchemaAndValidateDoc(this XDocument doc, ISchemaMap schemaMap, string schemaRootPath)
        {
            var xmlNamespace = doc.GetDefaultSchemaNamespace();

            if (!schemaMap.Mapping.ContainsKey(xmlNamespace.NamespaceName))
            {
                throw new InvalidOperationException($"Namespace mapping not configured: {xmlNamespace.NamespaceName}");
            }

            var schemaPath = Path.Combine(schemaRootPath, schemaMap.Mapping[xmlNamespace.NamespaceName]);

            var reader = new XmlTextReader(schemaPath);
            var schema = XmlSchema.Read(reader, ValidationCallback);

            var schemaSet = new XmlSchemaSet();

            schemaSet.Add(schema);

            doc.Validate(schemaSet, ValidationCallback);
        }
Beispiel #2
0
 public EdgeSerializer(ISchemaMap schemaMap = default(ISchemaMap))
 {
     this.Map = schemaMap ?? new AttributeSchemaMap();
 }
Beispiel #3
0
 public Client(ISchemaMap schemaMap)
 {
     _schemaMap = schemaMap ?? throw new ArgumentNullException(nameof(schemaMap));
 }