本文整理汇总了C#中System.Xml.Schema.XmlSchemaSimpleType类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaSimpleType类的具体用法?C# XmlSchemaSimpleType怎么用?C# XmlSchemaSimpleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaSimpleType类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaSimpleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSchema
public XmlSchemaElement GetSchema()
{
var type = new XmlSchemaComplexType();
type.Attributes.Add(new XmlSchemaAttribute
{
Name = "refValue",
Use = XmlSchemaUse.Required,
SchemaTypeName =
new XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema")
});
type.Attributes.Add(new XmlSchemaAttribute
{
Name = "test",
Use = XmlSchemaUse.Optional,
SchemaTypeName =
new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
});
var restriction = new XmlSchemaSimpleTypeRestriction
{
BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
};
restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "years"});
restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "weeks"});
restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "days"});
var simpleType = new XmlSchemaSimpleType {Content = restriction};
type.Attributes.Add(new XmlSchemaAttribute
{
Name = "units",
Use = XmlSchemaUse.Required,
SchemaType = simpleType
});
type.Attributes.Add(new XmlSchemaAttribute
{
Name = "expressionLanguage",
Use = XmlSchemaUse.Optional,
SchemaTypeName =
new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
});
var element = new XmlSchemaElement
{
Name = "dicom-age-less-than",
SchemaType = type
};
return element;
}
示例2: CreateSimpletypeLength
private void CreateSimpletypeLength(string length, string minLength, string maxLength, bool expected) {
passed = true;
XmlSchema schema = new XmlSchema();
XmlSchemaSimpleType testType = new XmlSchemaSimpleType();
testType.Name = "TestType";
XmlSchemaSimpleTypeRestriction testTypeRestriction = new XmlSchemaSimpleTypeRestriction();
testTypeRestriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
if (length != "-") {
XmlSchemaLengthFacet _length = new XmlSchemaLengthFacet();
_length.Value = length;
testTypeRestriction.Facets.Add(_length);
}
if (minLength != "-") {
XmlSchemaMinLengthFacet _minLength = new XmlSchemaMinLengthFacet();
_minLength.Value = minLength;
testTypeRestriction.Facets.Add(_minLength);
}
if (maxLength != "-") {
XmlSchemaMaxLengthFacet _maxLength = new XmlSchemaMaxLengthFacet();
_maxLength.Value = maxLength;
testTypeRestriction.Facets.Add(_maxLength);
}
testType.Content = testTypeRestriction;
schema.Items.Add(testType);
schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
Assert.IsTrue (expected == passed, (passed ? "Test passed, should have failed" : "Test failed, should have passed") + ": " + length + " " + minLength + " " + maxLength);
}
示例3: Visit
protected override void Visit(XmlSchemaSimpleType type)
{
if (type.QualifiedName.IsEmpty)
Traverse(type.Content);
else
AddLeaf(SimpleTypeStructureNodeType.NamedType, type);
}
示例4: Type
/// <summary>
/// Create an XmlQueryType from an Xsd simple type (where variety can be Atomic, List, or Union).
/// </summary>
/// <param name="schemaType">the simple Xsd schema type of the atomic value</param>
/// <param name="isStrict">true if the dynamic type is guaranteed to match the static type exactly</param>
/// <returns>the atomic value type</returns>
public static XmlQueryType Type(XmlSchemaSimpleType schemaType, bool isStrict) {
if (schemaType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) {
// We must special-case xs:anySimpleType because it is broken in Xsd and is sometimes treated as
// an atomic value and sometimes as a list value. In XQuery, it always maps to xdt:anyAtomicType*.
if (schemaType == DatatypeImplementation.AnySimpleType)
return AnyAtomicTypeS;
return ItemType.Create(schemaType, isStrict);
}
// Skip restrictions. It is safe to do that because this is a list or union, so it's not a build in type
while (schemaType.DerivedBy == XmlSchemaDerivationMethod.Restriction)
schemaType = (XmlSchemaSimpleType) schemaType.BaseXmlSchemaType;
// Convert Xsd list
if (schemaType.DerivedBy == XmlSchemaDerivationMethod.List)
return PrimeProduct(Type(((XmlSchemaSimpleTypeList) schemaType.Content).BaseItemType, isStrict), XmlQueryCardinality.ZeroOrMore);
// Convert Xsd union
Debug.Assert(schemaType.DerivedBy == XmlSchemaDerivationMethod.Union);
XmlSchemaSimpleType[] baseMemberTypes = ((XmlSchemaSimpleTypeUnion) schemaType.Content).BaseMemberTypes;
XmlQueryType[] queryMemberTypes = new XmlQueryType[baseMemberTypes.Length];
for (int i = 0; i < baseMemberTypes.Length; i++)
queryMemberTypes[i] = Type(baseMemberTypes[i], isStrict);
return Choice(queryMemberTypes);
}
示例5: CreateGuidType
private XmlSchemaSimpleType CreateGuidType()
{
var type = new XmlSchemaSimpleType { Name = "Guid" };
var restriction = new XmlSchemaSimpleTypeRestriction { BaseType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String) };
restriction.Facets.Add(new XmlSchemaPatternFacet
{
Value =
@"[{(]?[0-9A-Fa-f]{8}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{12}[})]?|([!$])(\(var|\(loc|\(wix)\.[_A-Za-z][0-9A-Za-z_.]*\)"
});
type.Content = restriction;
return type;
}
示例6: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
schemas.Add(SchemaCompletion);
XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
schemas.Add(xsdSchemaCompletionData);
string xml = GetSchema();
int index = xml.IndexOf("type=\"dir\"/>");
index = xml.IndexOf("dir", index);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaSimpleType = (XmlSchemaSimpleType)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
示例7: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(SchemaCompletionData);
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
schemas.Add(xsdSchemaCompletionData);
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty);
string xml = GetSchema();
int index = xml.IndexOf("type=\"dir\"/>");
index = xml.IndexOf("dir", index);
schemaSimpleType = (XmlSchemaSimpleType)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
}
示例8: Visit
protected override void Visit(XmlSchemaSimpleType type)
{
if (type.QualifiedName.IsEmpty)
base.Visit(type);
else
{
if (!AddUsage(type))
return;
PushNamedObject(type);
base.Visit(type);
PopNamedObject();
}
}
示例9: ResolveType
public static XmlSchemaSimpleType ResolveType(this XmlSchemaSet schemaSet, XmlSchemaSimpleType type, XmlQualifiedName typeName)
{
if (type != null)
return type;
var resolvedType = schemaSet.GlobalTypes[typeName] as XmlSchemaSimpleType;
if (resolvedType != null)
return resolvedType;
var builtInSimpleType = XmlSchemaType.GetBuiltInSimpleType(typeName);
if (builtInSimpleType != null)
return builtInSimpleType;
return null;
}
示例10: GetDataTypeSource
private TypeDesc GetDataTypeSource(XmlSchemaSimpleType dataType)
{
if ((dataType.Name != null) && (dataType.Name.Length != 0))
{
TypeDesc typeDesc = base.Scope.GetTypeDesc(dataType);
if (typeDesc != null)
{
return typeDesc;
}
}
if (!dataType.DerivedFrom.IsEmpty)
{
return this.GetDataTypeSource(this.FindDataType(dataType.DerivedFrom));
}
return base.Scope.GetTypeDesc(typeof(string));
}
示例11: SimpleType
internal SimpleType(XmlSchemaSimpleType node)
{
this.name = "";
this.length = -1;
this.minLength = -1;
this.maxLength = -1;
this.pattern = "";
this.ns = "";
this.maxExclusive = "";
this.maxInclusive = "";
this.minExclusive = "";
this.minInclusive = "";
this.enumeration = "";
this.name = node.Name;
this.ns = (node.QualifiedName != null) ? node.QualifiedName.Namespace : "";
this.LoadTypeValues(node);
}
示例12: AddNonXsdPrimitive
private static void AddNonXsdPrimitive(Type type, string dataTypeName, string ns, string formatterName, XmlQualifiedName baseTypeName, XmlSchemaFacet[] facets, TypeFlags flags)
{
XmlSchemaSimpleType dataType = new XmlSchemaSimpleType {
Name = dataTypeName
};
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
BaseTypeName = baseTypeName
};
foreach (XmlSchemaFacet facet in facets)
{
restriction.Facets.Add(facet);
}
dataType.Content = restriction;
TypeDesc desc = new TypeDesc(type, false, dataType, formatterName, flags);
if (primitiveTypes[type] == null)
{
primitiveTypes.Add(type, desc);
}
primitiveDataTypes.Add(dataType, desc);
primitiveNames.Add(dataTypeName, ns, desc);
}
示例13: CreateProtoSimpleType
string CreateProtoSimpleType(XmlSchemaSimpleType simpleType) {
if (simpleType.QualifiedName.Namespace == XmlSchema.Namespace) {
return CreateProtoXsdType(simpleType.QualifiedName.Name);
} else if ((simpleType.Content as XmlSchemaSimpleTypeRestriction) != null) {
var facets = (simpleType.Content as XmlSchemaSimpleTypeRestriction).Facets.OfType<XmlSchemaFacet>();
foreach (var facet in facets) {
if ((facet as XmlSchemaEnumerationFacet) != null) {
return (facet as XmlSchemaEnumerationFacet).Value;
} else if ((facet as XmlSchemaMinInclusiveFacet) != null) {
return (facet as XmlSchemaMinInclusiveFacet).Value;
} else if ((facet as XmlSchemaMaxLengthFacet) != null) {
return (facet as XmlSchemaMaxLengthFacet).Value;
}
}
throw new Exception("not implemented");
} else if ((simpleType.Content as XmlSchemaSimpleTypeUnion) != null) {
return CreateProtoSimpleType((simpleType.Content as XmlSchemaSimpleTypeUnion).BaseMemberTypes.First());
} else {
throw new Exception("not implemented");
}
}
示例14: GetSimpleType
/// <summary>
/// Returns a SimpleType restricted by the datatype only
/// </summary>
public override XmlSchemaSimpleType GetSimpleType(string attributeDataType)
{
var retVal = new XmlSchemaSimpleType();
// <xs:restriction base="<whatever xs:datatype is required>" />
var dataTypeRestriction = new XmlSchemaSimpleTypeRestriction
{
BaseTypeName = new XmlQualifiedName(attributeDataType)
};
retVal.Content = dataTypeRestriction;
// if the property type is an enum then add an enumeration facet to the simple type
if (Property.PropertyType.IsEnum)
{
// <xs:enumeration value="123" />
foreach (var enumValue in Enum.GetNames(Property.PropertyType))
{
var enumFacet = new XmlSchemaEnumerationFacet { Value = enumValue };
dataTypeRestriction.Facets.Add(enumFacet);
}
}
return retVal;
}
示例15: SetAttributeType
internal void SetAttributeType(XmlSchemaSimpleType value) {
attributeType = value;
}