Create an XSLT page

You can create XSLT pages that let you displays XML data on web pages.

You can create either:

  • an entire XSLT page, containing a body tag and a head tag
  • an XSLT fragment

When you create an XSLT fragment, you create an independent file that contains no body or head tag — a simple piece of code that is later inserted in a dynamic page.

See help.adobe.com.

Attach XML Data Sources

If you are starting with an existing XSLT page, or if you don’t attach an XML data source when creating a new XSLT page with Dreamweaver, you must attach an XML data source using the Bindings panel.

See help.adobe.com

Display XML Data in XSLT Pages

After you’ve created an XSLT page and attached an XML data source, you can bind data to the page.

To do this, you add an XML data placeholder to your page and then use the XPath Expression Builder or the Property inspector to format selected data that will be displayed on the page.

See help.adobe.com

Display Repeating XML Elements

The Repeating Region XSLT object lets you display repeating elements from an XML data source in a web page. For example, if you are displaying article titles and descriptions from a news feed, and that news feed contains between 10 and 20 articles, each title and description in the XML file would probably be a child element of a repeating element.

Any region in Design view containing an XML data placeholder can be changed to a repeated region. However, the most common regions are tables, table rows, or a series of table rows.

See help.adobe.com.

Insert XSLT fragments in dynamic pages

After you have created an XSLT fragment, you can insert it in a dynamic web page using the XSL Transformation server behavior.

When you add the server behavior to your page and view the page in a browser, an application server performs a transformation that displays the XML data from the selected XSLT fragment.

Dreamweaver supports XSL transformations for ColdFusion, ASP, or PHP pages.

Note: If you want to insert the contents of an entire XSLT page in a dynamic page, the procedure is exactly the same. Before using the XSL Transformation server behavior to insert the entire XSLT page, delete all HTML code from the dynamic page.

See help.adobe.com.

Delete XSLT fragments from dynamic pages

You can remove an XSLT fragment from a page by deleting the XSL Transformation server behavior used to insert the fragment. Deleting the server behavior deletes the XSLT fragment only—it does not delete the associated XML, XSLT, or run-time library files.

See help.adobe.com.

Edit XSL Transformation server behaviors

After you’ve added an XSLT fragment to a dynamic web page, you can edit the XSL Transformation server behavior at any time.

See help.adobe.com.

Create a dynamic link

You can create a dynamic link on your XSLT page that links to a specific URL when the user clicks a specified word or group of words from your XML data. For full instructions, see the Dreamweaver errata at www.adobe.com/go/dw_documentation

See help.adobe.com.

Applying styles to XSLT fragments

When you create an entire XSLT page (that is, an XSLT page that containsandtags), you can display XML data on the page and then format the data like any other piece of content using the Property inspector or the CSS Styles panel. When you create an XSLT fragment for insertion in a dynamic page, however (for example, a fragment for insertion in an ASP, PHP, or Cold Fusion page), the rendering of styles in the fragment and in the dynamic page becomes more complicated. Although you work on an XSLT fragment separately from the dynamic page, it is important to remember that the fragment is intended for use within the dynamic page, and that the output from the XSLT fragment ultimately resides somewhere within thetags of the dynamic page. Given this workflow, it is important to make sure that you do not include elements (such as style definitions or links to external style sheets) in XSLT fragments. Doing so will cause the application server to place these elements into the dynamic page, thereby generating invalid markup.

See help.adobe.com.

Use parameters with XSL Transformations

You can define parameters for your XSL transformation when adding the XSL Transformation server behavior to a web page.

A parameter controls how XML data is processed and displayed.

For example, you might use a parameter to identify and list a specific article from a news feed. When the page loads in a browser, only the article you specified with the parameter appears.

See help.adobe.com.

Conditional XSLT regions

You can create simple conditional regions or multiple conditional regions on an XSLT page. You can either select an element in Design view and apply a conditional region to the selection, or you can insert a conditional region wherever the insertion point is in the document.

For example, if you wanted to display the word “Unavailable” next to the price of an item when the item is unavailable, you type the text “Unavailable” on the page, select it, and then apply a conditional region to the selected text. Dreamweaver surrounds the selection with tags, and only displays the word “Unavailable” on the page when the data match the conditions of the conditional expression.

See help.adobe.com.

XSL Comments

You can add XSL comment tags to a document, or you can wrap a selection in XSL comment tags.

See help.adobe.com.

XPath Expression Builder

Use the XPath Expression Builder to add expressions for XML data.

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.

The XPath Expression Builder is a Dreamweaver feature that lets you build simple XPath expressions for identifying specific nodes of data and for repeating regions. The advantage of using this method instead of dragging values from the XML schema tree is that you can format the value that is displayed. The current context is identified based on the position of the insertion point in the XSL file when the XPath Expression Builder dialog box is opened. The current context is in boldface type in the XML schema tree. As you make selections within this dialog box, the correct XPath statements, relative to your current context, are generated. This simplifies the process of writing correct XPath expressions for beginners and advanced users.

Note: This feature is designed to help you build simple XPath expressions to identify a specific node or for repeating regions. It does not allow you to edit the expressions by hand. If you need to create complex expressions, use the XPath Expression Builder to get started and then customize your expressions in Code view or with the Property inspector.

See Also