- 
                Notifications
    You must be signed in to change notification settings 
- Fork 259
DomNodes and DOM Metadata Classes
The fundamental DomNode class represents an individual tree node containing application data, and related classes like DomNodeType describe node metadata.
Note that all application data is contained in DomNodes. This means that much of the application's data handling can be done by working with DomNodes.
DomNodeType represents the type associated with a DomNode, and every DomNode has a DomNodeType associated with it.
The DomNode and DomNodeType classes provide basic functionality for managing the tree and nodes within that tree, including event management, unique node naming, reference tracking, transactions, and synchronization with underlying documents that store application data persistently. DomNodeType serves as a repository of information about the node type, such as palette or property information associated with it.
Each DomNode object represents one node in a tree, one piece of data. The term node is also used for a DomNode.
Because a DomNode represents application data, you can create new application data by creating a DomNode. In its constructor, you specify a DomNode's type as a DomNodeType object. For more information, see DomNodeType Class.
You can use a DomXmlReader object to create a tree of DomNodes with the appropriate types from XML data, so your application doesn't need to construct all the DomNodes itself. For details on writing and reading DomNodes to and from storage, see DOM Persistence.
A child of a DomNode can be a single DomNode or a list of DomNodes, that is, IList<DomNode>, and a DomNode can have multiple children of both kinds. Each child DomNode is described by a ChildInfo object, which is metadata about a child of a DomNode, such as its name and DomNodeType. For more information on ChildInfo, see DomNodeType and Other Metadata Classes.
ChildInfo has the attribute IsList indicating whether that child is in a list or not. Children that are in a list and that have the same ChildInfo are all in the same list that is a child of the DomNode. Thus, if a child that is a list of DomNodes with a given ChildInfo already exists, you add a new node with that kind of ChildInfo to that list, just as for any collection.
Because DomNodes are tree nodes, the DomNode class has properties and methods to allow you to manipulate a tree, such as these:
- 
DomNode Parent: Get the parentDomNode, ornullif the node is a root.
- 
DomNode GetRoot(): Get the rootDomNodeof thisDomNode's subtree.
- 
IEnumerable<DomNode> Children: Get an enumeration of this node's children.
- 
SetChild(ChildInfo childInfo, DomNode child): Set the child corresponding to the child metadataChildInfowhen the child is not in a list.
- 
DomNode GetChild(ChildInfo childInfo): Get the child corresponding to the given child metadataChildInfowhen the child is not in a list.
- 
RemoveFromParent(): Remove theDomNodefrom its parent. TheDomNodeas a child of its parent can be in a list or not.
- 
DomNode GetLowestCommonAncestor(DomNode node1, DomNode node2): Get the lowest common ancestor (LCA) of a pair of DOM nodes. The LCA is the common ancestor of the two nodes that is furthest from the root node.
- 
Copy(): Several methods with different parameters to make deep copies ofDomNodetrees.
DomNodes to keep in sync with the changes. For example, if new data is added, you can add DomNodes at appropriate places in the tree.
DomNode also defines a set of events indicating tree changes. These events are raised if the DomNode or any DomNode of its subtree changes:
- 
AttributeChanging: Raised before an attribute is changed to a new value.
- 
AttributeChanged: Raised after an attribute is changed to a new value.
- 
ChildInserting: Raised before a child is inserted into a child list or added as a child to a node.
- 
ChildInserted: Raised after a child is inserted into a child list or added as a child to a node.
- 
ChildRemoving: Raised before a child is removed from a child list or removed as a child from a node.
- 
ChildRemoved: Raised after a child is removed from a child list or removed as a child from a node.
AttributeEventArgs and ChildEventArgs classes to provide event information.
Note that if the root DomNode subscribes to any of these events, the event occurs if any DomNode changes.
DomNodeDebugger is a private subclass of DomNode devoted to helping debug the DOM. For a full description of how this class aids debugging DOM code, see Debugging the DOM with Visual Studio. For DOM debugging topics, see DOM Debugging.
These metadata classes contain the information provided in the type definition, as well as other information.
A DomNodeType object specifies the type of a DomNode and holds all the information about the type. A DomNodeType can contain attributes, child node types (types of children of a node of this type), and DOM adapters. A DomNodeType is constructed from the name of the type:
DomNodeType(string name)DomNodeType derives from NamedMetadata, which is the general class for type metadata. NamedMetadata has a very useful method:
SetTag(object key, object value)You can use SetTag() to add any kind of metadata to a DomNodeType object, such as palette information. For examples, see Using DOM Metadata for Palettes and Other Items and Specifying Property Descriptors in Constructors.
Use the DomNodeType.Define() method to define DOM adapters for the types to which they apply. For details on how to do this, see Defining DOM Adapters for Types.
DomNodeType.BaseOfAllTypes is the node type from which all node types ultimately derive. This type is useful to define general-purpose DOM adapters that apply to all types of DomNodes.
In particular, DomNodeType.BaseOfAllTypes is used to enable metadata driven property editing for the DOM. For more details, see Metadata Driven Property Editing.
The general class of metadata, FieldMetadata, describes the fields inside a DomNodeType. These classes all derive from FieldMetadata:
- 
AttributeInfo: Metadata about aDomNodeType's attributes, which include the attribute typeAttributeType, any restrictions the attribute was defined with, such as its maximum value, and any additional restriction rules defined.AttributeTypedescribes aDomNodeattribute's type, which can be a primitive value or an array of primitive values.
- 
ChildInfo: Metadata about a child of aDomNode. Child information includes an identifying name, the child'sDomNodeTypeand whether the child is a list of nodes, as mentioned in DomNode Children.ChildInfocontains any restriction rules, such as limits on the number of children.ChildInfocan serve as an identifier for the type of a node's child. Typically, everyDomNodehas aChildInfoassociated with it, even the type of the rootDomNode. In fact, the rootDomNodemust have an associatedChildInfofor the application data persistence mechanism of ATF to work.
- 
ExtensionInfo: A DOM extension defined for this type, which is nearly always a DOM adapter. For information on what DOM adapters can do, see DOM Adapters.
- What is the DOM For: Overview of the DOM's features and advantages.
- It All Starts With Data: Defining application data models with types, especially using XML Schema.
- 
DomNodes and DOM Metadata Classes: The fundamental DomNodeclass and its type metadata classes, such asDomNodeType. Application data resides in a tree ofDomNodes.
- Type Loaders: Loading the type definition file into the application to use the file's data types and create type metadata class objects.
- 
DOM Adapters: DOM adapters allow adapting DomNodes to other types and monitor events in theDomNodetree to validate data.
- DOM Property Descriptors: DOM property descriptors make it easy to use property editors on application data and are stored in type metadata.
- Using DOM Metadata for Palettes and Other Items: Type metadata can hold all sorts of data, such as palette object information.
- 
DOM Persistence: Persisting application data using classes to write the DomNodetree to XML and read it back to aDomNodetree.
- DOM Debugging: ATF tools to facilitate debugging DOM code.
- DOM Use in Simple DOM Editor: Explains how the ATF Simple DOM Editor Sample uses the DOM.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC