In This Article

XmlSchemaResolver Class

Provides a class that can manage XML schema data.

public class XmlSchemaResolver : IXmlSchemaResolver
Inheritance:
Object Object
Implements:
IXmlSchemaResolver

Remarks

Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(Object, Object) method. Once an instance is registered with the language for the IXmlSchemaResolver interface type, its features can be used by the language.

Constructors

XmlSchemaResolver()

Initializes a new instance of the XmlSchemaResolver class.

public XmlSchemaResolver()

Properties

DefaultNamespace

Gets or sets the default XML namespace to use.

public string DefaultNamespace { get; set; }

Property Value

String:

The default XML namespace to use.

Remarks

The default namespace is used to mimic an xmlns attribute setting on the root element, if no xmlns attribute is present. It sets an empty-string-keyed value into the DefaultNamespacePrefixMappings dictionary.

DefaultNamespacePrefixMappings

Gets the mapping dictionary of namespace prefix to namespaces that are declared by default without the need for xmlns attributes in elements.

public IDictionary<string, string> DefaultNamespacePrefixMappings { get; }

Property Value

IDictionary<String, String>:

The mapping dictionary of namespace prefix to namespaces that are declared by default without the need for xmlns attributes in elements.

Remarks

The dictionary keys are namespace prefixes and the values are namespaces. The namespace declarations in this dictionary are used to mimic xmlns attribute settings on the root element when no xmlns declaration attributes for the specified namespace prefix keys are present.

The DefaultNamespace property is simply a wrapper for setting an empty-string-keyed value in this dictionary.

SchemaSet

Gets or sets the XmlSchemaSet to use.

public XmlSchemaSet SchemaSet { get; set; }

Property Value

XmlSchemaSet:

The XmlSchemaSet to use.

Remarks

This property can be set if you already have a XmlSchemaSet loaded that should directly be used.

Methods

AddSchema(XmlSchema)

Adds another XmlSchema to the existing SchemaSet.

public void AddSchema(XmlSchema schema)
Parameter Type Description
schema XmlSchema

The XmlSchema to load.

AddSchemaFromFile(String)

Adds another XmlSchema from a file to the existing SchemaSet.

public void AddSchemaFromFile(string path)
Parameter Type Description
path String

The path to the XSD schema file to load.

AddSchemaFromStream(Stream)

Adds another XmlSchema from a Stream to the existing SchemaSet.

public void AddSchemaFromStream(Stream stream)
Parameter Type Description
stream Stream

The Stream from which to load.

AddSchemaFromString(String)

Adds another XmlSchema from a string to the existing SchemaSet.

public void AddSchemaFromString(string schemaData)
Parameter Type Description
schemaData String

The XSD schema data.

GetChildSchemaElement(XmlSchemaElement, XmlQualifiedName)

Returns the child XmlSchemaElement that has the specified qualified name.

public XmlSchemaElement GetChildSchemaElement(XmlSchemaElement parentElement, XmlQualifiedName name)
Parameter Type Description
parentElement XmlSchemaElement

The parent XmlSchemaElement.

name XmlQualifiedName

The XmlQualifiedName for which to search.

Returns

XmlSchemaElement:

The child XmlSchemaElement that has the specified qualified name.

GetChildSchemaElements(XmlSchemaElement)

Returns the child XmlSchemaElement objects.

public IEnumerable<XmlSchemaElement> GetChildSchemaElements(XmlSchemaElement parentElement)
Parameter Type Description
parentElement XmlSchemaElement

The parent XmlSchemaElement.

Returns

IEnumerable<XmlSchemaElement>:

The child XmlSchemaElement objects.

GetDocumentation(XmlSchemaAnnotated)

Returns the XSD documentation for the specified source object.

public virtual string GetDocumentation(XmlSchemaAnnotated source)
Parameter Type Description
source XmlSchemaAnnotated

The source XmlSchemaAnnotated for which the documentation is being retrieved.

Returns

String:

The documentation that was retrieved.

Remarks

The default implementation of this method appends the inner text of all the XmlSchemaDocumentation child nodes together, with whitespace in between.

GetGlobalSchemaElement(XmlQualifiedName)

Returns the global XmlSchemaElement that has the specified qualified name.

public XmlSchemaElement GetGlobalSchemaElement(XmlQualifiedName name)
Parameter Type Description
name XmlQualifiedName

The XmlQualifiedName for which to search.

Returns

XmlSchemaElement:

The global XmlSchemaElement that has the specified qualified name.

GetGlobalSchemaElements()

Returns the collection of global XmlSchemaElement objects.

public IEnumerable<XmlSchemaElement> GetGlobalSchemaElements()

Returns

IEnumerable<XmlSchemaElement>:

The collection of global XmlSchemaElement objects.

GetSchemaAttributes(XmlSchemaElement)

Returns the child XmlSchemaAttribute objects.

public IEnumerable<XmlSchemaAttribute> GetSchemaAttributes(XmlSchemaElement parentElement)
Parameter Type Description
parentElement XmlSchemaElement

The parent XmlSchemaElement.

Returns

IEnumerable<XmlSchemaAttribute>:

The child XmlSchemaAttribute objects.

GetSchemaElementContentFacets(XmlSchemaElement)

Returns the XmlSchemaFacet objects that are allowed as content of the specified XmlSchemaElement.

public static IEnumerable<XmlSchemaFacet> GetSchemaElementContentFacets(XmlSchemaElement element)
Parameter Type Description
element XmlSchemaElement

The XmlSchemaElement to examine.

Returns

IEnumerable<XmlSchemaFacet>:

The XmlSchemaFacet objects that are allowed as content.

GetSchemaElementContentType(XmlSchemaElement)

Returns the XmlSchemaContentType for the specified XmlSchemaElement.

public static XmlSchemaContentType GetSchemaElementContentType(XmlSchemaElement element)
Parameter Type Description
element XmlSchemaElement

The XmlSchemaElement to examine.

Returns

XmlSchemaContentType:

The XmlSchemaContentType for the specified XmlSchemaElement.

LoadSchema(XmlSchema)

Clears any existing SchemaSet and loads a new single XmlSchema.

public void LoadSchema(XmlSchema schema)
Parameter Type Description
schema XmlSchema

The XmlSchema to load.

Remarks

This method first clears any schemas currently in use and then loads a single specified schema.

LoadSchemaFromFile(String)

Clears any existing SchemaSet and loads a new single XmlSchema from a file.

public void LoadSchemaFromFile(string path)
Parameter Type Description
path String

The path to the XSD schema file to load.

Remarks

This method first clears any schemas currently in use and then loads a single specified schema.

LoadSchemaFromStream(Stream)

Clears any existing SchemaSet and loads a new single XmlSchema from a Stream.

public void LoadSchemaFromStream(Stream stream)
Parameter Type Description
stream Stream

The Stream from which to load.

Remarks

This method first clears any schemas currently in use and then loads a single specified schema.

LoadSchemaFromString(String)

Clears any existing SchemaSet and loads a new single XmlSchema from a string.

public void LoadSchemaFromString(string schemaData)
Parameter Type Description
schemaData String

The XSD schema data.

ResolveSchemaAttribute(XmlSchemaAttribute)

Resolves the specified XmlSchemaAttribute in the event it is a reference to another XmlSchemaAttribute.

public XmlSchemaAttribute ResolveSchemaAttribute(XmlSchemaAttribute attribute)
Parameter Type Description
attribute XmlSchemaAttribute

The XmlSchemaAttribute to examine.

Returns

XmlSchemaAttribute:

The resolved XmlSchemaAttribute.

Inherited Members