public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { S_OS_STANJE_LOKACIJA_SVI_BROJEVIDataSet set = new S_OS_STANJE_LOKACIJA_SVI_BROJEVIDataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { URAVRSTAIZNOSADataSet set = new URAVRSTAIZNOSADataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { S_OS_POSTOJECI_DOKUMENTIDataSet set = new S_OS_POSTOJECI_DOKUMENTIDataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
private static XmlSchemaComplexType CreateAnyType() { XmlSchemaComplexType anyType = new XmlSchemaComplexType(); anyType.IsMixed = true; anyType.Particle = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny(); any.MinOccurs = 0; any.MaxOccurs = decimal.MaxValue; any.ProcessContents = XmlSchemaContentProcessing.Lax; ((XmlSchemaSequence)anyType.Particle).Items.Add(any); anyType.AnyAttribute = new XmlSchemaAnyAttribute(); return(anyType); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { vw_mjeseci_godine_isplateDataSet set = new vw_mjeseci_godine_isplateDataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { vw_DD_MJESECI_GODINE_ISPLATEDataSet set = new vw_DD_MJESECI_GODINE_ISPLATEDataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { S_OD_KONACNI_POREZ_PO_OPCINAMADataSet set = new S_OD_KONACNI_POREZ_PO_OPCINAMADataSet(); XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = set.Namespace }; sequence.Items.Add(item); type2.Particle = sequence; return(type2); }
private static XmlSchemaElement CountSchema() { XmlSchemaComplexType type = new XmlSchemaComplexType(); XmlSchemaAttribute attrib = new XmlSchemaAttribute(); attrib.Name = "min"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); attrib = new XmlSchemaAttribute(); attrib.Name = "max"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); attrib = new XmlSchemaAttribute(); attrib.Name = "expressionLanguage"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); attrib = new XmlSchemaAttribute(); attrib.Name = "failMessage"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); XmlSchemaAny any = new XmlSchemaAny(); any.MinOccurs = 1; any.MaxOccursString = "unbounded"; any.ProcessContents = XmlSchemaContentProcessing.Strict; any.Namespace = "##local"; XmlSchemaSequence sequence = new XmlSchemaSequence(); type.Particle = sequence; sequence.Items.Add(any); XmlSchemaElement element = new XmlSchemaElement(); element.Name = "count"; element.SchemaType = type; return(element); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { GaugeData gaugeData = new GaugeData(); XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(); XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence(); xs.Add(gaugeData.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = gaugeData.Namespace }; xmlSchemaSequence.Items.Add(item); xmlSchemaComplexType.Particle = xmlSchemaSequence; return(xmlSchemaComplexType); }
private void Write53_XmlSchemaAny(XmlSchemaAny o) { if (o != null) { this.WriteStartElement("any"); this.WriteAttribute("id", "", o.Id); this.WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs)); this.WriteAttribute("maxOccurs", "", (o.MaxOccurs == 79228162514264337593543950335M) ? "unbounded" : XmlConvert.ToString(o.MaxOccurs)); this.WriteAttribute("namespace", "", ToString(o.NamespaceList)); XmlSchemaContentProcessing v = (o.ProcessContents == XmlSchemaContentProcessing.None) ? XmlSchemaContentProcessing.Strict : o.ProcessContents; this.WriteAttribute("processContents", "", this.Write34_XmlSchemaContentProcessing(v)); this.WriteAttributes(o.UnhandledAttributes, o); this.Write5_XmlSchemaAnnotation(o.Annotation); this.WriteEndElement(); } }
protected override void Visit(XmlSchemaAny particle) { if (particle.MaxOccurs == 0) { return; } PushNode(ChildType.Any, particle.Parent, particle); foreach (XmlSchemaElement extensionElement in _schemaSetManager.GetExtensionElements(particle)) { AddLeaf(ChildType.ElementExtension, particle, extensionElement); } PopNode(); }
private static XmlSchemaComplexType CreateAnyElementType() { XmlSchemaComplexType anyElementType = new XmlSchemaComplexType { IsMixed = false, Particle = new XmlSchemaSequence() }; XmlSchemaAny any = new XmlSchemaAny { MinOccurs = 0, ProcessContents = XmlSchemaContentProcessing.Lax }; ((XmlSchemaSequence)anyElementType.Particle).Items.Add(any); return(anyElementType); }
static void AddProbeType(DiscoveryVersion discoveryVersion, XmlSchema schema) { // <xs:complexType name="ProbeType"> XmlSchemaComplexType probeType = new XmlSchemaComplexType(); probeType.Name = ProtocolStrings.SchemaNames.ProbeType; // <xs:sequence> XmlSchemaSequence probeTypeSequence = new XmlSchemaSequence(); // <xs:element ref="tns:Types" minOccurs="0" /> XmlSchemaElement typesElement = new XmlSchemaElement(); typesElement.RefName = discoveryVersion.Implementation.QualifiedNames.TypesElement; typesElement.MinOccurs = 0; // <xs:element ref="tns:Scopes" minOccurs="0" /> XmlSchemaElement scopesElement = new XmlSchemaElement(); scopesElement.RefName = discoveryVersion.Implementation.QualifiedNames.ScopesElement; scopesElement.MinOccurs = 0; // <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" /> XmlSchemaAny any = new XmlSchemaAny(); any.Namespace = "##other"; any.ProcessContents = XmlSchemaContentProcessing.Lax; any.MinOccurs = 0; any.MaxOccurs = decimal.MaxValue; // </xs:sequence> probeTypeSequence.Items.Add(typesElement); probeTypeSequence.Items.Add(scopesElement); probeTypeSequence.Items.Add(any); // <xs:anyAttribute namespace="##other" processContents="lax" /> XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute(); anyAttribue.Namespace = "##other"; anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax; // </xs:complexType> probeType.Particle = probeTypeSequence; probeType.AnyAttribute = anyAttribue; schema.Items.Add(probeType); }
private static void AddDefaultTypedDatasetType(XmlSchemaSet schemas, XmlSchema datasetSchema, string localName, string ns) { XmlSchemaComplexType type = new XmlSchemaComplexType(); type.Name = localName; type.Particle = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny(); any.Namespace = (datasetSchema.TargetNamespace == null) ? String.Empty : datasetSchema.TargetNamespace; ((XmlSchemaSequence)type.Particle).Items.Add(any); schemas.Add(datasetSchema); XmlSchema schema = SchemaHelper.GetSchema(ns, schemas); schema.Items.Add(type); schemas.Reprocess(datasetSchema); schemas.Reprocess(schema); }
private static void AddDefaultDatasetType(XmlSchemaSet schemas, string localName, string ns) { XmlSchemaComplexType type = new XmlSchemaComplexType(); type.Name = localName; type.Particle = new XmlSchemaSequence(); XmlSchemaElement schemaRefElement = new XmlSchemaElement(); schemaRefElement.RefName = new XmlQualifiedName(Globals.SchemaLocalName, XmlSchema.Namespace); ((XmlSchemaSequence)type.Particle).Items.Add(schemaRefElement); XmlSchemaAny any = new XmlSchemaAny(); ((XmlSchemaSequence)type.Particle).Items.Add(any); XmlSchema schema = SchemaHelper.GetSchema(ns, schemas); schema.Items.Add(type); schemas.Reprocess(schema); }
public static string GetTargetNS(this XmlSchemaAny any) { XmlSchemaObject parentObj = any.Parent; XmlSchema schemaObj = parentObj as XmlSchema; while (schemaObj == null) { if (parentObj != null) { parentObj = parentObj.Parent; schemaObj = parentObj as XmlSchema; } else { break; } } return(schemaObj != null ? schemaObj.TargetNamespace : ""); }
void Write53_XmlSchemaAny(XmlSchemaAny o) { if ((object)o == null) { return; } WriteStartElement("any"); WriteAttribute(@"id", @"", o.@Id); WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs)); WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs)); WriteAttribute(@"namespace", @"", ToString(o.NamespaceList)); XmlSchemaContentProcessing process = o.@ProcessContents == XmlSchemaContentProcessing.@None ? XmlSchemaContentProcessing.Strict : o.@ProcessContents; WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation); WriteEndElement(); }
public static bool ContainsWildCard(this XmlSchemaParticle particle, XmlSchemaAny any) { XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle p in groupBase.Items) { if (p == any) { return(true); } else if (p.ContainsWildCard(any)) { return(true); } } } return(false); }
public static XmlSchemaComplexType GetTypedTableSchema(XmlSchemaSet xs) { XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(); XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence(); GaugeData gaugeData = new GaugeData(); xs.Add(gaugeData.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = "http://www.w3.org/2001/XMLSchema", MinOccurs = 0m, MaxOccurs = decimal.MaxValue, ProcessContents = XmlSchemaContentProcessing.Lax }; xmlSchemaSequence.Items.Add(item); XmlSchemaAny item2 = new XmlSchemaAny { Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1", MinOccurs = 1m, ProcessContents = XmlSchemaContentProcessing.Lax }; xmlSchemaSequence.Items.Add(item2); XmlSchemaAttribute item3 = new XmlSchemaAttribute { Name = "namespace", FixedValue = gaugeData.Namespace }; xmlSchemaComplexType.Attributes.Add(item3); XmlSchemaAttribute item4 = new XmlSchemaAttribute { Name = "tableTypeName", FixedValue = "ValuesDataTable" }; xmlSchemaComplexType.Attributes.Add(item4); xmlSchemaComplexType.Particle = xmlSchemaSequence; return(xmlSchemaComplexType); }
public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { if (type == null) { return(null); } if (importedTypes[type] != null) { mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataSet).Namespace)); compileUnit.ReferencedAssemblies.Add("System.Data.dll"); return((string)importedTypes[type]); } if (!(context is XmlSchemaElement)) { return(null); } if (type is XmlSchemaComplexType) { XmlSchemaComplexType ct = (XmlSchemaComplexType)type; if (ct.Particle is XmlSchemaSequence) { XmlSchemaObjectCollection items = ((XmlSchemaSequence)ct.Particle).Items; if (items.Count == 2 && items[0] is XmlSchemaAny && items[1] is XmlSchemaAny) { XmlSchemaAny any0 = (XmlSchemaAny)items[0]; XmlSchemaAny any1 = (XmlSchemaAny)items[1]; if (any0.Namespace == XmlSchema.Namespace && any1.Namespace == "urn:schemas-microsoft-com:xml-diffgram-v1") { string typeName = typeof(DataTable).FullName; importedTypes.Add(type, typeName); mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataTable).Namespace)); compileUnit.ReferencedAssemblies.Add("System.Data.dll"); return(typeName); } } } } return(null); }
public XmlSchema GetSchema() { XmlSchema s = new XmlSchema(); s.TargetNamespace = "http://www.go-mono.org/schemas"; s.Id = "monoschema"; XmlSchemaElement e = new XmlSchemaElement(); e.Name = "data"; s.Items.Add(e); XmlSchemaComplexType cs = new XmlSchemaComplexType(); XmlSchemaSequence seq = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny(); any.MinOccurs = 0; any.MaxOccurs = decimal.MaxValue; seq.Items.Add(any); cs.Particle = seq; e.SchemaType = cs; return(s); }
private void RegisterExtensionElement(XmlSchemaAny parent, XmlSchemaElement element) { // Just there to require the argument to be of type XmlSchemaElement. Debug.Assert(element.Name != null); // Add object to parent's extension elements. List <XmlSchemaObject> elements; if (!_extensionElements.TryGetValue(parent, out elements)) { elements = new List <XmlSchemaObject>(); _extensionElements.Add(parent, elements); } elements.Add(element); // Add parent to object's parents. RegisterParent(element, parent); }
public static XmlSchemaComplexType GetTypedTableSchema(XmlSchemaSet xs) { XmlSchemaComplexType type2 = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); VW_GODINE_ISPLATEDataSet set = new VW_GODINE_ISPLATEDataSet(); xs.Add(set.GetSchemaSerializable()); XmlSchemaAny item = new XmlSchemaAny { Namespace = "http://www.w3.org/2001/XMLSchema" }; decimal num = new decimal(0); item.MinOccurs = num; item.MaxOccurs = 79228162514264337593543950335M; item.ProcessContents = XmlSchemaContentProcessing.Lax; sequence.Items.Add(item); XmlSchemaAny any2 = new XmlSchemaAny { Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" }; num = new decimal(1); any2.MinOccurs = num; any2.ProcessContents = XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); XmlSchemaAttribute attribute = new XmlSchemaAttribute { Name = "namespace", FixedValue = set.Namespace }; type2.Attributes.Add(attribute); XmlSchemaAttribute attribute2 = new XmlSchemaAttribute { Name = "tableTypeName", FixedValue = "InvoiceDataTable" }; type2.Attributes.Add(attribute2); type2.Particle = sequence; return(type2); }
//Exports <xs:type for SMMessage //FIXME: complex type for this can be made static QName ExportTypeMessage() { XmlSchema xs = GetSchema("http://schemas.microsoft.com/Message"); QName qname = new QName("MessageBody", xs.TargetNamespace); foreach (XmlSchemaObject o in xs.Items) { XmlSchemaComplexType ct = o as XmlSchemaComplexType; if (ct == null) { continue; } if (ct.Name == "MessageBody") { //Already exported return(qname); } } XmlSchemaComplexType complex_type = new XmlSchemaComplexType(); complex_type.Name = "MessageBody"; XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny(); any.MinOccurs = 0; any.MaxOccursString = "unbounded"; any.Namespace = "##any"; sequence.Items.Add(any); complex_type.Particle = sequence; xs.Items.Add(complex_type); GeneratedXmlSchemas.Reprocess(xs); return(qname); }
static void AddResolveType(DiscoveryVersion discoveryVersion, XmlSchema schema) { //<xs:complexType name="ResolveType" > XmlSchemaComplexType resolveType = new XmlSchemaComplexType(); resolveType.Name = ProtocolStrings.SchemaNames.ResolveType; // <xs:sequence> XmlSchemaSequence resolveSequence = new XmlSchemaSequence(); // <xs:element ref="wsa:EndpointReference" /> XmlSchemaElement eprElement = new XmlSchemaElement(); eprElement.RefName = discoveryVersion.Implementation.QualifiedNames.EprElement; // <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax" /> XmlSchemaAny any = new XmlSchemaAny(); any.Namespace = "##other"; any.ProcessContents = XmlSchemaContentProcessing.Lax; any.MinOccurs = 0; any.MaxOccurs = decimal.MaxValue; resolveSequence.Items.Add(eprElement); resolveSequence.Items.Add(any); // <xs:anyAttribute namespace="##other" processContents="lax" /> XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute(); anyAttribue.Namespace = "##other"; anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax; // </xs:complexType> resolveType.Particle = resolveSequence; resolveType.AnyAttribute = anyAttribue; schema.Items.Add(resolveType); }
public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { if (type != null) { if (this.importedTypes[type] != null) { mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataSet).Namespace)); compileUnit.ReferencedAssemblies.Add("System.Data.dll"); return((string)this.importedTypes[type]); } if (!(context is XmlSchemaElement)) { return(null); } if (type is XmlSchemaComplexType) { XmlSchemaComplexType type2 = (XmlSchemaComplexType)type; if (type2.Particle is XmlSchemaSequence) { XmlSchemaObjectCollection items = ((XmlSchemaSequence)type2.Particle).Items; if (((items.Count == 2) && (items[0] is XmlSchemaAny)) && (items[1] is XmlSchemaAny)) { XmlSchemaAny any = (XmlSchemaAny)items[0]; XmlSchemaAny any2 = (XmlSchemaAny)items[1]; if ((any.Namespace == "http://www.w3.org/2001/XMLSchema") && (any2.Namespace == "urn:schemas-microsoft-com:xml-diffgram-v1")) { string fullName = typeof(DataTable).FullName; this.importedTypes.Add(type, fullName); mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataTable).Namespace)); compileUnit.ReferencedAssemblies.Add("System.Data.dll"); return(fullName); } } } } } return(null); }
/// <include file='doc\XmlSchemaExporter.uex' path='docs/doc[@for="XmlSchemaExporter.ExportAnyType"]/*' /> public string ExportAnyType(string ns) { string name = "any"; int i = 1; XmlSchema schema = schemas[ns]; if (schema != null) { while (true) { XmlSchemaType schemaType = FindSchemaType(name, schema.Items); if (schemaType == null) { break; } if (IsAnyType(schemaType)) { return(name); } i++; name = "any" + i.ToString(); } } XmlSchemaComplexType type = new XmlSchemaComplexType(); type.Name = name; type.IsMixed = true; XmlSchemaSequence seq = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny(); any.MinOccurs = 0; any.MaxOccurs = decimal.MaxValue; seq.Items.Add(any); type.Particle = seq; AddSchemaItem(type, ns, null); return(name); }
public static XmlSchemaElement OrSchema() { var type = new XmlSchemaComplexType(); var any = new XmlSchemaAny(); any.MinOccurs = 1; any.MaxOccursString = "unbounded"; any.ProcessContents = XmlSchemaContentProcessing.Strict; any.Namespace = "##local"; var sequence = new XmlSchemaSequence(); type.Particle = sequence; sequence.Items.Add(any); var attrib = new XmlSchemaAttribute(); attrib.Name = "expressionLanguage"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); attrib = new XmlSchemaAttribute(); attrib.Name = "failMessage"; attrib.Use = XmlSchemaUse.Optional; attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); type.Attributes.Add(attrib); var element = new XmlSchemaElement(); element.Name = "or"; element.SchemaType = type; return(element); }
public static XmlSchemaComplexType GetTypedTableSchema(XmlSchemaSet xs) { XmlSchemaComplexType type = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); HaushaltsbuchDS ds = new HaushaltsbuchDS(); XmlSchemaAny any1 = new XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); XmlSchemaAny any2 = new XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); XmlSchemaAttribute attribute1 = new XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); XmlSchemaAttribute attribute2 = new XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BuchungssatzDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { MemoryStream s1 = new MemoryStream(); MemoryStream s2 = new MemoryStream(); try { XmlSchema schema = null; dsSchema.Write(s1); for (IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
/// <summary> /// Run the application with the given arguments. /// </summary> /// <param name="args">The commandline arguments.</param> /// <returns>The number of errors that were found.</returns> private int Run(string[] args) { XmlSchema mainSchema = null; XmlSchemaCollection schemas = new XmlSchemaCollection(); try { this.ParseCommandLine(args); if (this.showLogo) { Assembly thisAssembly = Assembly.GetExecutingAssembly(); Console.WriteLine("Microsoft (R) Windows Installer Xsd Stitch version {0}", thisAssembly.GetName().Version.ToString()); Console.WriteLine("Copyright (C) Microsoft Corporation 2006. All rights reserved."); Console.WriteLine(); } if (this.showHelp) { Console.WriteLine(" usage: xsdStitch.exe mainSchema.xsd stitched.xsd"); Console.WriteLine(); Console.WriteLine(" -ext extSchema.xsd adds an extension schema to the main schema"); Console.WriteLine(" -nologo suppress displaying the logo information"); Console.WriteLine(" -? this help information"); Console.WriteLine(); return(0); } XmlTextReader mainSchemaReader = null; // load the main schema try { mainSchemaReader = new XmlTextReader(this.mainSchemaFile); mainSchema = XmlSchema.Read(mainSchemaReader, null); schemas.Add(mainSchema); } finally { if (null != mainSchemaReader) { mainSchemaReader.Close(); } } StringCollection addedSchemas = new StringCollection(); // load the extension schemas foreach (string extensionSchemaFile in this.extensionSchemaFiles) { XmlTextReader reader = null; try { string schemaFilename = Path.GetFileNameWithoutExtension(extensionSchemaFile); if (addedSchemas.Contains(schemaFilename)) { int duplicateNameCounter = 2; while (addedSchemas.Contains(String.Concat(schemaFilename, duplicateNameCounter))) { duplicateNameCounter++; } schemaFilename = String.Concat(schemaFilename, duplicateNameCounter); } addedSchemas.Add(schemaFilename); reader = new XmlTextReader(extensionSchemaFile); XmlSchema extensionSchema = XmlSchema.Read(reader, null); mainSchema.Namespaces.Add(schemaFilename, extensionSchema.TargetNamespace); schemas.Add(extensionSchema); // add an import for the extension schema XmlSchemaImport import = new XmlSchemaImport(); import.Namespace = extensionSchema.TargetNamespace; import.SchemaLocation = Path.GetFileName(extensionSchemaFile); mainSchema.Includes.Add(import); } finally { if (null != reader) { reader.Close(); } } } foreach (XmlSchema schema in schemas) { if (schema != mainSchema) { foreach (XmlSchemaElement element in schema.Elements.Values) { // retrieve explicitly-specified parent elements if (element.Annotation != null) { foreach (XmlSchemaObject obj in element.Annotation.Items) { XmlSchemaAppInfo appInfo = obj as XmlSchemaAppInfo; if (appInfo != null) { foreach (XmlNode node in appInfo.Markup) { XmlElement markupElement = node as XmlElement; if (markupElement != null && markupElement.LocalName == "parent" && markupElement.NamespaceURI == XmlSchemaExtensionNamespace) { string parentNamespace = markupElement.GetAttribute("namespace"); string parentRef = markupElement.GetAttribute("ref"); if (parentNamespace.Length == 0) { throw new ApplicationException("The parent element is missing the namespace attribute."); } if (parentRef.Length == 0) { throw new ApplicationException("The parent element is missing the ref attribute."); } XmlQualifiedName parentQualifiedName = new XmlQualifiedName(parentRef, parentNamespace); XmlSchemaElement parentElement = (XmlSchemaElement)mainSchema.Elements[parentQualifiedName]; XmlSchemaComplexType complexType = (XmlSchemaComplexType)parentElement.ElementType; if (complexType.Particle != null) { XmlSchemaElement elementRef = new XmlSchemaElement(); elementRef.RefName = element.QualifiedName; this.InsertElement(complexType.Particle, elementRef); } } } } } } } foreach (XmlSchemaAttribute attribute in schema.Attributes.Values) { if (attribute.Annotation != null) { foreach (XmlSchemaObject obj in attribute.Annotation.Items) { XmlSchemaAppInfo appInfo = obj as XmlSchemaAppInfo; if (appInfo != null) { foreach (XmlNode node in appInfo.Markup) { XmlElement markupElement = node as XmlElement; if (markupElement != null && markupElement.LocalName == "parent" && markupElement.NamespaceURI == XmlSchemaExtensionNamespace) { string parentNamespace = markupElement.GetAttribute("namespace"); string parentRef = markupElement.GetAttribute("ref"); if (parentNamespace.Length == 0) { throw new ApplicationException("The parent element is missing the namespace attribute."); } if (parentRef.Length == 0) { throw new ApplicationException("The parent element is missing the ref attribute."); } XmlQualifiedName parentQualifiedName = new XmlQualifiedName(parentRef, parentNamespace); XmlSchemaElement parentElement = (XmlSchemaElement)mainSchema.Elements[parentQualifiedName]; XmlSchemaComplexType complexType = (XmlSchemaComplexType)parentElement.ElementType; if (complexType.Particle != null) { XmlSchemaAttribute attributeRef = new XmlSchemaAttribute(); attributeRef.RefName = attribute.QualifiedName; anyAttributeElements.Add(complexType); complexType.Attributes.Add(attribute); } } } } } } } } } // remove the any items foreach (DictionaryEntry entry in this.anys) { XmlSchemaAny any = (XmlSchemaAny)entry.Key; XmlSchemaParticle particle = (XmlSchemaParticle)entry.Value; if (particle is XmlSchemaChoice) { XmlSchemaChoice choice = (XmlSchemaChoice)particle; choice.Items.Remove(any); } else if (particle is XmlSchemaSequence) { XmlSchemaSequence sequence = (XmlSchemaSequence)particle; sequence.Items.Remove(any); } } // remove anyAttribute items foreach (XmlSchemaComplexType complexType in this.anyAttributeElements) { complexType.AnyAttribute = null; } XmlTextWriter writer = null; try { writer = new XmlTextWriter(this.outputFile, System.Text.Encoding.Default); writer.Indentation = 4; writer.IndentChar = ' '; writer.Formatting = Formatting.Indented; mainSchema.Write(writer); } finally { writer.Close(); } } catch (Exception e) { Console.WriteLine("xsdStitch.exe : fatal error XSDS0001 : {0}\r\n\n\nStack Trace:\r\n{1}", e.Message, e.StackTrace); return(1); } return(0); }
public void DumpAny (XmlSchemaAny any) { depth++; IndentLine ("**Any**"); // IndentLine ("Namespace: " + any.Namespace); depth--; }