網頁可能包含 XML 內容,其因此可包含 URL。需重新寫入的 XML 內容可分為兩類:
此規則是用於重新寫入標記元素的 PCDATA 或 CDATA。
本節分為下列部分:
<TagText tag="tagName" [attributePatterns="attribute_patterns_for_ this_tag" source="*"]/>
其中
tagName 為標記名稱
attributePatterns 是此標記的屬性及值式樣 (可選,表示此標記完全不具屬性)
source 是此 xml 檔案的 URI (可選,預設為 *,表示任何 xml 網頁)
假設此網頁的基準 URL 是:
http://abc.sesta.com/test/rewriter/test1/xml/page.html
網頁內容
<xml> <Attribute name="src">test.html</attribute> <attribute>abc.html</attribute> </xml>
規則
<TagText tag="attribute" attributePatterns="name=src"/>
輸出
<xml> <Attribute name="src">gateway-URL/ http://abc.sesta.com/test/rewriter/test1/ xml/test.html</attribute><attribute>abc.html</attribute> </xml>
描述
網頁內容的第一行包含屬性範例。此網頁內容的第二行不包含具有屬性呼叫名稱且屬性名稱值為 src 的屬性,因此不會執行任何重新寫入的動作。要進行重新寫入,我們亦需具有 <TagText tag="attribute"/>
XML 屬性的規則與 HTML 的屬性規則類似。其間的差異在於:XML 的屬性規則有大小寫之分,而 HTML 屬性規則則無。這是因為 XML 中建立了區分大小寫的特性,而 HTML 中未建立。
Rewriter 會依據屬性名稱轉譯屬性值。
本節分為下列部分:
<Attribute name="attributeName " [tag="*" type="URL" valuePatterns="*" source="*"]/>
其中
attributeName 為屬性名稱 (必須的)
tag 是包含此屬性的標記的名稱 (可選,預設為 *,表示任何標記)
valuePatterns 請參閱在規則中與式樣相符。
source 是此 XML 網頁的 URI (可選,預設為 *,表示在任何 XML 網頁中)
假設此網頁的基準 URL 是:
http://abc.sesta.com/test/rewriter/test1/xml/page.html
網頁內容
<xml> <baseroot href="/root.html"/> <img href="image.html"/> <string href="1234|substring.html"/> <check href="1234|string.html"/> </xml>
規則
<Attribute name="href"tag="check" valuePatterns="1234|"/>
輸出
<xml> <baseroot href="/root.html"/><img href="image.html"/> <string href="1234|substring.html"/><check href="1234| gateway-URL /http://abc.sesta.com/test/rewriter/test1/xml/string.html"/></xml>
描述
上列範例中,僅重新寫入第四行,因為其符合規則中所指定的所有條件。請參閱在規則中與式樣相符。