Dependencies
Previous  Top  Next

As its name suggests, a dependency element specifies a dependency from one item (the source) to another item (the target).

<
data flavor="com.headway.examples.halloworld">
   <
modules>
      <
module name="hallo" id="1" type="word"/>
      <
module name="world" id="2" type="word"/>
   <
/modules>
   <
dependencies>
      <
dependency from="1" to="2" type="comes before"/>
   <
/dependencies>
<
/data>

In the example above, there is a dependency from "hallo" to "world", of type "comes before".

To be valid, the values of the from and to attributes must each match the id of an item declared elsewhere in the data file.

Notes:
·It is perfectly legal for an item A to have several dependencies to an item B (though this is redundant unless the dependency types are different).  
·In general, you should only specify dependencies at the lowest level and let Structure101g infer "rolled up" dependencies. For example, if A.method1 calls B.method2, then Structure101g will automatically recognize an inferred dependency from A to B.  
·A dependency from an item to itself (e.g. a method calls itself recursively) will be ignored.  

There is an alternative way of defining a dependency in the XML data file, namely by using a depends-on element. Here, the from is implied from context (the parent module/submodule) and the to is specified via the id attribute. This is illustrated in the following example (semantically equivalent to the one above).

<
data flavor="com.headway.examples.halloworld">
   <
modules>
      <
module name="hallo" id="1" type="word">
         <
depends-on id="2" type="comes before"/>
      <
/module>
      <
module name="world" id="2" type="word"/>
   <
/modules>
<
/data>