使用AEM元件自訂DITA元素對應 id1679J600HEL
AEM Guides中的DITA元素對應至其對應的AEM元件。 AEM Guides在工作流程(例如發佈和稽核)中使用此對應,將DITA元素轉換為對應的AEM元件。 在elementmapping.xml檔案中定義對應,該檔案可使用Cloud Service設定的封裝管理員進行存取,也可以從URL: /libs/fmdita/config/elementmapping.xml (內部部署設定的CRXDE Lite模式)進行存取。
libs節點中使用預設組態檔中的任何自訂專案。 您必須在libs節點中建立apps節點的覆蓋,並僅更新apps節點中的必要檔案。您可以使用預先定義的DITA元素對應,也可以將DITA元素對映至自訂AEM元件。 若要使用自訂AEM元件,您必須瞭解elementmapping.xml檔案的結構。
elementmapping.xml結構
以下說明elementmapping.xml結構的高階概觀:
-
系統會根據元素名稱,先搜尋每個DITA元素以尋找對應的元件對應。 例如:
code language-xml <ditaelement> <name>**substeps**</name> <class>- topic/ol task/substeps</class> <componentpath>dita/components/ditaolist</componentpath> <type>COMPOSITE</type> <target>para</target> </ditaelement>在上述範例中,所有
substepsDITA元素都是使用dita/components/ditaolist元件轉譯。 -
如果DITA元素找不到以名稱為基礎的相符專案,則會完成以
class為基礎的相符專案。 例如:code language-xml <ditaelement> <name>topic</name> <class>**- topic/topic**</class> <componentpath>fmdita/components/dita/topic</componentpath> <type>COMPOSITE</type> <target>para</target> <attributemap> <attribute from="id" to="id" /> </attributemap> </ditaelement>在上述範例中,如果沒有為
task元素定義對應,則task元素會對應至上述元件,因為task繼承自topic元件。 -
當元素具有對應的元件對應時,其子元素的進一步處理由
type決定。 例如:code language-xml <ditaelement> <name>title</name> <class>- topic/title</class> <componentpath>foundation/components/title</componentpath> <type>**STANDALONE**</type> <target>para</target> <textprop>jcr:title</textprop> </ditaelement>type採用下列值:-
COMPOSITE:子元素 的元素與元件 的對映也會繼續。
-
STANDALONE:目前專案的子專案是未進一步對應。
在上述範例中,若
<title>元素具有任何子元素,則不會對應至任何其他元件。<title>元素的元件負責轉譯<title>元素內的所有子元素。 -
-
如果有多個元件對應至單一DITA元素,則會選取該元素的最佳相符專案。 若要選取最佳相符元件,會考慮DITA元素的領域和結構專門化。
如果有具有領域專門化的DITA元素,且元件對應到領域專門化,則該元件會獲得高優先順序。
同樣地,如果有具有結構專門化的DITA元素,且元件對應結構專門化,則該元件會獲得高優先順序。
-
您可以在元素對應中使用
<attributemap>,將屬性值對應至對應的節點屬性。 -
textprop可用來將DITA元素的文字內容序列化為node屬性。 此外,它可以在元素標籤中多次使用,以將已發佈階層中多個位置的文字內容序列化。 您也可以自訂目標屬性的位置和名稱。 例如:code language-xml <ditaelement> <name>title</name> <componentpath>foundation/components/title</componentpath> <type>STANDALONE</type> <target>para</target> <textprop>**jcr:title**</textprop> </ditaelement>以上元素對應指定
<title>元素的文字內容將會儲存為輸出節點上名為jcr:title之屬性的值。 -
xmlprop可用來將指定專案的整個XML序列化為節點屬性。 元件將可讀取此節點屬性並執行自訂轉譯。 例如:code language-xml <ditaelement> <name>svg-container</name> <class>+ topic/foreign svg-d/svg-container</class> <componentpath>fmdita/components/dita/svg</componentpath> <type>STANDALONE</type> <target>para</target> <xmlprop>**data**</xmlprop> </ditaelement>以上專案對應指定專案
<svg-container>的整個XML標籤將會儲存為輸出節點上名為data之屬性的值。 -
有一個特殊的屬性對應,可在輸出產生程式中處理路徑解析。 例如:
code language-xml <attributemap> <attribute from="href" to="fileReference" ispath="true" rel="source" /> <attribute from="height" to="height" /> <attribute from="width" to="width" /> </attributemap>對於上述
attributemap,您DITA元素中的href屬性將對應至名為fileReference的節點屬性。 現在,由於ispath設定為true,輸出產生程式會解析此路徑,然後在fileReference節點屬性中設定它。此解析如何根據屬性對應中
rel屬性的值來決定。-
如果
rel=source,則會針對目前處理中的DITA來源檔案解析href的值。href的值已解析並置於fileReference屬性的值中。 -
如果
rel=target,則相對於根發佈位置解析href的值。href的值已解析並置於fileReference屬性的值中。
如果您不想在路徑屬性上發生任何前置處理或解析,則不需要指定
ispath屬性。 值會依原樣複製,元件可執行所需的解析度。 -
DITA元素結構描述
以下是elementmapping.xml檔案中DITA元素結構描述的範例:
<ditaelement>
<name>element_name</name>
<class>element_class</class>
<componentpath>fmdita/components/dita/component_name</componentpath>
<type>COMPOSITE|STANDALONE</type>
<attributeprop>propname_a</attributeprop>
<textprop>propname_t</textprop>
<xmlprop>propname_x</xmlprop>
<xpath>xpath expression string</xpath>
<target>head|para</target>
<wrapelement>div</wrapelement>
<wrapclass>class_name</wrapclass>
<attributemap>
<attribute from="attrname" to="propname" ispath="true|false" rel="source|target" />
</attributemap>
<skip>true|false</skip>
</ditaelement>
下表說明DITA元素結構描述中的元素:
<ditaelement><class>例如,DITA主題的類別屬性是:
- topic/topic<componentpath><type>- 複合:處理子專案及
- STANDALONE:略過處理子專案
<attributeprop><note type="Caution">個元素,而對應至此元素的元件有<attributeprop>attr_t</ attributeprop>,則節點的屬性和值會序列化為對應AEM節點( attr_t)的attr_t->type="caution"屬性。<textprop>propname_t</textprop>getTextContent()輸出儲存至propname_t.所定義的屬性 注意:這是最佳化的屬性。
<xmlprop>propname_x </xmlprop>propname_x.<br> 定義的屬性注意:這是最佳化的屬性。<xpath><target>可能的值:
- head:在標題節點
之下 — 文字:在段落節點之下
<wrapelement><wrapclass>wrapclass.的元素值<attributemap><attribute>節點的容器節點。<attribute from="attrname" to="propname" ispath="true|false" rel="source|target" />-
from: DITA屬性名稱-
to: AEM元件屬性名稱-
ispath:如果屬性是路徑值\(例如: image\)-
rel:如果路徑是來源或目標注意:如果
attrname開頭為%,則將attrname minus '%'對應至Prop ' propname'。其他附註
-
如果您計畫覆寫預設元素對應,建議您不要在預設
elementmapping.xml檔案中進行變更。 您應該建立新的對應XML檔案,並將檔案放置於其他位置,最好是放在您建立的自訂應用程式資料夾內。 -
在
elementmapping.xml檔案中,有許多參考fmdita/components/dita/wrapper元件的對應專案。 包裝函式是一種泛型元件,會使用其網站節點上的屬性來產生相關的HTML,以呈現相對簡單的DITA建構。 它使用wrapelement屬性來產生封閉標籤,並將子轉譯委派給對應的元件。 當您只想要容器元件時,這個用法就相當實用。 您可以搭配使用Wrapper元件與div和p屬性來達到相同的效果,而不需建立可轉譯特定容器標籤(如wrapelement或wrapclass)的新元件。 -
不建議在字串JCR屬性中儲存大量文字。 輸出產生中最佳化的屬性型別計算可確保大型文字內容不會儲存為字串型別。 反之,當需要儲存大於某個臨界值的內容時,屬性的型別會變更為二進位。 預設會將此臨界值設定為512個位元組,但可以在Configuration Manager (com.adobe.fmdita.config.ConfigManager)中變更,方法是變更 另存為二進位臨界值 設定。
-
如果您計畫覆寫部分\(而非全部\)元素對應,則不需要復寫整個
elementmapping.xml檔案。 您需要建立新的XML對應檔案,並只定義要覆寫的元素。 -
在自訂位置中建立XML檔案之後,請更新
Override Element Mapping組合中的com.adobe.fmdita.config.ConfigManager設定。