private static void ForEach(this XmlSchemaObjectTable table, Action <DictionaryEntry> fn) { foreach (DictionaryEntry item in table) { fn(item); } }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, XmlSchemaObjectTable baseAttributes, ClrContentTypeInfo typeInfo) { foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { if (derivedAttribute.Use == XmlSchemaUse.Prohibited) { continue; } XmlSchemaAttribute baseAttribute = baseAttributes[derivedAttribute.QualifiedName] as XmlSchemaAttribute; if (baseAttribute != null && baseAttribute == derivedAttribute) { // Its the one copied from the base // http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3064 ClrBasePropertyInfo propertyInfo = BuildProperty(derivedAttribute, typeInfo.IsDerived, false, typeInfo); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } else { ClrBasePropertyInfo propertyInfo = BuildProperty(derivedAttribute, false, baseAttribute != null, typeInfo); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } } }
/// <summary> /// Get the type(s) for a given element /// </summary> /// <param name="target">The element for which to obtain the type</param> /// <returns>The type(s) for a given element </returns> public XmlSchemaElement[] findTypes(XmlQualifiedName target) { XmlSchemaElement[] result = null; ArrayList elements = new ArrayList(); XmlSchemaObjectTable globalTypes = schemaSet.GlobalTypes; XmlSchemaType targetType = globalTypes[target] as XmlSchemaType; if (null != targetType) { if (targetType is XmlSchemaComplexType) { XmlSchemaComplexType targetComplexType = targetType as XmlSchemaComplexType; XmlSchemaSequence sequence = targetComplexType.ContentTypeParticle as XmlSchemaSequence; foreach (XmlSchemaElement childElement in sequence.Items) { elements.Add(childElement); } } } if (elements.Count > 0) { result = new XmlSchemaElement[elements.Count]; elements.CopyTo(result, 0); } return(result); }
/// <summary> /// Get the XSD element for a given parameter /// </summary> /// <param name="target">The input / output message for which to fetch the parameter</param> /// <returns>The XSD element for the input / output message</returns> private XmlSchemaElement[] GetParameterElements(XmlQualifiedName target) { XmlSchemaElement[] result = null; ArrayList elements = new ArrayList(); XmlSchemaObjectTable globalElements = schemaSet.GlobalElements; XmlSchemaElement targetElement = globalElements[target] as XmlSchemaElement; if (null != targetElement) { XmlSchemaType schemaType = targetElement.SchemaType; XmlSchemaComplexType schemaComplexType = schemaType as XmlSchemaComplexType; if (schemaComplexType != null) { XmlSchemaParticle particle = schemaComplexType.Particle; XmlSchemaSequence sequence = particle as XmlSchemaSequence; if (sequence != null) { foreach (XmlSchemaElement childElement in sequence.Items) { elements.Add(childElement); } } } } if (elements.Count > 0) { result = new XmlSchemaElement[elements.Count]; elements.CopyTo(result, 0); } return(result); }
private static void AddSchemaObject(XmlSchema schema, XmlSchemaObjectTable table, XmlSchemaObject item) { if (item is XmlSchemaElement element) { if (element.ElementSchemaType is XmlSchemaComplexType comp) { AddComplexType(schema, table, comp); } else if (element.ElementSchemaType is XmlSchemaSimpleType simple) { AddSimpleType(schema, table, simple); } } else if (item is XmlSchemaParticle particle) { if (particle is XmlSchemaGroupBase sequence) { foreach (XmlSchemaObject i in sequence.Items) { AddSchemaObject(schema, table, i); } } } }
private static void AddSimpleType(XmlSchema schema, XmlSchemaObjectTable table, XmlSchemaSimpleType simple) { if (simple.QualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema") { return; } var obj = table[simple.QualifiedName]; if (obj != null) { if (schema.Items.Contains(obj)) { return; } schema.Items.Add(obj); } if (simple.DerivedBy.HasFlag(XmlSchemaDerivationMethod.Union) && simple.Content is XmlSchemaSimpleTypeUnion union) { foreach (var x in union.BaseMemberTypes) { AddSimpleType(schema, table, x); } } if (simple.BaseXmlSchemaType != null && simple.BaseXmlSchemaType is XmlSchemaSimpleType s) { AddSimpleType(schema, table, s); } }
internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs) { if ((element != null) && ((element.Parent != null) && (element.Parent is XmlSchema))) { XmlSchemaObjectTable elements = null; if ((this.Schema != null) && (this.Schema.TargetNamespace == elementNs)) { XmlSchemas.Preprocess(this.Schema); elements = this.Schema.Elements; } else if (this.Schemas != null) { elements = this.Schemas.GlobalElements; } else { return; } foreach (XmlSchemaElement element2 in elements.Values) { if ((element2.Name == element.Name) && (element2.QualifiedName.Namespace == elementNs)) { if (!this.Match(element2, element)) { throw new InvalidOperationException(Res.GetString("XmlSerializableRootDupName", new object[] { this.getSchemaMethod.DeclaringType.FullName, element2.Name, elementNs })); } break; } } } }
private static IEnumerable <XmlSchemaObject> CopyValues(XmlSchemaObjectTable objectTable) { XmlSchemaObject[] objectTableCopy = new XmlSchemaObject[objectTable.Count]; objectTable.Values.CopyTo(objectTableCopy, 0); return(objectTableCopy); }
public SQLColumn(string name, XmlSchemaSimpleType schemaType, XmlSchemaObjectTable schemaTypes, bool required, bool isAttribute, SQLTable table, string nameSpace) { Name = name; Required = required; DataType = GetDataType(schemaType, schemaTypes, 0, nameSpace); IsAttribute = isAttribute; Table = table; }
// Adds all items in the XmlSchemaObjectTable to the specified XmlSchema // private static void AddTableToSchema(XmlSchema outSch, XmlSchemaObjectTable table) { var e = table.GetEnumerator(); while (e.MoveNext()) { outSch.Items.Add((XmlSchemaObject)e.Value); } }
public static IEnumerable <XmlSchemaElement> Iterator(this XmlSchemaObjectTable table) { var en = table.Values.GetEnumerator(); while (en.MoveNext()) { yield return((XmlSchemaElement)en.Current); } }
public void v1() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchemaObjectTable table = sc.GlobalTypes; CError.Compare(table == null, false, "Count"); return; }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, ClrContentTypeInfo typeInfo) { foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { Debug.Assert(derivedAttribute.AttributeSchemaType != null); //For use=prohibited, without derivation it doesnt mean anything, hence attribute should be compiled ClrBasePropertyInfo propertyInfo = BuildProperty(derivedAttribute, false, false); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } }
/// <summary> /// Returns the XmlSchemaObject with the given qname from the given table, or null if no such object exists /// </summary> /// <param name="objectTable"></param> /// <param name="qname"></param> /// <returns></returns> private static XmlSchemaObject GetXmlSchemaObject(XmlSchemaObjectTable objectTable, XmlQualifiedName qname) { XmlSchemaObject xo = null; if (objectTable.Contains(qname)) { xo = objectTable[qname]; } return(xo); }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, ClrContentTypeInfo typeInfo) { foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { Debug.Assert(derivedAttribute.AttributeSchemaType != null); ClrBasePropertyInfo propertyInfo = this.BuildProperty(derivedAttribute, false, false); this.BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } }
private void GenerateAttribute(XmlSchemaObjectTable attributes, InstanceElement elem) { IDictionaryEnumerator ienum = attributes.GetEnumerator(); while (ienum.MoveNext()) { if (ienum.Value is XmlSchemaAttribute) { GenerateInstanceAttribute((XmlSchemaAttribute)ienum.Value, elem); } } }
XmlSchemaObject findElement(XmlSchema schema, XmlQualifiedName nm) { XmlSchemaObjectTable t = schema.Elements; foreach (XmlQualifiedName n in t.Names) { if (nm.Name.Equals(n.Name)) { return(t[n]); } } return(null); }
XmlSchemaObject findType(XmlSchema schema, XmlQualifiedName nm) { { XmlSchemaObjectTable types = schema.SchemaTypes; foreach (XmlQualifiedName n in types.Names) { if (nm.Name.Equals(n.Name)) { return(types[nm]); } } } return(null); }
object Find(XmlSchema schema, XmlQualifiedName name, Type type) { if (!schema.IsCompiled) { XmlSchemaSet set = new XmlSchemaSet(); set.Add(schema); set.Compile(); } XmlSchemaObjectTable tbl = null; if (type == typeof(XmlSchemaSimpleType) || type == typeof(XmlSchemaComplexType)) { tbl = schema.SchemaTypes; } else if (type == typeof(XmlSchemaAttribute)) { tbl = schema.Attributes; } else if (type == typeof(XmlSchemaAttributeGroup)) { tbl = schema.AttributeGroups; } else if (type == typeof(XmlSchemaElement)) { tbl = schema.Elements; } else if (type == typeof(XmlSchemaGroup)) { tbl = schema.Groups; } else if (type == typeof(XmlSchemaNotation)) { tbl = schema.Notations; } object res = (tbl != null) ? tbl [name] : null; if (res != null && res.GetType() != type) { return(null); } else { return(res); } }
private static void AddComplexType(XmlSchema schema, XmlSchemaObjectTable table, XmlSchemaComplexType complex) { if (complex.QualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema") { return; } var obj = table[complex.QualifiedName]; if (obj != null) { if (schema.Items.Contains(obj)) { return; } schema.Items.Add(obj); } if (complex.BaseXmlSchemaType?.Name != null) { if (complex.BaseXmlSchemaType is XmlSchemaComplexType c) { AddComplexType(schema, table, c); } else if (complex.BaseXmlSchemaType is XmlSchemaSimpleType s) { AddSimpleType(schema, table, s); } } if (complex.ContentTypeParticle is XmlSchemaGroupBase sequence) { foreach (XmlSchemaObject item in sequence.Items) { AddSchemaObject(schema, table, item); } } foreach (XmlSchemaAttribute attribute in complex.AttributeUses.Values) { AddSimpleType(schema, table, attribute.AttributeSchemaType); } }
internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs) { if (element == null) { return; } // only check duplicate definitions for top-level element if (element.Parent == null || !(element.Parent is XmlSchema)) { return; } XmlSchemaObjectTable elements = null; if (Schema != null && Schema.TargetNamespace == elementNs) { #if !XMLSERIALIZERGENERATOR XmlSchemas.Preprocess(Schema); elements = Schema.Elements; #endif } else if (Schemas != null) { elements = Schemas.GlobalElements; } else { return; } foreach (XmlSchemaElement e in elements.Values) { if (e.Name == element.Name && e.QualifiedName.Namespace == elementNs) { if (Match(e, element)) { return; } // XmlSerializableRootDupName=Cannot reconcile schema for '{0}'. Please use [XmlRoot] attribute to change name or namepace of the top-level element to avoid duplicate element declarations: element name='{1} namespace='{2}'. throw new InvalidOperationException(SR.Format(SR.XmlSerializableRootDupName, _getSchemaMethod.DeclaringType.FullName, e.Name, elementNs)); } } }
private object Find(XmlSchema schema, XmlQualifiedName name, Type type) { if (!schema.IsCompiled) { schema.Compile(null); } XmlSchemaObjectTable xmlSchemaObjectTable = null; if (type == typeof(XmlSchemaSimpleType) || type == typeof(XmlSchemaComplexType)) { xmlSchemaObjectTable = schema.SchemaTypes; } else if (type == typeof(XmlSchemaAttribute)) { xmlSchemaObjectTable = schema.Attributes; } else if (type == typeof(XmlSchemaAttributeGroup)) { xmlSchemaObjectTable = schema.AttributeGroups; } else if (type == typeof(XmlSchemaElement)) { xmlSchemaObjectTable = schema.Elements; } else if (type == typeof(XmlSchemaGroup)) { xmlSchemaObjectTable = schema.Groups; } else if (type == typeof(XmlSchemaNotation)) { xmlSchemaObjectTable = schema.Notations; } object obj = (xmlSchemaObjectTable == null) ? null : xmlSchemaObjectTable[name]; if (obj != null && obj.GetType() != type) { return(null); } return(obj); }
private XmlSchemaAttribute GetAttributeFromNS(string ns, bool other, XmlSchemaObjectTable attributes) { if (other) { foreach (XmlSchemaAttribute attr in schemaSet.GlobalAttributes.Values) { if (attr.QualifiedName.Namespace != ns && attr.QualifiedName.Namespace != string.Empty && attributes[attr.QualifiedName] == null) { return(attr); } } } else { foreach (XmlSchemaAttribute attr in schemaSet.GlobalAttributes.Values) { if (attr.QualifiedName.Namespace == ns && attributes[attr.QualifiedName] == null) { return(attr); } } } return(null); }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, XmlSchemaObjectTable baseAttributes, ClrContentTypeInfo typeInfo) { ClrBasePropertyInfo propertyInfo; foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { if (derivedAttribute.Use != XmlSchemaUse.Prohibited) { XmlSchemaAttribute baseAttribute = baseAttributes[derivedAttribute.QualifiedName] as XmlSchemaAttribute; if ((baseAttribute == null ? true : baseAttribute != derivedAttribute)) { propertyInfo = this.BuildProperty(derivedAttribute, false, baseAttribute != null); this.BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } else { propertyInfo = this.BuildProperty(derivedAttribute, typeInfo.IsDerived, false); this.BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } } } }
public static void Schema(string xsdFile, string outFile) { XmlSchemaSet schema = new XmlSchemaSet(); schema.Add("http://www.tcxml.org/Schemas/TCXMLSchema", xsdFile); schema.Compile(); XmlSchemaObjectTable table = schema.GlobalElements; System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(outFile, settings)) { writer.WriteStartDocument(true); writer.WriteStartElement("BMO"); //writer.WriteLine("USE Test"); XmlSchemaElement[] array = new XmlSchemaElement[table.Values.Count]; table.Values.CopyTo(array, 0); foreach (XmlSchemaElement el in array) { if (el.ElementSchemaType.BaseXmlSchemaType.GetType().Name.ToString() == "XmlSchemaComplexType") { string elementName = el.Name; XmlSchemaComplexType mType = (XmlSchemaComplexType)el.ElementSchemaType; XmlSchemaAttribute[] Attributes = mType.AttributeUses.Values.Cast <XmlSchemaAttribute>().Select(e => e).ToArray(); if (Attributes.Count() == 0) { continue; } writer.WriteStartElement(elementName); // writer.WriteLine("CREATE TABLE [" + elementName + "] ("); XmlSchemaAttribute last = Attributes.Last(); foreach (XmlSchemaAttribute attr in Attributes) { string name = attr.Name; // string type = attr.AttributeSchemaType.TypeCode.ToString(); string requirement = attr.Use.ToString(); requirement = ((requirement == "Required") ? "Y" : "N"); writer.WriteStartElement(name); //writer.WriteStartAttribute("req"); //writer.WriteValue(requirement); //writer.WriteEndAttribute(); //if (attr.Equals(last)) // writer.WriteLine("\t[" + name + "] " + typeReplace + ((requirement == "Required") ? " NOT NULL" : "")); //else // writer.WriteLine("\t[" + name + "] " + typeReplace + ((requirement == "Required") ? " NOT NULL" : "") + ","); writer.WriteEndElement(); } writer.WriteEndElement(); } } writer.WriteEndDocument(); } }
/// <summary> /// Este metodo nos sirve para extraer los conceptos /// </summary> /// <param name="xmlSchemaObjectTable"></param> private void procesarElementosGlobales(XmlSchemaObjectTable xmlSchemaObjectTable) { if (_nombreDirectorioACrear.Equals("")) { _nombreDirectorioACrear = _prefijoTaxonomíaActual; } Hashtable tuplasPorRevisar = new Hashtable(); //procesamos los elementos declarados globalmente foreach (XmlSchemaElement concepto in xmlSchemaObjectTable.Values) { string grupoSustitucion = concepto.SubstitutionGroup.Name.ToLower(); if (grupoSustitucion.Equals("item")) { IXBRLItemDef item = new XBLRLItemDefinicion(concepto); item.Id = concepto.Id; item.SemanticaTipo = concepto.SchemaTypeName.Name; item.EspacioNombre = concepto.QualifiedName.Namespace; item.Prefijo = (string)_prefijosEspaciosNombres[concepto.QualifiedName.Namespace]; if (_prefijosEspaciosNombres.Contains(item.EspacioNombre)) { item.Nombre = (string)_prefijosEspaciosNombres[item.EspacioNombre] + ':' + concepto.Name; } else { item.Nombre = concepto.Name; } if (concepto.ElementSchemaType.GetType() == typeof(XmlSchemaComplexType)) { XmlSchemaComplexType complexType = (XmlSchemaComplexType)concepto.ElementSchemaType; item.Tipo = complexType.Datatype.ValueType; } item.BalanceAsociado = Balance.Credit; if (getValueAtributo(concepto.UnhandledAttributes, "balance").Equals("debit")) { item.BalanceAsociado = Balance.Debit; } item.Periodo = Period.Duration; if (getValueAtributo(concepto.UnhandledAttributes, "periodtype").Equals("instant")) { item.Periodo = Period.Instant; } if (_items.Contains(item.Nombre)) { IXBRLItemDef guardado = (IXBRLItemDef)_items[item.Nombre]; } _items.Add(item.Nombre, item); GeneradorClases.GeneradorClase gc = GeneradorClases.GeneradorClase.getInstance(_ensambladoCliente); gc.NombreDirectorio = _nombreDirectorioACrear; if (_generarCodigo) { gc.generarCodigo(item); } else { _clases.Add(gc.generarClase(item).ToString()); } } else if (grupoSustitucion.Equals("tuple") && !tuplasPorRevisar.Contains(concepto.Name)) { tuplasPorRevisar.Add(concepto.Name, concepto); } } //miramos las tuplas que no fueron terminadas de rellenar foreach (XmlSchemaElement elementoTuple in tuplasPorRevisar.Values) { IXBRLTupleDef tupla = new XBRLTupleDefinicion(elementoTuple); tupla.Nombre = elementoTuple.Name; tupla.Id = elementoTuple.Id; tupla.Prefijo = (string)_prefijosEspaciosNombres[elementoTuple.QualifiedName.Namespace]; if (elementoTuple.SchemaType.GetType() == typeof(XmlSchemaComplexType)) { XmlSchemaComplexType tipo = (XmlSchemaComplexType)elementoTuple.SchemaType; if (tipo.ContentTypeParticle.GetType() == typeof(XmlSchemaSequence)) { XmlSchemaSequence elementos = (XmlSchemaSequence)tipo.ContentTypeParticle; //para cada elemento de la tupla foreach (XmlSchemaElement elemento in elementos.Items) { IXBRLItemDef item = buscarItem(elemento.QualifiedName); if (item != null) { tupla.Celdas.Add(item); } } } _tuplas.Add(tupla); GeneradorClases.GeneradorClase gc = GeneradorClases.GeneradorClase.getInstance(_ensambladoCliente); gc.NombreDirectorio = _nombreDirectorioACrear; if (_generarCodigo) { gc.generarCodigo(tupla); } else { _clases.Add(gc.generarClase(tupla).ToString()); } } } }
private static SQLDataType GetDataType(XmlSchemaSimpleType schemaType, XmlSchemaObjectTable schemaTypes, int size, string nameSpace) { var result = new SQLDataType(); if (size != 0) { result.Size = size; } if (schemaType.Content is XmlSchemaSimpleTypeRestriction) { var restriction = (XmlSchemaSimpleTypeRestriction)schemaType.Content; foreach (XmlSchemaFacet facet in restriction.Facets) { if (facet is XmlSchemaMaxLengthFacet) { var maxLength = (XmlSchemaMaxLengthFacet)facet; result.Size = Int32.Parse(maxLength.Value); } else if (facet is XmlSchemaTotalDigitsFacet) { var totalDigits = (XmlSchemaTotalDigitsFacet)facet; result.Size = Int32.Parse(totalDigits.Value); } else if (facet is XmlSchemaEnumerationFacet) { if (facet.Value.Length > result.Size) { result.Size = facet.Value.Length; } } else if (facet is XmlSchemaLengthFacet) { var length = (XmlSchemaLengthFacet)facet; result.Size = Int32.Parse(length.Value); } else if (facet is XmlSchemaPatternFacet && result.Size == 0) { var pattern = (XmlSchemaPatternFacet)facet; var patternValue = pattern.Value; if (patternValue.Contains("{") && patternValue.Contains("}")) { var candidate = patternValue; var results = new List <int>(); var temp = GetPatternFacetFieldLengths(candidate); while (temp.Any()) { results = results.Concat(temp).ToList(); var start = candidate.IndexOf("}") + 1; candidate = candidate.Substring(start); temp = GetPatternFacetFieldLengths(candidate); } result.Size = results.Max(); } } } if (restriction.BaseTypeName.Namespace == nameSpace) { //Get the schema type for the schema type name var _schemaType = (XmlSchemaType)schemaTypes[new XmlQualifiedName(restriction.BaseTypeName.Name, restriction.BaseTypeName.Namespace)]; if (_schemaType is XmlSchemaSimpleType) { return(GetDataType((XmlSchemaSimpleType)_schemaType, schemaTypes, result.Size, nameSpace)); } else { result.Name = "unknown(5)"; } } else { result.Name = restriction.BaseTypeName.Name; } } else if (schemaType.Content is XmlSchemaSimpleTypeUnion) { var union = (XmlSchemaSimpleTypeUnion)schemaType.Content; if (union.BaseMemberTypes != null) { result.Name = union.BaseMemberTypes[0].Name; } else if (union.BaseTypes != null) { if (union.BaseTypes[0] is XmlSchemaSimpleType) { return(GetDataType((XmlSchemaSimpleType)union.BaseTypes[0], schemaTypes, 0, nameSpace)); } else { result.Name = union.BaseTypes[0].GetType().ToString(); } } else { result.Name = "unknown(4)"; } } else { result.Name = "unknown(3)"; } return(result); }
private XmlSchemaAttribute GetAttributeFromNS(string ns, XmlSchemaObjectTable attributes) { return(GetAttributeFromNS(ns, false, attributes)); }
private void GenerateAttributeWildCard(XmlSchemaComplexType ct, InstanceElement elem) { char[] whitespace = new char[] { ' ', '\t', '\n', '\r' }; InstanceAttribute attr = null; XmlSchemaAttribute anyAttr = null; XmlSchemaAnyAttribute attributeWildCard = ct.AttributeWildcard; XmlSchemaObjectTable attributes = ct.AttributeUses; string namespaceList = attributeWildCard.Namespace; if (namespaceList == null) { namespaceList = "##any"; } if (attributeWildCard.ProcessContents == XmlSchemaContentProcessing.Skip || attributeWildCard.ProcessContents == XmlSchemaContentProcessing.Lax) { if (namespaceList == "##any" || namespaceList == "##targetNamespace") { attr = new InstanceAttribute(new XmlQualifiedName("any_Attr", rootTargetNamespace)); } else if (namespaceList == "##local") { attr = new InstanceAttribute(new XmlQualifiedName("any_Attr", string.Empty)); } else if (namespaceList == "##other") { attr = new InstanceAttribute(new XmlQualifiedName("any_Attr", "otherNS")); } if (attr != null) { attr.ValueGenerator = XmlValueGenerator.AnySimpleTypeGenerator; elem.AddAttribute(attr); return; } } switch (namespaceList) { case "##any": case "##targetNamespace": anyAttr = GetAttributeFromNS(rootTargetNamespace, attributes); break; case "##other": XmlSchema anySchema = GetParentSchema(attributeWildCard); anyAttr = GetAttributeFromNS(anySchema.TargetNamespace, true, attributes); break; case "##local": //Shd get local elements in some schema anyAttr = GetAttributeFromNS(string.Empty, attributes); break; default: foreach (string ns in attributeWildCard.Namespace.Split(whitespace)) { if (ns == "##local") { anyAttr = GetAttributeFromNS(string.Empty, attributes); } else if (ns == "##targetNamespace") { anyAttr = GetAttributeFromNS(rootTargetNamespace, attributes); } else { anyAttr = GetAttributeFromNS(ns, attributes); } if (anyAttr != null) //Found match { break; } } break; } if (anyAttr != null) { GenerateInstanceAttribute(anyAttr, elem); } else //Write comment in generated XML that match for wild card cd not be found. { if (elem.Comment.Length == 0) //For multiple attribute wildcards in the same element, generate comment only once { elem.Comment.Append(" Attribute Wild card could not be matched. Generated XML may not be valid. "); } } }