beautypg.com

Server-side xsl transformations – Adobe Dreamweaver CC 2015 User Manual

Page 513

background image

506

XML

Last updated 6/3/2015

Extensible Stylesheet Language Transformations (XSLT) is a subset language of XSL that actually lets you display XML
data on a web page, and “transform” it, along with XSL styles, into readable, styled information in the form of HTML.
You can use Dreamweaver to create XSLT pages that let you perform XSL transformations using an application server
or a browser. In a server-side XSL transformation, the server does the work of transforming the XML and XSL, and
displaying it on the page. In a client-side transformation, a browser (such as Internet Explorer) does the work.

The approach you ultimately take (server-side transformations versus client-side transformations) depends on what
you are trying to achieve as an end result, the technologies available to you, the level of access you have to XML source
files, and other factors. Both approaches have their own benefits and limitations. For example, server-side
transformations work in all browsers while client-side transformations are restricted to modern browsers only (Internet
Explorer 6, Netscape 8, Mozilla 1.8, and Firefox 1.0.2). Server-side transformations let you display XML data
dynamically from your own server or from anywhere else on the web, while client-side transformations must use XML
data that is locally hosted on your own web server. Finally, server-side transformations require that you deploy your
pages to a configured application server, while client-side transformations only require access to a web server.

For a tutorial about understanding XML, see

www.adobe.com/go/vid0165

.

Server-side XSL transformations

Dreamweaver provides methods for creating XSLT pages that let you perform server-side XSL transformations. When
an application server performs the XSL transformation, the file containing the XML data can reside on your own server,
or anywhere else on the web. Additionally, any browser can display the transformed data. Deploying pages for server-
side transformations, however, is somewhat complex, and requires that you have access to an application server.

When working with server-side XSL transformations, you can use Dreamweaver to create XSLT pages that generate full
HTML documents (entire XSLT pages), or XSLT fragments that generate a portion of an HTML document. An entire
XSLT page is similar to a regular HTML page. It contains a tag and a tag, and lets you display a
combination of HTML and XML data on the page. An XSLT fragment is a piece of code, used by a separate document,
that displays formatted XML data. Unlike an entire XSLT page, it is an independent file that contains no or
tag. If you want to display XML data on a page of its own, you would create an entire XSLT page, and bind your
XML data to it. If, on the other hand, you wanted to display XML data in a particular section of an existing dynamic
page—for example, a dynamic home page for a sporting goods store, with sports scores from an RSS feed displayed on
one side of the page—you would create an XSLT fragment and insert a reference to it in the dynamic page. Creating
XSLT fragments, and using them in conjunction with other dynamic pages to display XML data, is the more common
scenario.

The first step in creating these types of pages is to create the XSLT fragment. It is a separate file that contains the layout,
formatting, and so on of the XML data that you eventually want to display in the dynamic page. Once you create the
XSLT fragment, you insert a reference to it in your dynamic page (for example, a PHP or ColdFusion page). The
inserted reference to the fragment works much like an Server Side Include (SSI) — the formatted XML data (the
fragment) resides in a separate file, while in Design view, a placeholder for the fragment appears on the dynamic page
itself. When a browser requests the dynamic page containing the reference to the fragment, the server processes the
included instruction and creates a new document in which the formatted contents of the fragment appear instead of
the placeholder.