|
The following sections describe how to apply rules to several elements:
Note For a general introduction to the concepts of element depth and position, see the "XHTML Element Hierarchy" section. |
Rather than recreating the same rule for several elements on a page, you can create one rule and apply it to those elements. For example, if you want to change every hr element to a br element, you select the first br element, choose the Modify rule, and specify how you want the rule applied throughout the page. This feature simplifies the development and maintenance of configuration files and also results in more efficient operation for the Cisco CTE 1400.
The Configure Rule dialog box for most types of rules contains a Path to Selected Element area, as shown in Figure 5-1. To apply a rule to more than one element on a page, you configure at least one of the elements in the list.
The Path to Selected Element area lists every tag (enclosed in angle brackets) and text element that is in the path to the element to which you are applying a rule. The last item in the list (such as "Cisco Systems, Inc." in Figure 5-1) is the tag or text element selected in the XHTML source view when you chose a rule. To apply a rule to several elements, you typically start by configuring the last path element in the list. In some cases, you must configure more than one path element to achieve the intended result.
After you select a tag or text in the Path to Selected Element area, a dialog box similar to the one in Figure 5-2 appears.
To expand the scope of the rule, you change the default settings in the Configure Path Element dialog box. By default, a rule matches the tag name or text element and applies only to the selected element; attribute values are ignored.
When you apply a rule, you typically match against the element name, such as form, or the element text, such as the text string "Cisco Systems, Inc." shown in Figure 5-1. For example, when you select a form element to clip, you often want the clip rule to apply only to that form element and not to all elements. If you are applying a rule to text, you often want the rule to apply only to the selected text string.
Note When applying rules to several elements, be aware that the Select rule always takes precedence and that the last rule added has the highest priority. If a previously added rule no longer takes effect, delete and reapply the rule. |
You typically choose to not match by element name only if the information you want to match is always at a particular position in the XHTML but is not associated with a particular element. To not match by element name, clear the Match Element Name option in the Configure Path Element dialog box.
For information on how to work with the interaction between the element name and position setting, see the "Applying Rules Based on Position" section.
You can choose to skip a tag that is in the path to the element you are transforming. By skipping a tag, you allow a rule to apply higher in the tree hierarchy. This might be necessary for dynamic content in which formatting elements (font, b) may or may not be present. Skipping a tag is also useful for tables whose structure can vary.
Suppose that you are working with a document that includes the following dynamic content:
Assume that on the dynamically generated page, the b element may not be present around "Hello" and that you want to apply a rule to "Hello." By skipping the b element, you allow the rule to apply to "Hello" whether or not the b element is present. In addition to skipping the b element, you should also use the Any Descendant setting for the rule on the text element "Hello." Using the Any Descendant setting with the Skip This Tag setting is typical usage.
To skip an element, perform these steps:
Step 2 Choose the rule from the shortcut menu.
Step 3 In the Configure dialog box, click the element that may or may not appear in dynamically generated content.
In the following example, the b element is the optional element.
Step 4 In the Configure Path Element dialog box, click Skip This Tag to select it.
Step 5 Click Done.
Step 6 In the Configure: Rule dialog box, click the last element listed (the element on which you are applying the rule).
Step 7 In the Configure Text Element dialog box, click Any Descendant.
The Any Descendant setting allows the element to be matched whether it is at its current depth or one depth higher.
Step 8 Click Done.
Step 9 Change other settings in the Configure:Rule dialog box as needed and then click Done.
When you select a text element in the Path to Selected Element area, the Configure Text Element dialog box (Figure 5-3) displays the selected text.
At the top of the dialog box, you specify the text that an element must contain in order for the rule to apply to the element. By default, a rule applies only to text elements with the exact string, such as "Cisco Worldwide Contacts" shown in Figure 5-3. You can choose to apply a rule more broadly, such as to any text element that contains the original string. Table 5-1 describes the text to specify and menu item to select based on the text you want to match (as a condition for applying a rule).
Depth refers to how an element is nested along the x-axis in the XHTML. Suppose that a web page includes the following XHTML structure:
The second table element is a descendent of the first table element. There are tables at three different depths.
Suppose that you want to use one rule to remove the borders from several tables. Your web page contains the following XHTML structure. The table element in bold and underlined is the element selected when you apply a command.
Table 5-2 shows how each Depth to Match setting applies to other table elements, given the setup in this section. The elements affected by the depth settings are in bold and underlined in Table 5-2.
Table 5-2 Effect of XHTML Depth Settings
|
For more information, see the following sections:
Note When applying rules to several elements, be aware that the Select rule always takes precedence and that the last rule added has the highest priority. If a previously added rule no longer takes effect, delete and reapply the rule. |
Position refers to the sequence of a tag or text element along the y-axis in the XHTML. Suppose that a web page includes the following XHTML structure:
The four table elements are in positions one through four, provided you are matching on the element name table. If you are not matching on element name, all tag types are included in the count: The four table elements are in positions one, two, four, and five. The form element is in position three. Text elements are not included in the tag count; tags are not included in the text element count.
Suppose that you want to use one rule to clip several rows from all tables. Your web page contains the following XHTML structure. The table element in bold and underlined is the element selected when you apply a command.
Table 5-3 shows how each Element Position to Match setting applies to other table elements, given the setup in this section. Assume that the Match Element Name setting is selected and that the Depth to Match setting is Exact. The elements affected by the position settings are in bold and underlined in Table 5-3.
Table 5-3 Effect of Element Position Settings
Note When applying rules to several elements, be aware that the Select rule always takes precedence and that the last rule added has the highest priority. If a previously added rule no longer takes effect, delete and reapply the rule. |
For more information, see the following sections:
The depth and position settings work together, providing you with precise control over how narrowly or broadly a rule is applied. Table 5-4 describes how to set the Depth to Match and the Position to Match options based on how you want to apply a rule.
Table 5-4 Choosing Depth and Position Options
|
Choosing depth and position settings that have your intended results may require some experimentation. If you are unsure how to achieve a particular result, test the position settings first, followed by the depth settings. If changing just a depth or position setting does not work, then try combinations of those settings.
Consider the following scenario:
To include all but the first two link/text/break combinations in each table, perform these steps to configure the a element and the br element:
Step 2 Choose Clip from the shortcut menu.
Step 3 In the Configure: Clip Rule dialog box, scroll to the end of the Path to Selected Element list and click the a element.
Step 4 In the Configure Path Element dialog box, set the options as follows:
Match Element Name: selected
Depth to Match: All Depths
Position to Match: Range Min = 1 and Range Max = 2
Step 5 Click Done and then click Done again.
Step 6 In the XHTML source view, right-click the br element that immediately follows the a element you just worked with.
Step 7 Choose Clip from the shortcut menu.
Step 8 In the Configure: Clip Rule dialog box, scroll to the end of the Path to Selected Element list and click the br element.
Step 9 In the Configure Path Element dialog box, set the options as follows:
Match Element Name: selected
Depth to Match: All Depths
Position to Match: Range Min = 1 and Range Max = 2
Step 10 Click Done and then click Done again.
Consider the following scenario:
To apply the Modify rule to the nested tables (which are contained in two columns), you must configure the table and td elements so that the rule will iterate across the columns.
To configure the table element and the td element, perform these steps:
Step 2 Choose Modify from the shortcut menu.
Step 3 Click the Modify Element tab.
Step 4 Change the value of "border" to 0.
Step 5 Click the Configure Rule tab.
Step 6 Scroll to the end of the Path to Selected Element list and click the table element.
Step 7 In the Configure Path Element dialog box, set the options as follows:
Match Element Name: selected
Depth to Match: Exact
Position to Match: All Positions
Step 8 Click Done.
In the browser view, the borders are removed only from the tables in the left-most column.
Step 9 In the XHTML source view, right-click the table element with the Modify icon (
) and select Edit Rule from the shortcut menu.
Step 10 In the Path to Selected Element area, click the td element that immediately precedes the last table element.
Step 11 In the Configure Path Element dialog box, set the options as follows:
Match Element Name: selected
Depth to Match: Exact
Position to Match: All Positions
Step 12 Click Done and then click Done again.
In the browser view, the borders are removed from the tables in both columns.
By default, the CTE ignores the values of element attributes. For example, if the CTE finds a form element at a specified depth and position, it applies a rule to the form regardless of attribute values. However, you might want to specify that a rule applies only to forms with a particular method or target attribute. In addition, when you create transformation rules for a page that is dynamically generated, you might not know at what depth or position an element resides. However, you might know that the table elements you want to apply the rule to always have a particular datasrc attribute.
Table 5-5 describes how to set the attributes area in the Configure Path Element dialog box, based on how you want to apply a rule. For an example, see the "Example: Applying a Rule to All Occurrences of an Element with a Specified Attribute" section.
Table 5-5 Changing How an Attribute is Matched
|
Consider the following scenario:
To apply a rule to the form element regardless of its position on the page, set the options in the Configure Path Element dialog box as follows:
Match Element Name: selected
Depth to Match: All Depths
Position to Match: All Positions
datasrc Attribute Operation: equals
A Move rule contains path information for both the source element you are moving and its destination. When you create a Move rule, as described in the "Moving an Element Tag" section, the Configure: Move Rule dialog box shows the path that is common to the source element and its destination, followed by two folders named Source and Destination. The Source folder lists the path to the element you are moving. The Destination folder lists the path to the element where you are relocating the element as shown in Figure 5-4.
You can apply the Move rule to several source elements and to several destinations. Suppose that you are working with a page that contains several input fields followed by a label and you want to move each label so that it displays in front of the input field. You can do that with one Move rule by applying the rule to several source and destination elements.
To move or copy several elements, perform these steps:
The Source tab lists the full path to the element you selected to be moved.
Step 2 In the Path to Selected Element area, click the element you are moving.
Step 3 In the Configure Element dialog box, specify how you want Design Studio to match the elements you want to move.
For example, if you are moving all a elements that appear in a table, click the first a element and then click All Positions in the Configure Element dialog box.
Note Design Studio does not allow you to change the depth setting of the first element listed for the Source. Because the depth of the first Source element is relative to the Destination Path, Design Studio must retain the depth setting of the element in order to track the XPath of the element. |
Step 4 Click Done and then click Done again.
To move or copy to several locations, perform these steps:
Step 2 In the Path to Selected Element area, click the element before or after which you are moving the source element.
Step 3 In the Configure Element dialog box, specify how you want Design Studio to match against several destination elements.
For example, if you are moving one or more source elements after several input elements, click the first input element and then click the appropriate position and depth settings in the Configure Element dialog box.
Step 4 Click Done and then click Done again.
A Dial Number rule contains path information for both the dialable number and its label. When you create a Dial Number rule, as described in the "Adding a Dialable Phone Number" section, the Configure: Dial Number Rule dialog box includes the path to the phone number and label as shown in Figure 5-5.
You can apply the Dial Number rule to several phone numbers and labels. Suppose that you want to make all numbers in a directory listing dialable. You can do that with one Dial Number rule by applying the rule to several pairs of phone numbers and label elements.
To apply the Dial Number rule to several phone numbers, perform these steps:
Step 2 In the Path to Selected Element area, click the phone number you want to be dialable.
Step 3 In the Configure Element dialog box, specify how you want Design Studio to match other phone numbers you want to be dialable.
For example, if all phone numbers you want to be dialable have a common prefix, such as "(800)", match on just the prefix and click All Positions in the Configure Element dialog box as shown in the following example:
Step 4 Click Done.
To apply the Dial Number rule to the label for each dialable phone number, perform these steps:
Note This procedure assumes that you have already specified a label for the Dial Number rule when you created it. For more information, see the "Adding a Dialable Phone Number" section. |
The Label tab lists the path to the element you selected for the label.
Step 2 In the Path to Selected Element area, click the text you chose for the label.
Step 3 In the Configure Element dialog box, specify how you want Design Studio to match other labels.
Step 4 Click Done and then click Done again.
Note This feature is intended only for users familiar with XSL. |
You can manually configure an element by editing its XPath expression. This feature provides more flexibility in node selection when applying a rule.You can modify an XPath expression to address one or several nodes.
Table 5-6 contains the XPath expression to use to achieve various results.
Table 5-6 XPath Expression Examples
|
1 If the text you want to configure contains special characters, particularly single or double quotation marks, be sure to enter the text in the text field and click Reload to retrieve the XPath expression provided by Design Studio. You must include any text variables provided by Design Studio in your XPath expression. |
For more information about XPath pattern matching, see http://www.w3.org/TR/xpath.
To manually configure an XPath expression, perform these steps:
Step 2 Choose Manually Configure Element.
Step 3 Click Reload to view the current XPath expression for the node.
Step 4 Edit the XPath configuration in the text box.
Design Studio alerts you if you enter invalid syntax for the XPath.
Step 5 Click Done.
Posted: Mon Aug 18 17:09:46 PDT 2003
All contents are Copyright © 1992--2003 Cisco Systems, Inc. All rights reserved.
Important Notices and Privacy Statement.