actions 檔包含要對 topics 和 infoviews 執行的 scripting action。 目前只有一種動作,就是插入動作,使用此動作將按照插入點的 指定位置將 topics 插入 infoviews。您可以使用 Infoviews 和 topics 作為插入點。只有定義選用性 ID 的 topics 才能作為插入點。( Infoviews 一定要有 ID。)
定義插入 action 時,to 屬性指定目標插入點。 在 from 屬性中指定的 topic 是被插入的 topic。
下列是用來插入 topic 的一些可能方法:
作為插入點的子項(最常見)
作為插入點的第一個子項
作為插入點的最後一個子項
作為插入點的上一個同屬項(在導覽樹狀結構中的相同層次的插入點前面)
作為插入點的下一個同屬項(在導覽樹狀結構中的相同層次的插入點後面)
插入動作可以是巢狀,用來定義母項插入動作失敗時必須執行的「替代」插入動作。 當插入點所在位置為不一定有安裝的其他外掛程式時,這樣做會很 有用。您可以將 topic 插入另一個外掛程式的 topic,如果插入 action 檔 (因為沒有安裝其他外掛程式),您可以在別的地方安裝 topic。一旦滿 足了某個插入點,就會忽略巢狀的插入動作。
Actions 檔一律對單一 infoview 套用 action。 如果要將 topics 包括到不同 infoviews,那麼每一個 infoviews 需要一個 actions 檔。在一個特定 infoview 內只能使用一次 topic。 如果在一個 infoview 內需要參照一個 topic 兩次,那麼您必須建立 另一個使用相同 label 和 href 的 topic 元素(不同 id )。
到了最後將 topics 整合到 "Contents" infoview 的最上層 topics。 為了執行這個整合工作,我們需要另一個 actions 檔,我們將稱它為 actions_All.xml(因為它整合所有 topics)。
<actions infoview="com.example.helpexample.view_Contents">
<insert
from="com.example.helpexample.conceptsAll"
to="com.example.helpexample.conceptsRoot"
as="child"/>
<insert
from="com.example.helpexample.refAll"
to="com.example.helpexample.refRoot"
as="child"/>
<insert
from="com.example.helpexample.plainTasks"
to="com.example.helpexample.tasksRoot"
as="child"/>
<insert
from="com.example.helpexample.funTasks"
to="com.example.helpexample.funRoot"
as="child"/> </actions>
記得我們有一些與 html 檔相關的作業嗎?topics_tasks.xml 以下列方式定 義這些檔案的結構/導覽:
<topics id="tasksAll">
<topic id="plainTasks" label="Plain Stuff">
<topic label="Task1" href="doc/tasks/task1.html"/>
<topic label="Task2" href="doc/tasks/task2.html"/>
</topic>
<topic id="funTasks" label="Fun Stuff" >
<topic label="Task3_1" href="doc/tasks/task3_1.html"/>
<topic label="Task3_2" href="doc/tasks/task3_2.html"/>
</topic>
</topics>
在述 actions 檔中我們使用 insert 作為子項 action 來選取含有 ID com.example.helpexample.plainTasks 的 topic,然後在含有 ID com.example.helpexample..tasksRoot 的 topic 下面插入它和它的子項 topics
<insert
from="com.example.helpexample.plainTasks"
to="com.example.helpexample.tasksRoot"
as="child"/>
actions 檔也選取一些更有趣的工作並使用下列動作將它們插入 Web 的 "Fun Things" 區域。
<insert
from="com.example.helpexample.funTasks"
to="com.example.helpexample.funRoot"
as="child"/>