internal void LoadTypeValues(XmlSchemaSimpleType node) { if ((node.Content is XmlSchemaSimpleTypeList) || (node.Content is XmlSchemaSimpleTypeUnion)) { throw ExceptionBuilder.SimpleTypeNotSupported(); } if (node.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction content = (XmlSchemaSimpleTypeRestriction)node.Content; XmlSchemaSimpleType baseXmlSchemaType = node.BaseXmlSchemaType as XmlSchemaSimpleType; if ((baseXmlSchemaType != null) && (baseXmlSchemaType.QualifiedName.Namespace != "http://www.w3.org/2001/XMLSchema")) { this.baseSimpleType = new SimpleType(node.BaseXmlSchemaType as XmlSchemaSimpleType); } if (content.BaseTypeName.Namespace == "http://www.w3.org/2001/XMLSchema") { this.baseType = content.BaseTypeName.Name; } else { this.baseType = content.BaseTypeName.ToString(); } if (((this.baseSimpleType != null) && (this.baseSimpleType.Name != null)) && (this.baseSimpleType.Name.Length > 0)) { this.xmlBaseType = this.baseSimpleType.XmlBaseType; } else { this.xmlBaseType = content.BaseTypeName; } if ((this.baseType == null) || (this.baseType.Length == 0)) { this.baseType = content.BaseType.Name; this.xmlBaseType = null; } if (this.baseType == "NOTATION") { this.baseType = "string"; } foreach (XmlSchemaFacet facet in content.Facets) { if (facet is XmlSchemaLengthFacet) { this.length = Convert.ToInt32(facet.Value, (IFormatProvider)null); } if (facet is XmlSchemaMinLengthFacet) { this.minLength = Convert.ToInt32(facet.Value, (IFormatProvider)null); } if (facet is XmlSchemaMaxLengthFacet) { this.maxLength = Convert.ToInt32(facet.Value, (IFormatProvider)null); } if (facet is XmlSchemaPatternFacet) { this.pattern = facet.Value; } if (facet is XmlSchemaEnumerationFacet) { this.enumeration = !ADP.IsEmpty(this.enumeration) ? (this.enumeration + " " + facet.Value) : facet.Value; } if (facet is XmlSchemaMinExclusiveFacet) { this.minExclusive = facet.Value; } if (facet is XmlSchemaMinInclusiveFacet) { this.minInclusive = facet.Value; } if (facet is XmlSchemaMaxExclusiveFacet) { this.maxExclusive = facet.Value; } if (facet is XmlSchemaMaxInclusiveFacet) { this.maxInclusive = facet.Value; } } } string msdataAttribute = XSDSchema.GetMsdataAttribute(node, "targetNamespace"); if (msdataAttribute != null) { this.ns = msdataAttribute; } }
internal void LoadTypeValues(XmlSchemaSimpleType node) { if ((node.Content is XmlSchemaSimpleTypeList) || (node.Content is XmlSchemaSimpleTypeUnion)) { throw ExceptionBuilder.SimpleTypeNotSupported(); } if (node.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction content = (XmlSchemaSimpleTypeRestriction)node.Content; XmlSchemaSimpleType?ancestor = node.BaseXmlSchemaType as XmlSchemaSimpleType; if ((ancestor != null) && (ancestor.QualifiedName.Namespace != Keywords.XSDNS)) { _baseSimpleType = new SimpleType(ancestor); } // do we need to put qualified name? // for user defined simpletype, always go with qname if (content.BaseTypeName.Namespace == Keywords.XSDNS) { _baseType = content.BaseTypeName.Name; } else { _baseType = content.BaseTypeName.ToString(); } if (_baseSimpleType != null && _baseSimpleType.Name != null && _baseSimpleType.Name.Length > 0) { _xmlBaseType = _baseSimpleType.XmlBaseType; // SimpleTypeQualifiedName; } else { _xmlBaseType = content.BaseTypeName; } if (_baseType == null || _baseType.Length == 0) { _baseType = content.BaseType !.Name; _xmlBaseType = null; } if (_baseType == "NOTATION") { _baseType = "string"; } foreach (XmlSchemaFacet facet in content.Facets) { if (facet is XmlSchemaLengthFacet) { _length = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaMinLengthFacet) { _minLength = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaMaxLengthFacet) { _maxLength = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaPatternFacet) { _pattern = facet.Value; } if (facet is XmlSchemaEnumerationFacet) { _enumeration = !string.IsNullOrEmpty(_enumeration) ? _enumeration + " " + facet.Value : facet.Value; } if (facet is XmlSchemaMinExclusiveFacet) { _minExclusive = facet.Value; } if (facet is XmlSchemaMinInclusiveFacet) { _minInclusive = facet.Value; } if (facet is XmlSchemaMaxExclusiveFacet) { _maxExclusive = facet.Value; } if (facet is XmlSchemaMaxInclusiveFacet) { _maxInclusive = facet.Value; } } } string tempStr = XSDSchema.GetMsdataAttribute(node, Keywords.TARGETNAMESPACE); if (tempStr != null) { _ns = tempStr; } }
internal void LoadTypeValues(XmlSchemaSimpleType node) { if ((node.Content is XmlSchemaSimpleTypeList) || (node.Content is XmlSchemaSimpleTypeUnion)) { throw ExceptionBuilder.SimpleTypeNotSupported(); } if (node.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction content = (XmlSchemaSimpleTypeRestriction)node.Content; XmlSchemaSimpleType ancestor = node.BaseXmlSchemaType as XmlSchemaSimpleType; if ((ancestor != null) && (ancestor.QualifiedName.Namespace != Keywords.XSDNS)) // I'm assuming that built-in types don't have a name! // Console.WriteLine("In simpleNode, ancestor.Name = '{0}'", ancestor.Name); { baseSimpleType = new SimpleType(node.BaseXmlSchemaType as XmlSchemaSimpleType); // baseSimpleType = new SimpleType(node); } // do we need to put qualified name? // for user defined simpletype, always go with qname if (content.BaseTypeName.Namespace == Keywords.XSDNS) { baseType = content.BaseTypeName.Name; } else { baseType = content.BaseTypeName.ToString(); } if (baseSimpleType != null && baseSimpleType.Name != null && baseSimpleType.Name.Length > 0) { xmlBaseType = baseSimpleType.XmlBaseType;// SimpleTypeQualifiedName; } else { xmlBaseType = content.BaseTypeName; } if (baseType == null || baseType.Length == 0) { // Console.WriteLine("baseType == null, setting it to ", content.BaseType.Name); baseType = content.BaseType.Name; xmlBaseType = null; } if (baseType == "NOTATION") { baseType = "string"; } foreach (XmlSchemaFacet facet in content.Facets) { if (facet is XmlSchemaLengthFacet) { length = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaMinLengthFacet) { minLength = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaMaxLengthFacet) { maxLength = Convert.ToInt32(facet.Value, null); } if (facet is XmlSchemaPatternFacet) { pattern = facet.Value; } if (facet is XmlSchemaEnumerationFacet) { enumeration = !Common.ADP.IsEmpty(enumeration) ? enumeration + " " + facet.Value : facet.Value; } if (facet is XmlSchemaMinExclusiveFacet) { minExclusive = facet.Value; } if (facet is XmlSchemaMinInclusiveFacet) { minInclusive = facet.Value; } if (facet is XmlSchemaMaxExclusiveFacet) { maxExclusive = facet.Value; } if (facet is XmlSchemaMaxInclusiveFacet) { maxInclusive = facet.Value; } } } string tempStr = XSDSchema.GetMsdataAttribute(node, Keywords.TARGETNAMESPACE); if (tempStr != null) { ns = tempStr; } }