public bool Validate(XmlNode nodeToValidate) { XmlSchemaObject partialValidationType = null; XmlSchemaValidationFlags validationFlags = XmlSchemaValidationFlags.AllowXmlAttributes; Debug.Assert(nodeToValidate.SchemaInfo != null); _startNode = nodeToValidate; switch (nodeToValidate.NodeType) { case XmlNodeType.Document: validationFlags |= XmlSchemaValidationFlags.ProcessIdentityConstraints; break; case XmlNodeType.DocumentFragment: break; case XmlNodeType.Element: //Validate children of this element IXmlSchemaInfo schemaInfo = nodeToValidate.SchemaInfo; XmlSchemaElement schemaElement = schemaInfo.SchemaElement; if (schemaElement != null) { if (!schemaElement.RefName.IsEmpty) { //If it is element ref, partialValidationType = _schemas.GlobalElements[schemaElement.QualifiedName]; //Get Global element with correct Nillable, Default etc } else { //local element partialValidationType = schemaElement; } //Verify that if there was xsi:type, the schemaElement returned has the correct type set Debug.Assert(schemaElement.ElementSchemaType == schemaInfo.SchemaType); } else { //Can be an element that matched xs:any and had xsi:type partialValidationType = schemaInfo.SchemaType; if (partialValidationType == null) { //Validated against xs:any with pc= lax or skip or undeclared / not validated element if (nodeToValidate.ParentNode.NodeType == XmlNodeType.Document) { //If this is the documentElement and it has not been validated at all nodeToValidate = nodeToValidate.ParentNode; } else { partialValidationType = FindSchemaInfo(nodeToValidate as XmlElement); if (partialValidationType == null) { throw new XmlSchemaValidationException(ResXml.XmlDocument_NoNodeSchemaInfo, null, nodeToValidate); } } } } break; case XmlNodeType.Attribute: if (nodeToValidate.XPNodeType == XPathNodeType.Namespace) { goto default; } partialValidationType = nodeToValidate.SchemaInfo.SchemaAttribute; if (partialValidationType == null) { //Validated against xs:anyAttribute with pc = lax or skip / undeclared attribute partialValidationType = FindSchemaInfo(nodeToValidate as XmlAttribute); if (partialValidationType == null) { throw new XmlSchemaValidationException(ResXml.XmlDocument_NoNodeSchemaInfo, null, nodeToValidate); } } break; default: throw new InvalidOperationException(string.Format(ResXml.XmlDocument_ValidateInvalidNodeType, null)); } _isValid = true; CreateValidator(partialValidationType, validationFlags); if (_psviAugmentation) { if (_schemaInfo == null) { //Might have created it during FindSchemaInfo _schemaInfo = new XmlSchemaInfo(); } _attributeSchemaInfo = new XmlSchemaInfo(); } ValidateNode(nodeToValidate); _validator.EndValidation(); return(_isValid); }
public void Initialize(XmlSchemaObject partialValidationType) { }
internal void Depends(XmlSchemaObject item, ArrayList refs) { if (item == null || _scope[item] != null) { return; } Type t = item.GetType(); if (typeof(XmlSchemaType).IsAssignableFrom(t)) { XmlQualifiedName baseName = XmlQualifiedName.Empty; XmlSchemaType baseType = null; XmlSchemaParticle particle = null; XmlSchemaObjectCollection attributes = null; if (item is XmlSchemaComplexType) { XmlSchemaComplexType ct = (XmlSchemaComplexType)item; if (ct.ContentModel != null) { XmlSchemaContent content = ct.ContentModel.Content; if (content is XmlSchemaComplexContentRestriction) { baseName = ((XmlSchemaComplexContentRestriction)content).BaseTypeName; attributes = ((XmlSchemaComplexContentRestriction)content).Attributes; } else if (content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content; if (restriction.BaseType != null) { baseType = restriction.BaseType; } else { baseName = restriction.BaseTypeName; } attributes = restriction.Attributes; } else if (content is XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content; attributes = extension.Attributes; particle = extension.Particle; baseName = extension.BaseTypeName; } else if (content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension)content; attributes = extension.Attributes; baseName = extension.BaseTypeName; } } else { attributes = ct.Attributes; particle = ct.Particle; } if (particle is XmlSchemaGroupRef) { XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle; particle = ((XmlSchemaGroup)_schemas.Find(refGroup.RefName, typeof(XmlSchemaGroup), false)).Particle; } else if (particle is XmlSchemaGroupBase) { particle = (XmlSchemaGroupBase)particle; } } else if (item is XmlSchemaSimpleType) { XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)item; XmlSchemaSimpleTypeContent content = simpleType.Content; if (content is XmlSchemaSimpleTypeRestriction) { baseType = ((XmlSchemaSimpleTypeRestriction)content).BaseType; baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName; } else if (content is XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content; if (list.ItemTypeName != null && !list.ItemTypeName.IsEmpty) { baseName = list.ItemTypeName; } if (list.ItemType != null) { baseType = list.ItemType; } } else if (content is XmlSchemaSimpleTypeRestriction) { baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName; } else if (t == typeof(XmlSchemaSimpleTypeUnion)) { XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes; if (memberTypes != null) { for (int i = 0; i < memberTypes.Length; i++) { XmlSchemaType type = (XmlSchemaType)_schemas.Find(memberTypes[i], typeof(XmlSchemaType), false); AddRef(refs, type); } } } } if (baseType == null && !baseName.IsEmpty && baseName.Namespace != XmlSchema.Namespace) { baseType = (XmlSchemaType)_schemas.Find(baseName, typeof(XmlSchemaType), false); } if (baseType != null) { AddRef(refs, baseType); } if (particle != null) { Depends(particle, refs); } if (attributes != null) { for (int i = 0; i < attributes.Count; i++) { Depends(attributes[i], refs); } } } else if (t == typeof(XmlSchemaElement)) { XmlSchemaElement el = (XmlSchemaElement)item; if (!el.SubstitutionGroup.IsEmpty) { if (el.SubstitutionGroup.Namespace != XmlSchema.Namespace) { XmlSchemaElement head = (XmlSchemaElement)_schemas.Find(el.SubstitutionGroup, typeof(XmlSchemaElement), false); AddRef(refs, head); } } if (!el.RefName.IsEmpty) { el = (XmlSchemaElement)_schemas.Find(el.RefName, typeof(XmlSchemaElement), false); AddRef(refs, el); } else if (!el.SchemaTypeName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)_schemas.Find(el.SchemaTypeName, typeof(XmlSchemaType), false); AddRef(refs, type); } else { Depends(el.SchemaType, refs); } } else if (t == typeof(XmlSchemaGroup)) { Depends(((XmlSchemaGroup)item).Particle); } else if (t == typeof(XmlSchemaGroupRef)) { XmlSchemaGroup group = (XmlSchemaGroup)_schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false); AddRef(refs, group); } else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(t)) { foreach (XmlSchemaObject o in ((XmlSchemaGroupBase)item).Items) { Depends(o, refs); } } else if (t == typeof(XmlSchemaAttributeGroupRef)) { XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup)_schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false); AddRef(refs, group); } else if (t == typeof(XmlSchemaAttributeGroup)) { foreach (XmlSchemaObject o in ((XmlSchemaAttributeGroup)item).Attributes) { Depends(o, refs); } } else if (t == typeof(XmlSchemaAttribute)) { XmlSchemaAttribute at = (XmlSchemaAttribute)item; if (!at.RefName.IsEmpty) { at = (XmlSchemaAttribute)_schemas.Find(at.RefName, typeof(XmlSchemaAttribute), false); AddRef(refs, at); } else if (!at.SchemaTypeName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)_schemas.Find(at.SchemaTypeName, typeof(XmlSchemaType), false); AddRef(refs, type); } else { Depends(at.SchemaType, refs); } } if (typeof(XmlSchemaAnnotated).IsAssignableFrom(t)) { XmlAttribute[] attrs = (XmlAttribute[])((XmlSchemaAnnotated)item).UnhandledAttributes; if (attrs != null) { for (int i = 0; i < attrs.Length; i++) { XmlAttribute attribute = attrs[i]; if (attribute.LocalName == Wsdl.ArrayType && attribute.NamespaceURI == Wsdl.Namespace) { string dims; XmlQualifiedName qname = TypeScope.ParseWsdlArrayType(attribute.Value, out dims, item); XmlSchemaType type = (XmlSchemaType)_schemas.Find(qname, typeof(XmlSchemaType), false); AddRef(refs, type); } } } } }
private static string GetSchemaItem(XmlSchemaObject o, string ns, string details) { if (o != null) { while ((o.Parent != null) && !(o.Parent is XmlSchema)) { o = o.Parent; } if ((ns == null) || (ns.Length == 0)) { XmlSchemaObject parent = o; while (parent.Parent != null) { parent = parent.Parent; } if (parent is XmlSchema) { ns = ((XmlSchema)parent).TargetNamespace; } } if (o is XmlSchemaNotation) { return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, "notation", ((XmlSchemaNotation)o).Name, details })); } if (o is XmlSchemaGroup) { return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, "group", ((XmlSchemaGroup)o).Name, details })); } if (o is XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement)o; if ((element.Name == null) || (element.Name.Length == 0)) { XmlQualifiedName parentName = GetParentName(o); return(System.Web.Services.Res.GetString("XmlSchemaElementReference", new object[] { element.RefName.ToString(), parentName.Name, parentName.Namespace })); } return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, "element", element.Name, details })); } if (o is XmlSchemaType) { return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, (o.GetType() == typeof(XmlSchemaSimpleType)) ? "simpleType" : "complexType", ((XmlSchemaType)o).Name, details })); } if (o is XmlSchemaAttributeGroup) { return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, "attributeGroup", ((XmlSchemaAttributeGroup)o).Name, details })); } if (o is XmlSchemaAttribute) { XmlSchemaAttribute attribute = (XmlSchemaAttribute)o; if ((attribute.Name == null) || (attribute.Name.Length == 0)) { XmlQualifiedName name2 = GetParentName(o); return(System.Web.Services.Res.GetString("XmlSchemaAttributeReference", new object[] { attribute.RefName.ToString(), name2.Name, name2.Namespace })); } return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", new object[] { ns, "attribute", attribute.Name, details })); } if (o is XmlSchemaContent) { XmlQualifiedName name3 = GetParentName(o); return(System.Web.Services.Res.GetString("XmlSchemaContentDef", new object[] { name3.Name, name3.Namespace, details })); } if (o is XmlSchemaExternal) { string str2 = (o is XmlSchemaImport) ? "import" : ((o is XmlSchemaInclude) ? "include" : ((o is XmlSchemaRedefine) ? "redefine" : o.GetType().Name)); return(System.Web.Services.Res.GetString("XmlSchemaItem", new object[] { ns, str2, details })); } if (o is XmlSchema) { return(System.Web.Services.Res.GetString("XmlSchema", new object[] { ns, details })); } object[] args = new object[4]; args[0] = ns; args[1] = o.GetType().Name; args[3] = details; return(System.Web.Services.Res.GetString("XmlSchemaNamedItem", args)); } return(null); }
private void WriteFacets(XmlSchemaObjectCollection facets) { if (facets != null) { ArrayList list = new ArrayList(); for (int i = 0; i < facets.Count; i++) { list.Add(facets[i]); } list.Sort(new XmlFacetComparer()); for (int j = 0; j < list.Count; j++) { XmlSchemaObject obj2 = (XmlSchemaObject)list[j]; if (obj2 is XmlSchemaMinExclusiveFacet) { this.Write_XmlSchemaFacet("minExclusive", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaMaxInclusiveFacet) { this.Write_XmlSchemaFacet("maxInclusive", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaMaxExclusiveFacet) { this.Write_XmlSchemaFacet("maxExclusive", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaMinInclusiveFacet) { this.Write_XmlSchemaFacet("minInclusive", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaLengthFacet) { this.Write_XmlSchemaFacet("length", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaEnumerationFacet) { this.Write_XmlSchemaFacet("enumeration", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaMinLengthFacet) { this.Write_XmlSchemaFacet("minLength", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaPatternFacet) { this.Write_XmlSchemaFacet("pattern", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaTotalDigitsFacet) { this.Write_XmlSchemaFacet("totalDigits", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaMaxLengthFacet) { this.Write_XmlSchemaFacet("maxLength", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaWhiteSpaceFacet) { this.Write_XmlSchemaFacet("whiteSpace", (XmlSchemaFacet)obj2); } else if (obj2 is XmlSchemaFractionDigitsFacet) { this.Write_XmlSchemaFacet("fractionDigit", (XmlSchemaFacet)obj2); } } } }
private void GetColumns(XmlSchemaObject xmlSchemaObject, ColumnSchemaCollection columnSchemaCollection) { XmlSchemaComplexType baseType = FindBaseType(xmlSchemaObject); if (baseType != null) { GetColumns(baseType, columnSchemaCollection); } if (xmlSchemaObject is XmlSchemaComplexType) { XmlSchemaComplexType xmlSchemaComplexType = xmlSchemaObject as XmlSchemaComplexType; // Columns can be specified as attributes. foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes) { columnSchemaCollection.Add(new ColumnSchema(this.DataModelSchema, xmlSchemaAttribute)); } // The ComplexContent is mutually exclusive of the Particle. That is, if there is no particle defined for this comlex // type then it must have a comlex content description. Comlex content extends a base class. if (xmlSchemaComplexType.Particle == null) { // The Comlex Content describes an extension of a base class. It is mutually exclusive of the Particle which // describes a simple sequence of columns. if (xmlSchemaComplexType.ContentModel is XmlSchemaComplexContent) { // Strongly type the XmlSchemaContent. XmlSchemaComplexContent xmlSchemaComplexContent = xmlSchemaComplexType.ContentModel as XmlSchemaComplexContent; // A complex content can be derived by extension (adding columns) or restriction (removing columns). This // section will look for the extensions to the base class. if (xmlSchemaComplexContent.Content is XmlSchemaComplexContentExtension) { // The Complex Content Extension describes a base class and the additional columns that make up a derived // class. This section will recursively collect the columns from the base class and then parse out the // extra columns in-line. XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension = xmlSchemaComplexContent.Content as XmlSchemaComplexContentExtension; // The additional columns for this inherited table are found on the in-line in the <sequence> node that follows // the <extension> node. if (xmlSchemaComplexContentExtension.Particle is XmlSchemaSequence) { // Strongly type the XmlSchemaSequence XmlSchemaSequence xmlSchemaSequence = xmlSchemaComplexContentExtension.Particle as XmlSchemaSequence; // Read through the sequence and replace any column from an inherited class with the column in the // derived class. Also note that the columns are added in alphabetical order to give some amount of // predictability to the way the parameter lists are constructed when there are several layers of // inheritance. foreach (XmlSchemaObject item in xmlSchemaSequence.Items) { ColumnSchema columnSchema = new ColumnSchema(this.DataModelSchema, item); if (columnSchemaCollection.ContainsKey(columnSchema.QualifiedName)) { columnSchemaCollection.Remove(columnSchema.QualifiedName); } columnSchemaCollection.Add(columnSchema); } } // The Complex Content can also contain attributes that describe columns. foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexContentExtension.Attributes) { ColumnSchema columnSchema = new ColumnSchema(this.DataModelSchema, xmlSchemaAttribute); if (columnSchemaCollection.ContainsKey(columnSchema.QualifiedName)) { columnSchemaCollection.Remove(columnSchema.QualifiedName); } columnSchemaCollection.Add(columnSchema); } } } } else { // This section will parse the simple particle. The particle has no inheritiance to evaluate. if (xmlSchemaComplexType.Particle is XmlSchemaSequence) { // Strongly type the XmlSchemaSequence member. XmlSchemaSequence xmlSchemaSequence = xmlSchemaComplexType.Particle as XmlSchemaSequence; // Each XmlSchemaElement on the Particle describes a column. foreach (XmlSchemaObject item in xmlSchemaSequence.Items) { ColumnSchema columnSchema = new ColumnSchema(this.DataModelSchema, item); if (columnSchemaCollection.ContainsKey(columnSchema.QualifiedName)) { columnSchemaCollection.Remove(columnSchema.QualifiedName); } columnSchemaCollection.Add(columnSchema); } } // The ComplexType can also have attributes that describe table columns. foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes) { ColumnSchema columnSchema = new ColumnSchema(this.DataModelSchema, xmlSchemaAttribute); if (columnSchemaCollection.ContainsKey(columnSchema.QualifiedName)) { columnSchemaCollection.Remove(columnSchema.QualifiedName); } columnSchemaCollection.Add(columnSchema); } } } }
public XmlSchemaObjectLocation GetSelectedSchemaObjectLocation(string xml, int index) { XmlSchemaObject schemaObject = GetSelectedSchemaObject(xml, index); return(new XmlSchemaObjectLocation(schemaObject)); }
private void Read(XmlSchemaObject obj) { var xmlSchema = (XmlSchema)obj; Id = xmlSchema.Id; TargetNamespace = xmlSchema.TargetNamespace; Version = xmlSchema.Version; ElementFormDefault = xmlSchema.ElementFormDefault; foreach (var ns in xmlSchema.Namespaces.ToArray()) { Namespaces.Add(ns); } foreach (var import in xmlSchema.Includes.OfType <XmlSchemaImport>()) { Imports.Add(import); } var elements = xmlSchema.Items.OfType <XmlSchemaElement>().ToDictionary(element => element.SchemaTypeName); var types = new Dictionary <XmlQualifiedName, SDataSchemaType>(); var lists = new Dictionary <XmlQualifiedName, XmlSchemaComplexType>(); foreach (var item in xmlSchema.Items.OfType <XmlSchemaType>()) { SDataSchemaType type; var qualifiedName = new XmlQualifiedName(item.Name, TargetNamespace); if (item is XmlSchemaComplexType) { var xmlComplexType = (XmlSchemaComplexType)item; if (xmlComplexType.Particle == null || xmlComplexType.Particle is XmlSchemaAll) { XmlSchemaElement element; if (elements.TryGetValue(qualifiedName, out element)) { var roleAttr = element.UnhandledAttributes != null ? element.UnhandledAttributes.FirstOrDefault(attr => attr.NamespaceURI == SmeNamespaceUri && attr.LocalName == "role") : null; if (roleAttr == null) { throw new SDataClientException(string.Format("Role attribute on top level element '{0}' not found", element.Name)); } switch (roleAttr.Value) { case "resourceKind": type = new SDataSchemaResourceType(); break; case "serviceOperation": type = new SDataSchemaServiceOperationType(); break; case "query": type = new SDataSchemaNamedQueryType(); break; default: throw new SDataClientException(string.Format("Unexpected role attribute value '{0}' on top level element '{1}'", roleAttr.Value, element.Name)); } type.Read(element); elements.Remove(qualifiedName); } else { type = new SDataSchemaComplexType(); } } else if (xmlComplexType.Particle is XmlSchemaSequence) { var sequence = (XmlSchemaSequence)xmlComplexType.Particle; if (sequence.Items.Count != 1) { throw new SDataClientException(string.Format("Particle on list complex type '{0}' does not contain exactly one element", xmlComplexType.Name)); } var element = sequence.Items[0] as XmlSchemaElement; if (element == null) { throw new SDataClientException(string.Format("Unexpected sequence item type '{0}' on list complex type '{1}'", sequence.Items[0].GetType(), xmlComplexType.Name)); } SDataSchemaType complexType; if (types.TryGetValue(element.SchemaTypeName, out complexType)) { complexType.ListName = xmlComplexType.Name; complexType.ListItemName = element.Name; complexType.ListAnyAttribute = xmlComplexType.AnyAttribute; types.Remove(element.SchemaTypeName); } else { lists.Add(element.SchemaTypeName, xmlComplexType); } continue; } else if (xmlComplexType.Particle is XmlSchemaChoice) { type = new SDataSchemaChoiceType(); } else { throw new SDataClientException(string.Format("Unexpected particle type '{0}' on complex type '{1}'", xmlComplexType.Particle.GetType(), xmlComplexType.Name)); } } else if (item is XmlSchemaSimpleType) { var simpleType = (XmlSchemaSimpleType)item; if (simpleType.Content == null) { throw new SDataClientException(string.Format("Missing content on simple type '{0}'", simpleType.Name)); } var restriction = simpleType.Content as XmlSchemaSimpleTypeRestriction; if (restriction == null) { throw new SDataClientException(string.Format("Unexpected content type '{0}' on simple type '{1}'", simpleType.Content.GetType(), simpleType.Name)); } if (restriction.Facets.Cast <XmlSchemaObject>().All(facet => facet is XmlSchemaEnumerationFacet)) { type = new SDataSchemaEnumType(); } else { type = new SDataSchemaSimpleType(); } } else { throw new SDataClientException(string.Format("Unexpected item type '{0}'", item.GetType())); } XmlSchemaComplexType complexList; if (lists.TryGetValue(qualifiedName, out complexList)) { var sequence = (XmlSchemaSequence)complexList.Particle; var itemElement = (XmlSchemaElement)sequence.Items[0]; type.ListName = complexList.Name; type.ListItemName = itemElement.Name; type.ListAnyAttribute = complexList.AnyAttribute; lists.Remove(qualifiedName); } else { types.Add(qualifiedName, type); } type.Read(item); Types.Add(type); } Compile(); }
private void Write(XmlSchemaObject obj) { var xmlSchema = (XmlSchema)obj; xmlSchema.Id = Id; xmlSchema.TargetNamespace = TargetNamespace; xmlSchema.Version = Version; xmlSchema.ElementFormDefault = ElementFormDefault; var hasSme = false; var hasXs = false; var hasDefault = false; foreach (var ns in Namespaces) { xmlSchema.Namespaces.Add(ns.Name, ns.Namespace); hasSme |= ns.Namespace == SmeNamespaceUri; hasXs |= ns.Namespace == XmlSchema.Namespace; hasDefault |= ns.Namespace == TargetNamespace; } foreach (var import in Imports) { xmlSchema.Includes.Add(import); } if (!hasSme) { xmlSchema.Namespaces.Add("sme", SmeNamespaceUri); } if (!hasXs) { xmlSchema.Namespaces.Add("xs", XmlSchema.Namespace); } if (!hasDefault) { xmlSchema.Namespaces.Add(string.Empty, TargetNamespace); } foreach (var type in Types) { if (type is SDataSchemaComplexType || type is SDataSchemaChoiceType) { if (type is SDataSchemaTopLevelType) { var element = new XmlSchemaElement { SchemaTypeName = type.QualifiedName }; type.Write(element); xmlSchema.Items.Add(element); } var xmlComplexType = new XmlSchemaComplexType(); type.Write(xmlComplexType); xmlSchema.Items.Add(xmlComplexType); } else if (type is SDataSchemaValueType) { var xmlType = new XmlSchemaSimpleType(); type.Write(xmlType); xmlSchema.Items.Add(xmlType); } else { throw new SDataClientException(string.Format("Unexpected type '{0}'", type.GetType())); } if (type.ListName != null) { var xmlComplexType = new XmlSchemaComplexType { Name = type.ListName, AnyAttribute = type.ListAnyAttribute, Particle = new XmlSchemaSequence { Items = { new XmlSchemaElement { Name = type.ListItemName, SchemaTypeName = type.QualifiedName, MinOccurs = 0, MaxOccurs = decimal.MaxValue } } } }; xmlSchema.Items.Add(xmlComplexType); } } }
public void Remove(XmlSchemaObject item) { }
public XmlSchemaObjectCollection(XmlSchemaObject parent) { }
public void Insert(int index, XmlSchemaObject item) { }
public int IndexOf(XmlSchemaObject item) { }
public void CopyTo(XmlSchemaObject[] array, int index) { }
void Merge(IList originals, XmlSchema schema) { foreach (XmlSchema s in originals) { if (schema == s) { return; } } foreach (XmlSchemaExternal external in schema.Includes) { if (external is XmlSchemaImport) { external.SchemaLocation = null; if (external.Schema != null) { Merge(external.Schema); } else { AddImport(originals, ((XmlSchemaImport)external).Namespace); } } else { if (external.Schema == null) { // we do not process includes or redefines by the schemaLocation if (external.SchemaLocation != null) { throw new InvalidOperationException(Res.GetString(Res.XmlSchemaIncludeLocation, this.GetType().Name, external.SchemaLocation)); } } else { external.SchemaLocation = null; Merge(originals, external.Schema); } } } // bring all included items to the parent schema; bool[] matchedItems = new bool[schema.Items.Count]; int count = 0; for (int i = 0; i < schema.Items.Count; i++) { XmlSchemaObject o = schema.Items[i]; XmlSchemaObject dest = Find(o, originals); if (dest != null) { if (!Cache.Match(dest, o, shareTypes)) { Debug.WriteLineIf(DiagnosticsSwitches.XmlSerialization.TraceVerbose, "XmlSerialization::Failed to Merge " + MergeFailedMessage(o, dest, schema.TargetNamespace) + "' Plase Compare hash:\r\n" + Cache.looks[dest] + "\r\n" + Cache.looks[o]); throw new InvalidOperationException(MergeFailedMessage(o, dest, schema.TargetNamespace)); } matchedItems[i] = true; count++; } } if (count != schema.Items.Count) { XmlSchema destination = (XmlSchema)originals[0]; for (int i = 0; i < schema.Items.Count; i++) { if (!matchedItems[i]) { destination.Items.Add(schema.Items[i]); } } destination.IsPreprocessed = false; Preprocess(destination); } }
public void SetLineInfo(XmlSchemaObject obj) { obj.SourceUri = BaseURI; obj.LineNumber = LineNumber; obj.LinePosition = LinePosition; }
internal MappedTypeDesc(string clrType, string name, string ns, XmlSchemaType xsdType, XmlSchemaObject context, SchemaImporterExtension extension, CodeNamespace code, StringCollection references) { _clrType = clrType.Replace('+', '.'); _name = name; _ns = ns; _xsdType = xsdType; _context = context; _code = code; _references = references; _extension = extension; }
internal static XmlQualifiedName NameOf(XmlSchemaObject o) { if (o is XmlSchemaAttribute) { return(((XmlSchemaAttribute)o).QualifiedName); } else if (o is XmlSchemaAttributeGroup) { return(((XmlSchemaAttributeGroup)o).QualifiedName); } else if (o is XmlSchemaComplexType) { return(((XmlSchemaComplexType)o).QualifiedName); } else if (o is XmlSchemaSimpleType) { return(((XmlSchemaSimpleType)o).QualifiedName); } else if (o is XmlSchemaElement) { return(((XmlSchemaElement)o).QualifiedName); } else if (o is XmlSchemaGroup) { return(((XmlSchemaGroup)o).QualifiedName); } else if (o is XmlSchemaGroupRef) { return(((XmlSchemaGroupRef)o).RefName); } else if (o is XmlSchemaNotation) { return(((XmlSchemaNotation)o).QualifiedName); } else if (o is XmlSchemaSequence) { XmlSchemaSequence s = (XmlSchemaSequence)o; if (s.Items.Count == 0) { return(new XmlQualifiedName(".sequence", Namespace(o))); } return(NameOf(s.Items[0])); } else if (o is XmlSchemaAll) { XmlSchemaAll a = (XmlSchemaAll)o; if (a.Items.Count == 0) { return(new XmlQualifiedName(".all", Namespace(o))); } return(NameOf(a.Items)); } else if (o is XmlSchemaChoice) { XmlSchemaChoice c = (XmlSchemaChoice)o; if (c.Items.Count == 0) { return(new XmlQualifiedName(".choice", Namespace(o))); } return(NameOf(c.Items)); } else if (o is XmlSchemaAny) { return(new XmlQualifiedName("*", SchemaObjectWriter.ToString(((XmlSchemaAny)o).NamespaceList))); } else if (o is XmlSchemaIdentityConstraint) { return(((XmlSchemaIdentityConstraint)o).QualifiedName); } return(new XmlQualifiedName("?", Namespace(o))); }
public bool Contains(XmlSchemaObject item) { }
private void WriteFacets(XmlSchemaObjectCollection facets) { if (facets == null) { return; } ArrayList a = new ArrayList(); for (int i = 0; i < facets.Count; i++) { a.Add(facets[i]); } a.Sort(new XmlFacetComparer()); for (int ia = 0; ia < a.Count; ia++) { XmlSchemaObject ai = (XmlSchemaObject)a[ia]; if (ai is XmlSchemaMinExclusiveFacet) { Write_XmlSchemaFacet("minExclusive", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaMaxInclusiveFacet) { Write_XmlSchemaFacet("maxInclusive", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaMaxExclusiveFacet) { Write_XmlSchemaFacet("maxExclusive", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaMinInclusiveFacet) { Write_XmlSchemaFacet("minInclusive", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaLengthFacet) { Write_XmlSchemaFacet("length", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaEnumerationFacet) { Write_XmlSchemaFacet("enumeration", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaMinLengthFacet) { Write_XmlSchemaFacet("minLength", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaPatternFacet) { Write_XmlSchemaFacet("pattern", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaTotalDigitsFacet) { Write_XmlSchemaFacet("totalDigits", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaMaxLengthFacet) { Write_XmlSchemaFacet("maxLength", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaWhiteSpaceFacet) { Write_XmlSchemaFacet("whiteSpace", (XmlSchemaFacet)ai); } else if (ai is XmlSchemaFractionDigitsFacet) { Write_XmlSchemaFacet("fractionDigit", (XmlSchemaFacet)ai); } } }
private static string GetHelpKeyword(XmlSchemaSet schemaSet, string xmlNamespace, XmlSchemaObject xmlSchemaObject) { var xmlLastObject = xmlSchemaObject; var sb = new StringBuilder(); while (xmlSchemaObject != null && !(xmlSchemaObject is XmlSchema)) { xmlSchemaObject = ResolveLink(schemaSet, xmlSchemaObject); var name = GetName(xmlSchemaObject); if (name != null) { if (sb.Length > 0) { sb.Insert(0, "/"); } sb.Insert(0, name); } xmlLastObject = xmlSchemaObject; xmlSchemaObject = xmlSchemaObject.Parent; } if (xmlLastObject is XmlSchemaGroup) { sb.Insert(0, "#G/"); } else if (xmlLastObject is XmlSchemaAttributeGroup) { sb.Insert(0, "#AG/"); } else if (xmlLastObject is XmlSchemaSimpleType || xmlLastObject is XmlSchemaComplexType) { sb.Insert(0, "#T/"); } else { sb.Insert(0, "#E/"); } sb.Insert(0, xmlNamespace ?? String.Empty); return(sb.ToString()); }
// TODO - figure out how to get filename in here (xsd.SourceUri was null in my testing) public ParserException(XmlSchemaObject xsd, string message) : base($"line {xsd.LineNumber}: {message}") { LineNumber = xsd.LineNumber; LinePosition = xsd.LinePosition; }
private void PushNamedObject(XmlSchemaObject namedObject) { _namedObjectStack.Push(namedObject); }
public ParserException(XmlSchemaObject xsd, string message, Exception inner) : base($"line {xsd.LineNumber}: {message} - {inner.Message}", inner) { LineNumber = xsd.LineNumber; LinePosition = xsd.LinePosition; }
private void Write3_XmlSchemaObject(XmlSchemaObject o) { if (o != null) { Type type = o.GetType(); if (type == typeof(XmlSchemaComplexType)) { this.Write35_XmlSchemaComplexType((XmlSchemaComplexType)o); } else if (type == typeof(XmlSchemaSimpleType)) { this.Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o); } else if (type == typeof(XmlSchemaElement)) { this.Write46_XmlSchemaElement((XmlSchemaElement)o); } else if (type == typeof(XmlSchemaAppInfo)) { this.Write7_XmlSchemaAppInfo((XmlSchemaAppInfo)o); } else if (type == typeof(XmlSchemaDocumentation)) { this.Write6_XmlSchemaDocumentation((XmlSchemaDocumentation)o); } else if (type == typeof(XmlSchemaAnnotation)) { this.Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o); } else if (type == typeof(XmlSchemaGroup)) { this.Write57_XmlSchemaGroup((XmlSchemaGroup)o); } else if (type == typeof(XmlSchemaXPath)) { this.Write49_XmlSchemaXPath("xpath", "", (XmlSchemaXPath)o); } else if (type == typeof(XmlSchemaIdentityConstraint)) { this.Write48_XmlSchemaIdentityConstraint((XmlSchemaIdentityConstraint)o); } else if (type == typeof(XmlSchemaUnique)) { this.Write51_XmlSchemaUnique((XmlSchemaUnique)o); } else if (type == typeof(XmlSchemaKeyref)) { this.Write50_XmlSchemaKeyref((XmlSchemaKeyref)o); } else if (type == typeof(XmlSchemaKey)) { this.Write47_XmlSchemaKey((XmlSchemaKey)o); } else if (type == typeof(XmlSchemaGroupRef)) { this.Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o); } else if (type == typeof(XmlSchemaAny)) { this.Write53_XmlSchemaAny((XmlSchemaAny)o); } else if (type == typeof(XmlSchemaSequence)) { this.Write54_XmlSchemaSequence((XmlSchemaSequence)o); } else if (type == typeof(XmlSchemaChoice)) { this.Write52_XmlSchemaChoice((XmlSchemaChoice)o); } else if (type == typeof(XmlSchemaAll)) { this.Write43_XmlSchemaAll((XmlSchemaAll)o); } else if (type == typeof(XmlSchemaComplexContentRestriction)) { this.Write56_XmlSchemaComplexContentRestriction((XmlSchemaComplexContentRestriction)o); } else if (type == typeof(XmlSchemaComplexContentExtension)) { this.Write42_XmlSchemaComplexContentExtension((XmlSchemaComplexContentExtension)o); } else if (type == typeof(XmlSchemaSimpleContentRestriction)) { this.Write40_XmlSchemaSimpleContentRestriction((XmlSchemaSimpleContentRestriction)o); } else if (type == typeof(XmlSchemaSimpleContentExtension)) { this.Write38_XmlSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)o); } else if (type == typeof(XmlSchemaComplexContent)) { this.Write41_XmlSchemaComplexContent((XmlSchemaComplexContent)o); } else if (type == typeof(XmlSchemaSimpleContent)) { this.Write36_XmlSchemaSimpleContent((XmlSchemaSimpleContent)o); } else if (type == typeof(XmlSchemaAnyAttribute)) { this.Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o); } else if (type == typeof(XmlSchemaAttributeGroupRef)) { this.Write32_XmlSchemaAttributeGroupRef((XmlSchemaAttributeGroupRef)o); } else if (type == typeof(XmlSchemaAttributeGroup)) { this.Write31_XmlSchemaAttributeGroup((XmlSchemaAttributeGroup)o); } else if (type == typeof(XmlSchemaSimpleTypeRestriction)) { this.Write15_XmlSchemaSimpleTypeRestriction((XmlSchemaSimpleTypeRestriction)o); } else if (type == typeof(XmlSchemaSimpleTypeList)) { this.Write14_XmlSchemaSimpleTypeList((XmlSchemaSimpleTypeList)o); } else if (type == typeof(XmlSchemaSimpleTypeUnion)) { this.Write12_XmlSchemaSimpleTypeUnion((XmlSchemaSimpleTypeUnion)o); } else if (type == typeof(XmlSchemaAttribute)) { this.Write1_XmlSchemaAttribute((XmlSchemaAttribute)o); } } }
private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject) { XmlNode[] markup; XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated; if ((annotatedObject == null ? false : annotatedObject.Annotation != null)) { foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items) { XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation; markup = (doc == null ? ((XmlSchemaAppInfo)annot).Markup : doc.Markup); string text = string.Empty; XmlNode[] xmlNodeArrays = markup; for (int i = 0; i < (int)xmlNodeArrays.Length; i++) { XmlNode xn = xmlNodeArrays[i]; text = string.Concat(text, xn.InnerText); } if (text.Length > 0) { this.AppendMessage(annotations, "summary", text); } } } }
private string ToString(XmlSchemaObject o, SchemaObjectWriter writer) { return(writer.WriteXmlSchemaObject(o)); }
private void AppendCardinalityInformation(List <ClrAnnotation> annotations, ClrBasePropertyInfo basePropertyInfo, XmlSchemaObject schemaObject, bool isInChoice, bool isInNestedGroup) { ClrPropertyInfo propertyInfo = basePropertyInfo as ClrPropertyInfo; string text = string.Empty; text = string.Concat(text, "Occurrence: "); text = (!propertyInfo.IsOptional ? string.Concat(text, "required") : string.Concat(text, "optional")); if ((propertyInfo.IsStar ? true : propertyInfo.IsPlus)) { text = string.Concat(text, ", repeating"); } if (isInChoice) { text = string.Concat(text, ", choice"); } this.AppendMessage(annotations, "summary", text); if (isInNestedGroup) { this.AppendMessage(annotations, "summary", "Setter: Appends"); } if (propertyInfo.IsSubstitutionHead) { bool fComma = false; text = "Substitution members: "; foreach (XmlSchemaElement xse in propertyInfo.SubstitutionMembers) { if (fComma) { text = string.Concat(text, ", "); } else { fComma = true; } text = string.Concat(text, xse.Name); } this.AppendMessage(annotations, "summary", text); } }
private XmlSchemaObject GetTypeFromAncestors(XmlElement elementToValidate, XmlSchemaObject ancestorType, int ancestorsCount) { //schemaInfo is currentNode's schemaInfo _validator = CreateTypeFinderValidator(ancestorType); _schemaInfo = new XmlSchemaInfo(); //start at the ancestor to start validating int startIndex = ancestorsCount - 1; bool ancestorHasWildCard = AncestorTypeHasWildcard(ancestorType); for (int i = startIndex; i >= 0; i--) { XmlNode node = _nodeSequenceToValidate[i]; XmlElement currentElement = node as XmlElement; ValidateSingleElement(currentElement, false, _schemaInfo); if (!ancestorHasWildCard) { //store type if ancestor does not have wildcard in its content model currentElement.XmlName = _document.AddXmlName(currentElement.Prefix, currentElement.LocalName, currentElement.NamespaceURI, _schemaInfo); //update wildcard flag ancestorHasWildCard = AncestorTypeHasWildcard(_schemaInfo.SchemaElement); } _validator.ValidateEndOfAttributes(null); if (i > 0) { ValidateChildrenTillNextAncestor(node, _nodeSequenceToValidate[i - 1]); } else { //i == 0 ValidateChildrenTillNextAncestor(node, elementToValidate); } } Debug.Assert(_nodeSequenceToValidate[0] == elementToValidate.ParentNode); //validate element whose type is needed, ValidateSingleElement(elementToValidate, false, _schemaInfo); XmlSchemaObject schemaInfoFound = null; if (_schemaInfo.SchemaElement != null) { schemaInfoFound = _schemaInfo.SchemaElement; } else { schemaInfoFound = _schemaInfo.SchemaType; } if (schemaInfoFound == null) { //Detect if the node was validated lax or skip if (_validator.CurrentProcessContents == XmlSchemaContentProcessing.Skip) { if (_isPartialTreeValid) { //Then node assessed as skip; if there was error we turn processContents to skip as well. But this is not the same as validating as skip. return(XmlSchemaComplexType.AnyTypeSkip); } } else if (_validator.CurrentProcessContents == XmlSchemaContentProcessing.Lax) { return(XmlSchemaComplexType.AnyType); } } return(schemaInfoFound); }
private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject) { XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated; if (annotatedObject != null && annotatedObject.Annotation != null) { XmlNode[] markup; foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items) { XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation; if (doc != null) { markup = doc.Markup; } else { markup = ((XmlSchemaAppInfo)annot).Markup; } string text = String.Empty; foreach (XmlNode xn in markup) { text += xn.InnerText; } if (text.Length > 0) { AppendMessage(annotations, "summary", text); } } } }
internal object Find(XmlQualifiedName name, Type type, bool checkCache) { if (!IsCompiled) { foreach (XmlSchema schema in List) { Preprocess(schema); } } IList values = (IList)SchemaSet.Schemas(name.Namespace); if (values == null) { return(null); } foreach (XmlSchema schema in values) { Preprocess(schema); XmlSchemaObject ret = null; if (typeof(XmlSchemaType).IsAssignableFrom(type)) { ret = schema.SchemaTypes[name]; if (ret == null || !type.IsAssignableFrom(ret.GetType())) { continue; } } else if (type == typeof(XmlSchemaGroup)) { ret = schema.Groups[name]; } else if (type == typeof(XmlSchemaAttributeGroup)) { ret = schema.AttributeGroups[name]; } else if (type == typeof(XmlSchemaElement)) { ret = schema.Elements[name]; } else if (type == typeof(XmlSchemaAttribute)) { ret = schema.Attributes[name]; } else if (type == typeof(XmlSchemaNotation)) { ret = schema.Notations[name]; } #if DEBUG else { // use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe throw new InvalidOperationException(Res.GetString(Res.XmlInternalErrorDetails, "XmlSchemas.Find: Invalid object type " + type.FullName)); } #endif if (ret != null && shareTypes && checkCache && !IsReference(ret)) { ret = Cache.AddItem(ret, name, this); } if (ret != null) { return(ret); } } return(null); }
private void AppendCardinalityInformation(List <ClrAnnotation> annotations, ClrBasePropertyInfo basePropertyInfo, XmlSchemaObject schemaObject, bool isInChoice, bool isInNestedGroup) { ClrPropertyInfo propertyInfo = basePropertyInfo as ClrPropertyInfo; string text = String.Empty; text += "Occurrence: "; if (propertyInfo.IsOptional) { text += "optional"; } else { text += "required"; } if (propertyInfo.IsStar || propertyInfo.IsPlus) { text += ", repeating"; } if (isInChoice) { text += ", choice"; } // Append the occurrence message AppendMessage(annotations, "summary", text); if (isInNestedGroup) { AppendMessage(annotations, "summary", "Setter: Appends"); } if (propertyInfo.IsSubstitutionHead) { bool fComma = false; text = "Substitution members: "; foreach (XmlSchemaElement xse in propertyInfo.SubstitutionMembers) { if (!fComma) { fComma = true; } else { text += ", "; } text += xse.Name; } AppendMessage(annotations, "summary", text); } }
static string GetSchemaItem(XmlSchemaObject o, string ns, string details) { if (o == null) { return(null); } while (o.Parent != null && !(o.Parent is XmlSchema)) { o = o.Parent; } if (ns == null || ns.Length == 0) { XmlSchemaObject tmp = o; while (tmp.Parent != null) { tmp = tmp.Parent; } if (tmp is XmlSchema) { ns = ((XmlSchema)tmp).TargetNamespace; } } string item = null; if (o is XmlSchemaNotation) { item = Res.GetString(Res.XmlSchemaNamedItem, ns, "notation", ((XmlSchemaNotation)o).Name, details); } else if (o is XmlSchemaGroup) { item = Res.GetString(Res.XmlSchemaNamedItem, ns, "group", ((XmlSchemaGroup)o).Name, details); } else if (o is XmlSchemaElement) { XmlSchemaElement e = ((XmlSchemaElement)o); if (e.Name == null || e.Name.Length == 0) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Element reference '{0}' declared in schema type '{1}' from namespace '{2}' item = Res.GetString(Res.XmlSchemaElementReference, e.RefName.ToString(), parentName.Name, parentName.Namespace); } else { item = Res.GetString(Res.XmlSchemaNamedItem, ns, "element", e.Name, details); } } else if (o is XmlSchemaType) { item = Res.GetString(Res.XmlSchemaNamedItem, ns, o.GetType() == typeof(XmlSchemaSimpleType) ? "simpleType" : "complexType", ((XmlSchemaType)o).Name, null); } else if (o is XmlSchemaAttributeGroup) { item = Res.GetString(Res.XmlSchemaNamedItem, ns, "attributeGroup", ((XmlSchemaAttributeGroup)o).Name, details); } else if (o is XmlSchemaAttribute) { XmlSchemaAttribute a = ((XmlSchemaAttribute)o); if (a.Name == null || a.Name.Length == 0) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Attribure reference '{0}' declared in schema type '{1}' from namespace '{2}' return(Res.GetString(Res.XmlSchemaAttributeReference, a.RefName.ToString(), parentName.Name, parentName.Namespace)); } else { item = Res.GetString(Res.XmlSchemaNamedItem, ns, "attribute", a.Name, details); } } else if (o is XmlSchemaContent) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Check content definition of schema type '{0}' from namespace '{1}'. {2} item = Res.GetString(Res.XmlSchemaContentDef, parentName.Name, parentName.Namespace, null); } else if (o is XmlSchemaExternal) { string itemType = o is XmlSchemaImport ? "import" : o is XmlSchemaInclude ? "include" : o is XmlSchemaRedefine ? "redefine" : o.GetType().Name; item = Res.GetString(Res.XmlSchemaItem, ns, itemType, details); } else if (o is XmlSchema) { item = Res.GetString(Res.XmlSchema, ns, details); } else { item = Res.GetString(Res.XmlSchemaNamedItem, ns, o.GetType().Name, null, details); } return(item); }
private void BuildAnnotationInformation(ClrTypeInfo typeInfo, XmlSchemaObject schemaObject) { AppendXsdDocumentationInformation(typeInfo.Annotations, schemaObject); AppendRegExInformation(typeInfo); }
/// <include file='doc\SchemaImporterExtension.uex' path='docs/doc[@for="SchemaImporterExtension.ImportSchemaType1"]/*' /> public virtual string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return(null); }
private void BuildAnnotationInformation(ClrBasePropertyInfo propertyInfo, XmlSchemaObject schemaObject, bool isInChoice, bool isInNestedGroup) { AppendXsdDocumentationInformation(propertyInfo.Annotations, schemaObject); AppendCardinalityInformation(propertyInfo.Annotations, propertyInfo, schemaObject, isInChoice, isInNestedGroup); }
private static void ConvertObjectAnnotation(XmlSchemaObject schemaObj) { XmlSchemaAnnotated annObj = schemaObj as XmlSchemaAnnotated; if (annObj != null && annObj.Annotation != null) { XmlSchemaDocumentation comment = null; foreach (XmlSchemaObject annotation in annObj.Annotation.Items) { XmlSchemaAppInfo appInfo = annotation as XmlSchemaAppInfo; if (appInfo != null) { for (int i = 0; i < appInfo.Markup.Length; i++) { XmlNode markup = appInfo.Markup[i]; if (markup != null) { XmlAttribute typeAttrib = markup.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; if (typeAttrib != null) { if (typeAttrib.Value.Contains(":Annotation")) { string ns = typeAttrib.Value.Split(':')[0]; typeAttrib = markup.Attributes[ns, "http://www.w3.org/2000/xmlns/"]; if (typeAttrib != null && typeAttrib.Value == Annotation.AnnotationNamespace) { //This is an annotation created by us. Convert it to ws:documentation element and break comment = CreateDocumentationItem(markup.InnerText); appInfo.Markup[i] = null; break; } } else if (typeAttrib.Value.Contains(":EnumAnnotation")) { string ns = typeAttrib.Value.Split(':')[0]; typeAttrib = markup.Attributes[ns, "http://www.w3.org/2000/xmlns/"]; if (typeAttrib != null && typeAttrib.Value == Annotation.AnnotationNamespace) { DataContractSerializer serializer = new DataContractSerializer(typeof(EnumAnnotation)); using (XmlReader reader = new XmlNodeReader(markup)) { EnumAnnotation enumAnn = (EnumAnnotation)serializer.ReadObject(reader, false); if (enumAnn.EnumText != null) { //This is an annotation created by us. Convert it to ws:documentation element and break comment = CreateDocumentationItem(enumAnn.EnumText); } if (enumAnn.Members.Count > 0) { foreach (XmlSchemaEnumerationFacet enumObj in GetEnumItems(schemaObj)) { string docText; if (enumAnn.Members.TryGetValue(enumObj.Value, out docText)) { if (enumObj.Annotation == null) { enumObj.Annotation = new XmlSchemaAnnotation(); } enumObj.Annotation.Items.Add(CreateDocumentationItem(docText)); } } } appInfo.Markup[i] = null; break; } } } } } } } } if (comment != null) { annObj.Annotation.Items.Add(comment); } } foreach (XmlSchemaObject subObj in GetSubItems(schemaObj)) { ConvertObjectAnnotation(subObj); } }
public int Add(XmlSchemaObject item) { }