public static IEnumerable <IFxtTransformation> Deanonymize( this XmlSchemaSet schemas, // the schemas to transform FxtScope scope, // affected abstractions bool strict, // be strict about de-anonymization FxtLog log // log transformations and analyses ) { // Determine potential ambiguity of local element names var recurrence = new Dictionary <string, int>(); foreach (var el in schemas.LocalXsdElements()) { if (el.SchemaType != null && el.SchemaType is XmlSchemaComplexType) { if (!recurrence.ContainsKey(el.Name)) { recurrence.Add(el.Name, 1); } else { recurrence[el.Name]++; } } } foreach (var el in schemas.LocalXsdElements()) { // Test whether element is affected if (el.SchemaType != null && el.SchemaType is XmlSchemaComplexType && scope.Test(el)) { // Determine name of new type var qname = new XmlQualifiedName( el.Name, el.XmlSchema().TargetNamespace); // Check for name clashes if (schemas.DefinesXsdType(qname) || recurrence[el.Name] > 1) { if (!strict) { continue; // Skip this candidate } else { throw new FxtTypeClashException(qname); } } // Build and yield transformation var trafo = new ExtractType(); trafo.element = el; log.AtType(qname).Add(new ExtractTypeAnnotation()); yield return(trafo); } } }
public static FxtLog Run(XmlSchemaSet schemas, XElement trafo, interpreter i) { FxtLog fxtLog; List <IFxtTransformation> trafos = new List <IFxtTransformation>(); FxtLog log = new FxtLog(); if (!schemas.IsCompiled) { schemas.Compile(); } if (trafo != null) { i(schemas, trafo, log, trafos); foreach (IFxtTransformation x in trafos) { x.Run(); } foreach (XmlSchema x in schemas.XmlSchemas()) { schemas.Reprocess(x); } schemas.Compile(); fxtLog = log; } else { fxtLog = log; } return(fxtLog); }
public static FxtLog Run(XmlSchemaSet schemas, XElement trafo, interpreter i) { var trafos = new List <IFxtTransformation>(); var log = new FxtLog(); // Compile if necessary if (!schemas.IsCompiled) { schemas.Compile(); } if (trafo == null) { return(log); } // Interpret trafo i(schemas, trafo, log, trafos); // Execute trafos foreach (var x in trafos) { x.Run(); } // Re-compile foreach (var x in schemas.XmlSchemas()) { schemas.Reprocess(x); } schemas.Compile(); return(log); }
static void interpret(XmlSchemaSet schemas, XElement trafo, FxtLog log, List<IFxtTransformation> trafos) { foreach (var child in trafo.Elements()) { if (child.Name == FxtInterpreter.FxtNs + "Deanonymize" && child.Elements().Count()==0) { bool strict = (bool?)child.Attribute("strict") ?? false; foreach (var x in schemas.Deanonymize(new FxtScope(),strict,log)) trafos.Add(x); continue; } throw FxtInterpreter.ex; } }
private static void interpret(XmlSchemaSet schemas, XElement trafo, FxtLog log, List <IFxtTransformation> trafos) { foreach (XElement child in trafo.Elements()) { if ((child.Name != (FxtInterpreter.FxtNs + "Deanonymize") ? true : child.Elements().Count <XElement>() != 0)) { throw FxtInterpreter.ex; } bool?nullable = (bool?)child.Attribute("strict"); foreach (IFxtTransformation x in schemas.Deanonymize(new FxtScope(), (nullable.HasValue ? nullable.GetValueOrDefault() : false), log)) { trafos.Add(x); } } }
static void interpret(XmlSchemaSet schemas, XElement trafo, FxtLog log, List <IFxtTransformation> trafos) { foreach (var child in trafo.Elements()) { if (child.Name == FxtInterpreter.FxtNs + "Deanonymize" && child.Elements().Count() == 0) { bool strict = (bool?)child.Attribute("strict") ?? false; foreach (var x in schemas.Deanonymize(new FxtScope(), strict, log)) { trafos.Add(x); } continue; } throw FxtInterpreter.ex; } }
public static IEnumerable<IFxtTransformation> Deanonymize( this XmlSchemaSet schemas, // the schemas to transform FxtScope scope, // affected abstractions bool strict, // be strict about de-anonymization FxtLog log // log transformations and analyses ) { // Determine potential ambiguity of local element names var recurrence = new Dictionary<string,int>(); foreach (var el in schemas.LocalXsdElements()) if (el.SchemaType!=null && el.SchemaType is XmlSchemaComplexType) if (!recurrence.ContainsKey(el.Name)) recurrence.Add(el.Name,1); else recurrence[el.Name]++; foreach (var el in schemas.LocalXsdElements()) // Test whether element is affected if (el.SchemaType!=null && el.SchemaType is XmlSchemaComplexType && scope.Test(el)) { // Determine name of new type var qname = new XmlQualifiedName( el.Name, el.XmlSchema().TargetNamespace); // Check for name clashes if (schemas.DefinesXsdType(qname) || recurrence[el.Name] > 1) if (!strict) continue; // Skip this candidate else throw new FxtTypeClashException(qname); // Build and yield transformation var trafo = new ExtractType(); trafo.element = el; log.AtType(qname).Add(new ExtractTypeAnnotation()); yield return trafo; } }
public static IEnumerable <IFxtTransformation> Deanonymize(this XmlSchemaSet schemas, FxtScope scope, bool strict, FxtLog log) { bool flag; bool flag1; bool flag2; XmlQualifiedName xmlQualifiedName; Dictionary <string, int> strs = new Dictionary <string, int>(); foreach (XmlSchemaElement xmlSchemaElement in schemas.LocalXsdElements()) { flag = (xmlSchemaElement.SchemaType == null ? true : !(xmlSchemaElement.SchemaType is XmlSchemaComplexType)); if (flag) { continue; } if (strs.ContainsKey(xmlSchemaElement.Name)) { Dictionary <string, int> item = strs; Dictionary <string, int> strs1 = item; string name = xmlSchemaElement.Name; item[name] = strs1[name] + 1; } else { strs.Add(xmlSchemaElement.Name, 1); } } IEnumerator <XmlSchemaElement> enumerator = schemas.LocalXsdElements().GetEnumerator(); try { while (enumerator.MoveNext()) { XmlSchemaElement current = enumerator.Current; flag1 = (current.SchemaType == null || !(current.SchemaType is XmlSchemaComplexType) ? true : !scope.Test(current)); if (flag1) { continue; } xmlQualifiedName = new XmlQualifiedName(current.Name, current.XmlSchema().TargetNamespace); flag2 = (schemas.DefinesXsdType(xmlQualifiedName) ? false : strs[current.Name] <= 1); if (flag2) { ExtractType extractType = new ExtractType() { element = current }; log.AtType(xmlQualifiedName).Add(new ExtractTypeAnnotation()); yield return(extractType); } else if (strict) { throw new FxtTypeClashException(xmlQualifiedName); } } goto Label1; throw new FxtTypeClashException(xmlQualifiedName); } finally { if (enumerator != null) { enumerator.Dispose(); } } Label1: yield break; }
public static FxtLog Run(XmlSchemaSet schemas, XElement trafo, interpreter i) { var trafos = new List<IFxtTransformation>(); var log = new FxtLog(); // Compile if necessary if (!schemas.IsCompiled) schemas.Compile(); if (trafo==null) return log; // Interpret trafo i(schemas, trafo,log,trafos); // Execute trafos foreach (var x in trafos) x.Run(); // Re-compile foreach (var x in schemas.XmlSchemas()) schemas.Reprocess(x); schemas.Compile(); return log; }
public static FxtLog Run(XmlSchemaSet schemas, XElement trafo) { FxtLog fxtLog = FxtInterpreter.Run(schemas, trafo, new interpreter(FxtLinq2XsdInterpreter.interpret)); return(fxtLog); }