Setting the XPath Expression Builder (Repeat Region) dialog box options

Setting the XPath Expression Builder (Repeat Region) dialog box options

The purpose of this dialog box is to select a node to repeat over and, optionally, to filter the results. If you have content selected when this dialog box is invoked, your content will be wrapped inside an <xsl:for-each> block. If you do not have content selected, the <xsl:for-each> block will be entered at the insertion point of your cursor.

One of the advantages of the XPath Expression Builder is that it identifies the current context based on your position in the XSL file when the dialog box is opened. The current context is in boldface type in the XML schema tree. As you make selections within this dialog box, it generates the correct XPath statements relative to your current context. This simplifies the process of writing correct XPath expressions for both beginners and advanced users.

XPath (XML Path Language) is a non-XML syntax for addressing portions of an XML document. It is used mostly as a query language for XML data, just as the SQL language is used to query databases. For more information on XPath, see the XPath language specification on the W3C website at www.w3.org/TR/xpath.

It is important to note that this dialog box is designed to help you build simple XPath expressions for repeat regions. It does not allow you to edit the expressions by hand. If you need to create complex expressions, use this dialog box to get started and then customize your expressions in Code view or with the Property inspector.

To select a node to repeat:

  • In the XPath Expression Builder (Repeat Region) dialog box, select the item to repeat in the XML schema tree.

    Dreamweaver writes the correct XPath expression in the Expression text box to identify the node.

In the following example, you want to repeat over each item node within the XML file.

This is a picture of the feature being described.

When you click OK, the following code is inserted in your XSLT page:

<xsl:for-each select="provider/store/items/item">
   Content goes here
</xsl:for-each>

In some cases, you may want to work with a subset of the repeating nodes--for example, you may only want items where an attribute has a specific value. In this case, you need to create a filter.

To filter the data to be repeated:

  1. In the XML schema tree, select a node to repeat.
  2. Click the Build Filter expander button.
  3. Click the Plus (+) button.

    Dreamweaver creates an empty filter.

  4. Enter the filter criteria in the following fields:

    Filter By specifies the repeating node that contains the data you want to filter by. The pop-up menu provides a list of ancestor nodes relative to the node you selected in the XML schema tree.

    Where specifies the attribute or subelement of the Filter By node that will be used to limit the results. You can select an attribute or subelement from the pop-up menu, or you can enter your own XPath expression in this field to identify children that exist deeper within the schema tree.

    Operator specifies the comparison operator to use in the filter expression.

    Value specifies the value to check for in the Filter By node. Enter the value. If dynamic parameters are defined for your XSLT page, you can select one from the pop-up menu.

  5. To specify another filter, click the Plus (+) button again.

    As you enter values or make selections in the pop-up menus, Dreamweaver changes the XPath expression in the Expression text box.

In the following example, you want to restrict the resultset to those item nodes where the value of the @available attribute is true.

This is a picture of the feature being described.

When you click OK, the following code is inserted in your XSLT page:

<xsl:for-each select="provider/store/items/item[@available = &apos;true&apos;]">
     Content goes here
</xsl:for-each>

You can create more complex filters that allow you to specify parent nodes as part of your filter criteria. In the following example, you want to restrict the resultset to those item nodes where the store’s @id attribute is equal to 1 and the item’s price node is greater than 5.

This is a picture of the feature being described.

When you click OK, the following code is inserted in your XSLT page:

<xsl:for-each select="provider/store[@id = 1]/items/item[price &gt; 5]">
   Content goes here
</xsl:for-each>

For more information and examples of repeat regions, see the <xsl:for-each> section in the Reference panel.



Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Defining Sources of Dynamic Content
Developing Applications Rapidly
 
ASPTreeView.com
 
Evaluation has јµРёЦЅШБШexpired.
Info...