<!ELEMENT extension (traversalStrategy+)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!ELEMENT traversalStrategy (eclass*)>
<!ATTLIST traversalStrategy
namespaceUri CDATA #REQUIRED
class CDATA #REQUIRED>
Declares a traversal strategy that knows how to iterate sub-trees rooted at elements of types in a specific EPackage. Zero or more EClasses may be specified to indicate which specific element types are to use the traversal strategy. If no EClasses are listed, then this strategy constitutes the default for the package. Multiple traversal strategies can be provided for the same EPackage, for example to iterate different element types in different ways. In fact, at at least two declarations are needed to define a default strategy for the package and a select number of alternative implementations for specific EClasses.
<!ELEMENT eclass EMPTY>
<!ATTLIST eclass
name CDATA #REQUIRED>
Indicates a specific EClass in the package identified by the extension's namespace URI to which the traversal strategy applies. This EClass is assumed to be one whose instances can serve as a root container, thus defining a "kind of" model implemented by the metamodel. A metamodel may require different traversal algorithms for resources rooted in different metaclasses; the validation system finds the most appropriate traversal strategy for an element according to its root container. The inheritance of EClasses is taken into account. During validation, the system finds the most specific strategy declaration available for any EClass (defaulting to the package default strategy if needed). As an example of metamodels that distinguish different kinds of models by the root container type, the UML 2.0 metamodel defines Model and Profile metaclasses (both specializations of Package) that can serve as root containers.
This example shows an extension that declares a traversal strategy for the EXTLibrary meta-model. It applies to traversals starting at Persons or Items (rather than at libraries), perhaps because its purpose is to back-track to the nearest containing Library and start from there. When traversal starts from a Library, this extension indicates that the default strategy (recursion over the containment tree) is sufficient.
<extension point="org.eclipse.emf.validation.traversal"> <traversalStrategy namespaceUri="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0" class="com.example.validation.traversal.EXTLibraryTraversalStrategy"/> <eclass name="Person" /> <eclass name="Item" /> </traversalStrategy> </extension>
Copyright (c) 2005 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html