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 System.Xml.Schema.XmlSchemaSet to use.

public XmlSchemaSet SchemaSet { get; set; }

Property Value

XmlSchemaSet:

The System.Xml.Schema.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 System.Xml.Schema.XmlSchema to the existing SchemaSet.

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

The System.Xml.Schema.XmlSchema to load.

AddSchemaFromFile(string)

Adds another System.Xml.Schema.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 System.Xml.Schema.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 System.Xml.Schema.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 System.Xml.Schema.XmlSchemaElement that has the specified qualified name.

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

The parent System.Xml.Schema.XmlSchemaElement.

name XmlQualifiedName

The System.Xml.XmlQualifiedName for which to search.

Returns

XmlSchemaElement:

The child System.Xml.Schema.XmlSchemaElement that has the specified qualified name.

GetChildSchemaElements(XmlSchemaElement)

Returns the child System.Xml.Schema.XmlSchemaElement objects.

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

The parent System.Xml.Schema.XmlSchemaElement.

Returns

IEnumerable<XmlSchemaElement>:

The child System.Xml.Schema.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 System.Xml.Schema.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 System.Xml.Schema.XmlSchemaDocumentation child nodes together, with whitespace in between.

GetGlobalSchemaElement(XmlQualifiedName)

Returns the global System.Xml.Schema.XmlSchemaElement that has the specified qualified name.

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

The System.Xml.XmlQualifiedName for which to search.

Returns

XmlSchemaElement:

The global System.Xml.Schema.XmlSchemaElement that has the specified qualified name.

GetGlobalSchemaElements()

Returns the collection of global System.Xml.Schema.XmlSchemaElement objects.

public IEnumerable<XmlSchemaElement> GetGlobalSchemaElements()

Returns

IEnumerable<XmlSchemaElement>:

The collection of global System.Xml.Schema.XmlSchemaElement objects.

GetSchemaAttributes(XmlSchemaElement)

Returns the child System.Xml.Schema.XmlSchemaAttribute objects.

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

The parent System.Xml.Schema.XmlSchemaElement.

Returns

IEnumerable<XmlSchemaAttribute>:

The child System.Xml.Schema.XmlSchemaAttribute objects.

GetSchemaElementContentFacets(XmlSchemaElement)

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

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

The System.Xml.Schema.XmlSchemaElement to examine.

Returns

IEnumerable<XmlSchemaFacet>:

The System.Xml.Schema.XmlSchemaFacet objects that are allowed as content.

GetSchemaElementContentType(XmlSchemaElement)

Returns the System.Xml.Schema.XmlSchemaContentType for the specified System.Xml.Schema.XmlSchemaElement.

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

The System.Xml.Schema.XmlSchemaElement to examine.

Returns

XmlSchemaContentType:

The System.Xml.Schema.XmlSchemaContentType for the specified System.Xml.Schema.XmlSchemaElement.

LoadSchema(XmlSchema)

Clears any existing SchemaSet and loads a new single System.Xml.Schema.XmlSchema.

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

The System.Xml.Schema.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 System.Xml.Schema.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 System.Xml.Schema.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 System.Xml.Schema.XmlSchema from a string.

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

The XSD schema data.

ResolveSchemaAttribute(XmlSchemaAttribute)

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

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

The System.Xml.Schema.XmlSchemaAttribute to examine.

Returns

XmlSchemaAttribute:

The resolved System.Xml.Schema.XmlSchemaAttribute.

Inherited Members