本文整理汇总了C#中System.Xml.Schema.XmlSchemaSet.Reprocess方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaSet.Reprocess方法的具体用法?C# XmlSchemaSet.Reprocess怎么用?C# XmlSchemaSet.Reprocess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaSet
的用法示例。
在下文中一共展示了XmlSchemaSet.Reprocess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveTypeNameClashesByRenaming
// .NET C# cannot have types with same name in the Codenamespace. If that happens a digit is appended to the typename.
// Eg. CoreComponents and UnqualifiedDataTypes both have "IdentifierType", one gets named "IdentifierType1" :-(
// Solution: Prepend types in CoreComponents with "cctscct" and modify references in UnqualifiedComponents
public static void ResolveTypeNameClashesByRenaming(XmlSchemaSet schemaSet)
{
string ccts_cctPrefix = "cctscct";
XmlSchema coreCompSchema = schemaSet.Schemas(Constants.CoreComponentTypeSchemaModuleTargetNamespace).OfType<XmlSchema>().Single();
XmlSchema unqualSchema = schemaSet.Schemas(Constants.UnqualifiedDataTypesTargetNamespace).OfType<XmlSchema>().Single();
foreach (var complexType in coreCompSchema.Items.OfType<XmlSchemaComplexType>())
{
complexType.Name = ccts_cctPrefix + complexType.Name;
complexType.IsAbstract = true; // Make it abstract as well. Ain't gonna use the base, only the one derived from this type.
}
foreach (var complexType in unqualSchema.Items.OfType<XmlSchemaComplexType>()
.Where(t => t.BaseXmlSchemaType.QualifiedName.Namespace.Equals(Constants.CoreComponentTypeSchemaModuleTargetNamespace)))
{
var name = new XmlQualifiedName(ccts_cctPrefix + complexType.BaseXmlSchemaType.QualifiedName.Name, complexType.BaseXmlSchemaType.QualifiedName.Namespace);
var content = complexType.ContentModel as XmlSchemaSimpleContent;
if (content.Content is XmlSchemaSimpleContentRestriction)
{
(content.Content as XmlSchemaSimpleContentRestriction).BaseTypeName = name;
}
else if (content.Content is XmlSchemaSimpleContentExtension)
{
(content.Content as XmlSchemaSimpleContentExtension).BaseTypeName = name;
}
}
schemaSet.Reprocess(coreCompSchema);
schemaSet.Reprocess(unqualSchema);
}
示例2: AddDefaultTypedDatasetType
private static void AddDefaultTypedDatasetType(XmlSchemaSet schemas, XmlSchema datasetSchema, string localName, string ns)
{
XmlSchemaComplexType item = new XmlSchemaComplexType {
Name = localName,
Particle = new XmlSchemaSequence()
};
XmlSchemaAny any = new XmlSchemaAny {
Namespace = (datasetSchema.TargetNamespace == null) ? string.Empty : datasetSchema.TargetNamespace
};
((XmlSchemaSequence) item.Particle).Items.Add(any);
schemas.Add(datasetSchema);
XmlSchema schema = SchemaHelper.GetSchema(ns, schemas);
schema.Items.Add(item);
schemas.Reprocess(datasetSchema);
schemas.Reprocess(schema);
}
示例3: AddDefaultXmlType
internal static void AddDefaultXmlType(XmlSchemaSet schemas, string localName, string ns)
{
XmlSchemaComplexType defaultXmlType = CreateAnyType();
defaultXmlType.Name = localName;
XmlSchema schema = SchemaHelper.GetSchema(ns, schemas);
schema.Items.Add(defaultXmlType);
schemas.Reprocess(schema);
}
示例4: EnsureProbeMatchSchema
public static XmlQualifiedName EnsureProbeMatchSchema(DiscoveryVersion discoveryVersion, XmlSchemaSet schemaSet)
{
Fx.Assert(schemaSet != null, "The schemaSet must be non null.");
Fx.Assert(discoveryVersion != null, "The discoveryVersion must be non null.");
// ensure that EPR is added to the schema.
if (discoveryVersion == DiscoveryVersion.WSDiscoveryApril2005 || discoveryVersion == DiscoveryVersion.WSDiscoveryCD1)
{
EndpointAddressAugust2004.GetSchema(schemaSet);
}
else if (discoveryVersion == DiscoveryVersion.WSDiscovery11)
{
EndpointAddress10.GetSchema(schemaSet);
}
else
{
Fx.Assert("The discoveryVersion is not supported.");
}
// do not add/find Probe related schema items
SchemaTypes typesFound = SchemaTypes.ProbeType | SchemaTypes.ResolveType;
SchemaElements elementsFound = SchemaElements.None;
XmlSchema discoverySchema = null;
ICollection discoverySchemas = schemaSet.Schemas(discoveryVersion.Namespace);
if ((discoverySchemas == null) || (discoverySchemas.Count == 0))
{
discoverySchema = CreateSchema(discoveryVersion);
AddImport(discoverySchema, discoveryVersion.Implementation.WsaNamespace);
schemaSet.Add(discoverySchema);
}
else
{
foreach (XmlSchema schema in discoverySchemas)
{
discoverySchema = schema;
if (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.ProbeMatchType))
{
typesFound |= SchemaTypes.ProbeMatchType;
break;
}
LocateSchemaTypes(discoveryVersion, schema, ref typesFound);
LocateSchemaElements(discoveryVersion, schema, ref elementsFound);
}
}
if ((typesFound & SchemaTypes.ProbeMatchType) != SchemaTypes.ProbeMatchType)
{
AddSchemaTypes(discoveryVersion, typesFound, discoverySchema);
AddElements(discoveryVersion, elementsFound, discoverySchema);
schemaSet.Reprocess(discoverySchema);
}
return discoveryVersion.Implementation.QualifiedNames.ProbeMatchType;
}
示例5: AddTypeToSchema
static internal void AddTypeToSchema(XmlSchemaType type, XmlSchema schema, XmlSchemaSet schemaSet)
{
XmlSchemaType existingType = (XmlSchemaType)schema.SchemaTypes[new XmlQualifiedName(type.Name, schema.TargetNamespace)];
if (existingType != null)
{
if (existingType == type)
return;
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxConflictingGlobalType, type.Name, schema.TargetNamespace)));
}
schema.Items.Add(type);
schemaSet.Reprocess(schema);
}
示例6: v1
public void v1()
{
XmlSchemaSet sc = new XmlSchemaSet();
try
{
sc.Reprocess(null);
}
catch (ArgumentNullException e)
{
_output.WriteLine(e.ToString());
CError.Compare(sc.Count, 0, "AddCount");
CError.Compare(sc.IsCompiled, false, "AddIsCompiled");
return;
}
Assert.True(false);
}
示例7: AddTypeToSchema
internal static void AddTypeToSchema(XmlSchemaType type, System.Xml.Schema.XmlSchema schema, XmlSchemaSet schemaSet)
{
XmlSchemaType type2 = (XmlSchemaType) schema.SchemaTypes[new XmlQualifiedName(type.Name, schema.TargetNamespace)];
if (type2 != null)
{
if (type2 != type)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxConflictingGlobalType", new object[] { type.Name, schema.TargetNamespace })));
}
}
else
{
schema.Items.Add(type);
schemaSet.Reprocess(schema);
}
}
示例8: AddElementToSchema
static internal void AddElementToSchema(XmlSchemaElement element, XmlSchema schema, XmlSchemaSet schemaSet)
{
XmlSchemaElement existingElement = (XmlSchemaElement)schema.Elements[new XmlQualifiedName(element.Name, schema.TargetNamespace)];
if (existingElement != null)
{
if (element.SchemaType == existingElement.SchemaType && element.SchemaTypeName == existingElement.SchemaTypeName)
return;
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxConflictingGlobalElement, element.Name, schema.TargetNamespace, GetTypeName(element), GetTypeName(existingElement))));
}
schema.Items.Add(element);
if (!element.SchemaTypeName.IsEmpty)
AddImportToSchema(element.SchemaTypeName.Namespace, schema);
schemaSet.Reprocess(schema);
}
示例9: AddDefaultDatasetType
private static void AddDefaultDatasetType(XmlSchemaSet schemas, string localName, string ns)
{
XmlSchemaComplexType item = new XmlSchemaComplexType {
Name = localName,
Particle = new XmlSchemaSequence()
};
XmlSchemaElement element = new XmlSchemaElement {
RefName = new XmlQualifiedName("schema", "http://www.w3.org/2001/XMLSchema")
};
((XmlSchemaSequence) item.Particle).Items.Add(element);
XmlSchemaAny any = new XmlSchemaAny();
((XmlSchemaSequence) item.Particle).Items.Add(any);
XmlSchema schema = SchemaHelper.GetSchema(ns, schemas);
schema.Items.Add(item);
schemas.Reprocess(schema);
}
示例10: AddElementToSchema
internal static void AddElementToSchema(XmlSchemaElement element, System.Xml.Schema.XmlSchema schema, XmlSchemaSet schemaSet)
{
XmlSchemaElement element2 = (XmlSchemaElement) schema.Elements[new XmlQualifiedName(element.Name, schema.TargetNamespace)];
if (element2 != null)
{
if ((element.SchemaType != element2.SchemaType) || (element.SchemaTypeName != element2.SchemaTypeName))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxConflictingGlobalElement", new object[] { element.Name, schema.TargetNamespace, GetTypeName(element), GetTypeName(element2) })));
}
}
else
{
schema.Items.Add(element);
if (!element.SchemaTypeName.IsEmpty)
{
AddImportToSchema(element.SchemaTypeName.Namespace, schema);
}
schemaSet.Reprocess(schema);
}
}
示例11: v1
public void v1(String testDir, String testFile, int expCount, int expCountGT, int expCountGE, int expCountGA)
{
Initialize();
string xsd = Path.Combine(path, testDir, testFile);
XmlSchemaSet ss = new XmlSchemaSet();
XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback);
ss.XmlResolver = new XmlUrlResolver();
XmlSchema Schema1 = ss.Add(Schema);
ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
ValidateWithSchemaInfo(ss);
ss.Compile();
ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after add/comp");
ValidateWithSchemaInfo(ss);
XmlSchema Schema2 = null;
foreach (XmlSchema schema in ss.Schemas())
Schema2 = ss.Reprocess(schema);
ValidateSchemaSet(ss, expCount, false, 1, 0, 0, "Validation after repr");
ValidateWithSchemaInfo(ss);
ss.Compile();
ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after repr/comp");
ValidateWithSchemaInfo(ss);
Assert.Equal(ss.RemoveRecursive(Schema), true);
ValidateSchemaSet(ss, 0, false, 1, 0, 0, "Validation after remRec");
ValidateWithSchemaInfo(ss);
ss.Compile();
ValidateSchemaSet(ss, 0, true, 0, 0, 0, "Validation after remRec/comp");
ValidateWithSchemaInfo(ss);
return;
}
示例12: GetSchema
public static XmlQualifiedName GetSchema(XmlSchemaSet xmlSchemaSet)
{
if (xmlSchemaSet == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlSchemaSet");
}
XmlQualifiedName eprType = EprType;
XmlSchema eprSchema = GetEprSchema();
ICollection is2 = xmlSchemaSet.Schemas("http://schemas.xmlsoap.org/ws/2004/08/addressing");
if ((is2 == null) || (is2.Count == 0))
{
xmlSchemaSet.Add(eprSchema);
return eprType;
}
XmlSchema schema = null;
foreach (XmlSchema schema3 in is2)
{
if (schema3.SchemaTypes.Contains(eprType))
{
schema = null;
break;
}
schema = schema3;
}
if (schema != null)
{
foreach (XmlQualifiedName name2 in eprSchema.Namespaces.ToArray())
{
schema.Namespaces.Add(name2.Name, name2.Namespace);
}
foreach (XmlSchemaObject obj2 in eprSchema.Items)
{
schema.Items.Add(obj2);
}
xmlSchemaSet.Reprocess(schema);
}
return eprType;
}
示例13: v112
public void v112()
{
Initialize();
XmlSchemaSet set2 = new XmlSchemaSet();
set2.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
XmlSchema includedSchema = set2.Add(null, Path.Combine(TestData._Root, "bug382035a1.xsd"));
set2.Compile();
XmlSchemaSet set = new XmlSchemaSet();
set.XmlResolver = new XmlUrlResolver();
set.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
XmlSchema mainSchema = set.Add(null, Path.Combine(TestData._Root, "bug382035a.xsd"));
set.Compile();
XmlReader r = XmlReader.Create(Path.Combine(TestData._Root, "bug382035a1.xsd"));
XmlSchema reParsedInclude = XmlSchema.Read(r, new ValidationEventHandler(ValidationCallback));
((XmlSchemaExternal)mainSchema.Includes[0]).Schema = reParsedInclude;
set.Reprocess(mainSchema);
set.Compile();
CError.Compare(warningCount, 0, "Warning Count mismatch!");
CError.Compare(errorCount, 0, "Error Count mismatch!");
return;
}
示例14: v50
public void v50()
{
bWarningCallback = false;
bErrorCallback = false;
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchema schema = new XmlSchema();
schemaSet.Add(schema);
schema.TargetNamespace = "http://myns/";
//type
XmlSchemaType schemaType = new XmlSchemaComplexType();
schemaType.Name = "MySimpleType";
schema.Items.Add(schemaType);
schemaSet.Reprocess(schema);
schemaSet.Compile();
//element
XmlSchemaElement schemaElement = new XmlSchemaElement();
schemaElement.Name = "MyElement";
schema.Items.Add(schemaElement);
schemaSet.Reprocess(schema);
schemaSet.Compile();
//attribute
XmlSchemaAttribute schemaAttribute = new XmlSchemaAttribute();
schemaAttribute.Name = "MyAttribute";
schema.Items.Add(schemaAttribute);
schemaSet.Reprocess(schema);
schemaSet.Compile();
schemaSet.Reprocess(schema);
schemaSet.Compile();
schema.Items.Remove(schemaType);//what is the best way to remove it?
schema.Items.Remove(schemaElement);
schema.Items.Remove(schemaAttribute);
schemaSet.Reprocess(schema);
schemaSet.Compile();
schemaType = new XmlSchemaComplexType();
schemaType.Name = "MySimpleType";
schema.Items.Add(schemaType);
schema.Items.Add(schemaElement);
schema.Items.Add(schemaAttribute);
schemaSet.Reprocess(schema);
schemaSet.Compile();
CError.Compare(schemaSet.GlobalElements.Count, 1, "Element count mismatch!");
CError.Compare(schemaSet.GlobalAttributes.Count, 1, "Attributes count mismatch!");
CError.Compare(schemaSet.GlobalTypes.Count, 2, "Types count mismatch!");
return;
}
示例15: v51
public void v51(object param0, object param1, object param2, object param3)
{
bWarningCallback = false;
bErrorCallback = false;
string mainFile = TestData._Root + param0.ToString();
string include1 = TestData._Root + param1.ToString();
string include2 = TestData._Root + param2.ToString();
string xmlFile = TestData._Root + "bug382119.xml";
bool IsImport = (bool)param3;
XmlSchemaSet set1 = new XmlSchemaSet();
set1.XmlResolver = new XmlUrlResolver();
set1.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
XmlSchema includedSchema = set1.Add(null, include1);
set1.Compile();
XmlSchemaSet set = new XmlSchemaSet();
set.XmlResolver = new XmlUrlResolver();
set.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
XmlSchema mainSchema = set.Add(null, mainFile);
set.Compile();
_output.WriteLine("First validation ***************");
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
settings.ValidationType = ValidationType.Schema;
settings.Schemas = set;
XmlReader reader = XmlReader.Create(xmlFile, settings);
while (reader.Read()) { }
CError.Compare(bWarningCallback, false, "Warning count mismatch");
CError.Compare(bErrorCallback, true, "Error count mismatch");
if (IsImport == true)
set.Remove(((XmlSchemaExternal)mainSchema.Includes[0]).Schema);
_output.WriteLine("re-setting include");
XmlSchema reParsedInclude = LoadSchema(include2, include1);
((XmlSchemaExternal)mainSchema.Includes[0]).Schema = reParsedInclude;
_output.WriteLine("Calling reprocess");
set.Reprocess(mainSchema);
set.Compile();
bWarningCallback = false;
bErrorCallback = false;
_output.WriteLine("Second validation ***************");
settings.Schemas = set;
reader = XmlReader.Create(xmlFile, settings);
while (reader.Read()) { }
CError.Compare(bWarningCallback, false, "Warning count mismatch");
CError.Compare(bErrorCallback, false, "Error count mismatch");
//Editing the include again
_output.WriteLine("Re-adding include to set1");
XmlSchema reParsedInclude2 = LoadSchema(include1, include1);
set1.Remove(includedSchema);
set1.Add(reParsedInclude2);
set1.Compile();
if (IsImport == true)
set.Remove(((XmlSchemaExternal)mainSchema.Includes[0]).Schema);
((XmlSchemaExternal)mainSchema.Includes[0]).Schema = reParsedInclude2;
set.Reprocess(mainSchema);
set.Compile();
bWarningCallback = false;
bErrorCallback = false;
_output.WriteLine("Third validation, Expecting errors ***************");
settings.Schemas = set;
reader = XmlReader.Create(xmlFile, settings);
while (reader.Read()) { }
CError.Compare(bWarningCallback, false, "Warning count mismatch");
CError.Compare(bErrorCallback, true, "Error count mismatch");
return;
}