About XML data and repeating elements

About XML data and repeating elements

The Repeat Region XSLT object lets you display repeating elements from an XML file within a page. Any region containing an XML data placeholder can be turned into a repeated region. However, the most common regions are a table, a table row, or a series of table rows.

The following example illustrates how the Repeat Region XSLT object is applied to a table row that displays menu information for a restaurant. The initial row displays three different elements from the XML schema: item, description, and price. When the Repeat Region XSLT object is applied to the table row, and the page is processed by an application server or a browser, the table is repeated with unique data inserted in each new table row.

This is a picture of the feature being described.

When you apply a Repeat Region XSLT object in the Document window, a thin, tabbed, gray outline appears around the repeated region. When you preview your work in a browser (File > Preview in Browser), the gray outline disappears and the selection expands to display the specified repeating elements in the XML file, as in the previous illustration.

You might also notice that when you add the Repeat Region XSLT object to the page, Dreamweaver truncates the length of the XML data placeholder in the Document window. This is because Dreamweaver updates the XPath for the XML data placeholder so that it is relative to the path of the repeating element.

For example, the following code is for a table that contains two dynamic placeholders, without a Repeat Region XSLT object applied to the table:

<table width="500" border="1">
   <tr>
      <td><xsl:value-of select="rss/channel/item/title"/></td>
   </tr>
   <tr>
      <td><xsl:value-of select="rss/channel/item/description"/></td>
   </tr>
</table>

The following code is for the same table with the Repeat Region XSLT object applied to it:

<xsl:for-each select="rss/channel/item">
   <table width="500" border="1">
      <tr>
         <td><xsl:value-of select="title"/></td>
      </tr>
      <tr>
         <td><xsl:value-of select="description"/></td>
      </tr>
   </table>
</xsl:for-each>

In the previous example, Dreamweaver has automatically updated the XPath for the items that fall within the Repeat Region (title & description) to be relative to the XPath in the enclosing <xsl:for-each> tags, rather than the full document.

Dreamweaver generates context-relative XPath expressions in other cases as well. For example, if you drag an XML data placeholder to a table that already has a Repeat Region XSLT object applied to it, Dreamweaver automatically displays the XPath relative to the existing XPath in the enclosing <xsl:for-each> tags.

To learn how to apply the Repeat Region XSLT object, see Displaying repeating XML elements.

Related topics

  • About using XML and XSL with web pages


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...