XmlSchemaObject.Namespaces Property


Gets or sets the XmlSerializerNamespaces to use with this schema object.

Namespace:   System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)

member Namespaces : XmlSerializerNamespaces with get, set

Property Value

Type: System.Xml.Serialization.XmlSerializerNamespaces

The XmlSerializerNamespaces property for the schema object.

This gives the Schema Object Model (SOM) the ability to add xmlns declarations. This is useful when you want to declare a prefix to qualify declarations from an imported schema or use in the xpath attribute of the xs:selector element.

You can also use the Namespaces property to change namespace prefixes in a schema. For example, you can change the prefix used by a schema for the W3C XML Schema namespace from xs to xsd as illustrated in the following example.

No code example is currently available or this language may not be supported.

In the following example, the prefix myImpPrefix is added at the schema element level. The prefix is then used to qualify definitions that are imported from myImportNamespace.

No code example is currently available or this language may not be supported.

The example produces the following XML.

<?xml version="1.0" encoding="IBM437"?>
<schema xmlns:myImpPrefix="myImportNamespace" targetNamespace="myNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
  <import schemaLocation="http://www.microsoft.com/myImportNamespace" namespace="myImportNamespace" />
  <element name="element1" type="myImpPrefix:importType" />

.NET Framework
Available since 1.1
Return to top