System.Xml.Schema.XmlSchemaDocumentation Class

Assembly: System.Xml.dll
Namespace: System.Xml.Schema
Summary
Class that specifies information to be read or used by humans within an annotation. Represents the World Wide Web Consortium (W3C) documentation element.
C# Syntax:
public class XmlSchemaDocumentation : XmlSchemaObject
Remarks
Information supplied within the XmlSchemaDocumentation class is not used in validation. However, it provides a standardized way to supply information that can be retrieved by tools.
Example
The following example creates the documentation element.
using System;
using System.Xml;  
using System.Xml.Schema;

class XMLSchemaExamples {
	public static void Main() {
 
		XmlSchema schema = new XmlSchema();
		
		// <xs:simpleType name="northwestStates">
		XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType();
		simpleType.Name = "northwestStates";
                schema.Items.Add(simpleType);
        	
		// <xs:annotation>
		XmlSchemaAnnotation annNorthwestStates = new XmlSchemaAnnotation();
		simpleType.Annotation = annNorthwestStates;
		
		// <xs:documentation>States in the Pacific Northwest of US</xs:documentation>
		XmlSchemaDocumentation docNorthwestStates = new XmlSchemaDocumentation();
		annNorthwestStates.Items.Add(docNorthwestStates);
		docNorthwestStates.Markup = TextToNodeArray("States in the Pacific Northwest of US");

		// <xs:restriction base="xs:string">
		XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
		simpleType.Content = restriction;
		restriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
		
		// <xs:enumeration value="WA">
		XmlSchemaEnumerationFacet enumerationWA = new XmlSchemaEnumerationFacet();
		restriction.Facets.Add(enumerationWA);
		enumerationWA.Value = "WA";
		
		// <xs:annotation>
		XmlSchemaAnnotation annWA = new XmlSchemaAnnotation();
		enumerationWA.Annotation = annWA;

		// <xs:documentation>Washington</documentation>
		XmlSchemaDocumentation docWA = new XmlSchemaDocumentation();
		annWA.Items.Add(docWA);
		docWA.Markup = TextToNodeArray("Washington");
		
		// <xs:enumeration value="OR">
		XmlSchemaEnumerationFacet enumerationOR = new XmlSchemaEnumerationFacet();
		restriction.Facets.Add(enumerationOR);
		enumerationOR.Value = "OR";
		
		// <xs:annotation>
		XmlSchemaAnnotation annOR = new XmlSchemaAnnotation();
		enumerationOR.Annotation = annOR;

		// <xs:documentation>Oregon</xs:documentation>
		XmlSchemaDocumentation docOR = new XmlSchemaDocumentation();
		annOR.Items.Add(docOR);
		docOR.Markup = TextToNodeArray("Oregon");

		// <xs:enumeration value="ID">
		XmlSchemaEnumerationFacet enumerationID = new XmlSchemaEnumerationFacet();
		restriction.Facets.Add(enumerationID);
		enumerationID.Value = "ID";
		
		// <xs:annotation>
		XmlSchemaAnnotation annID = new XmlSchemaAnnotation();
		enumerationID.Annotation = annID;

		// <xs:documentation>Idaho</xs:documentation>
		XmlSchemaDocumentation docID = new XmlSchemaDocumentation();
		annID.Items.Add(docID);
		docID.Markup = TextToNodeArray("Idaho");

        schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
 	XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        schema.Write(Console.Out, nsmgr);
	}

    public static void ValidationCallbackOne(object sender, ValidationEventArgs args) {
        Console.WriteLine(args.Message);
    }

	public static XmlNode[] TextToNodeArray(string text) {
		XmlDocument doc = new XmlDocument();
		return new XmlNode[1] {
                  doc.CreateTextNode(text)};
	}

}

    

The following XML file is generated for the preceding code example.

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:simpleType name="northwestStates">
		<xs:annotation>
			<xs:documentation>States in the Pacific Northwest of US</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
		  <xs:enumeration value="WA">
		    <xs:annotation>
		      <xs:documentation>Washington</xs:documentation>
		    </xs:annotation>
		  </xs:enumeration>
		  <xs:enumeration value="OR">
		    <xs:annotation>
		      <xs:documentation>Oregon</xs:documentation>
		    </xs:annotation>
		  </xs:enumeration>
		  <xs:enumeration value="ID">
		    <xs:annotation>
		      <xs:documentation>Idaho</xs:documentation>
		    </xs:annotation>
		  </xs:enumeration>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

    
See also:
System.Xml.Schema Namespace

System.Xml.Schema.XmlSchemaDocumentation Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Public Properties
Language Read-write

Gets or sets the xml:lang attribute. This serves as an indicator of the language used in the contents.
LineNumber
(inherited from System.Xml.Schema.XmlSchemaObject)
Read-write

See base class member description: System.Xml.Schema.XmlSchemaObject.LineNumber


Gets or sets the line number in the file to which the schema element refers.
LinePosition
(inherited from System.Xml.Schema.XmlSchemaObject)
Read-write

See base class member description: System.Xml.Schema.XmlSchemaObject.LinePosition


Gets or sets the line position in the file to which the schema element refers.
Markup Read-write

Gets or sets an array of XmlNodes that represents the documentation child nodes.
Namespaces
(inherited from System.Xml.Schema.XmlSchemaObject)
Read-write

See base class member description: System.Xml.Schema.XmlSchemaObject.Namespaces


Source Read-write

Gets or sets the URI source of the information.
SourceUri
(inherited from System.Xml.Schema.XmlSchemaObject)
Read-write

See base class member description: System.Xml.Schema.XmlSchemaObject.SourceUri


Gets or sets the source location for the file that loaded the schema.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Xml.Schema.XmlSchemaDocumentation Member Details

ctor #1
Summary:
Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public XmlSchemaDocumentation();

Return to top


Property: Language (read-write)
Summary
Gets or sets the xml:lang attribute. This serves as an indicator of the language used in the contents.
C# Syntax:
public string Language {get; set;}

Return to top


Property: LineNumber (read-write)
Inherited
See base class member description: System.Xml.Schema.XmlSchemaObject.LineNumber

Summary
Gets or sets the line number in the file to which the schema element refers.
C# Syntax:
public int LineNumber {get; set;}
Remarks
LineNumber is used to store the line number when a schema is read from a file. This is reported through XmlSchemaException for error handling.

Return to top


Property: LinePosition (read-write)
Inherited
See base class member description: System.Xml.Schema.XmlSchemaObject.LinePosition

Summary
Gets or sets the line position in the file to which the schema element refers.
C# Syntax:
public int LinePosition {get; set;}
Remarks
This is used to store the line position when a schema is read from a file. This is reported through XmlSchemaException for error handling.

Return to top


Property: Markup (read-write)
Summary
Gets or sets an array of XmlNodes that represents the documentation child nodes.
C# Syntax:
public XmlNode[] Markup {get; set;}

Return to top


Property: Namespaces (read-write)
Inherited
See base class member description: System.Xml.Schema.XmlSchemaObject.Namespaces

C# Syntax:
public XmlSerializerNamespaces Namespaces {get; set;}

Return to top


Property: Source (read-write)
Summary
Gets or sets the URI source of the information.
C# Syntax:
public string Source {get; set;}
Remarks
Source must be a URI reference.

Optional.

Return to top


Property: SourceUri (read-write)
Inherited
See base class member description: System.Xml.Schema.XmlSchemaObject.SourceUri

Summary
Gets or sets the source location for the file that loaded the schema.
C# Syntax:
public string SourceUri {get; set;}
Remarks
Provides information for exception handling.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~XmlSchemaDocumentation();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.