Change Text conditionally causes text content immediately within the specified elements to be replaced.
Text residing within descendant elements of the specified element are not processed.
Note: Only contiguous text can be substituted. If an element, such as emphasis or subscript, wraps a portion of a match string, no match will occur. You can replace a string with an XML fragment, including a linking element with a referencing attribute.
This rule uses the following parameters:
- Find
- The text to be found immediately within the specified elements.
- Replace With
- The text which is to replace the text that was matched.
- Case Sensitive
- A true/false selection indicating if the Find string must match the case. Select the check box for true; clear the check box for false.
- RegEx
- A true/false selection indicating if regular expression processing should be used. Select the check box for true; clear the check box for false.
Replacing a Text String with an XML Fragment
Replace text with an XML fragment by starting the
Replace With string with
xml:
. To wrap the text string
paragraph with a <b> element, specify a Change Text rule with:
Find |
paragraph |
Replace With |
xml:<b>paragraph</b> |
Case sensitive |
false (not selected) |
RegEx |
false (not selected) |
Note: If you leave out the leading
xml:
, then the process will not replace with a fragment, and will replace with the text string
<b>paragraph</b> in the PCDATA.
Note that the xml fragment does not have to be a single element. The following
Replace With values are legal:
- Nested elements:
xml:<p>Hello <b>World</b></p>
- Multiple top-level elements:
xml:<p>First paragraph</p><p>Second paragraph</p>
- Leading and/or trailing PCDATA:
xml:hello <b>World</b>, how are you?
Replacing with an XML Fragment Linking Element using a URL
To replace a string with a DITA linking element (for example, conref, xref, image) specify the appropriate attributes with a valid repository WEBDAV URL. You can generate this URL from the WAN editor. If you create a conref/href in your editor using the Astoria menu, you will see the href attribute with a value something like:
http://shrike/astoria/_id_00000018WIA33D06910GYZ_conrefA1.dita#conrefA/para
Use this value in the
Replace With string:
xml:<p conref="http://shrike/astoria/_id_00000018WIA33D06910GYZ_conrefA1.dita#conrefA/para">
It is critical that you include the trailing fragment string #conrefA/para
if indeed you wish to reference a specific element.
You can also use the folder item path syntax instead of the ID syntax:
xml:<p conref="http://shrike/astoria/DITA/Translation Testing/Approval/
conrefA1.dita#conrefA/para"/>
It is critical that you include the trailing fragment string
#conrefA/para
if indeed you wish to reference a specific element.
Replacing with a link to a graphic file works similarly, just without the trailing fragment string:
xml:<image href="http://shrike/astoria/DITA/Translation Testing/Effectivity/basediag3.gif"/>
Inserting Text After One or More Matched Words
If you had the text:
I did run the marathon. I do believe that was wise. and want to insert the word
not after
did or
do, specify a Change Text rule with:
Find |
(did|do) |
Replace With |
$1 not |
Case sensitive |
false (not selected) |
RegEx |
false (not selected) |
The text would be changed to I did not run the marathon. I do not believe that was wise.