beautypg.com

Adobe Dreamweaver CC 2015 User Manual

Page 515

background image

508

XML

Last updated 6/3/2015

First, create an entire XSLT page and attach an XML data source. (Dreamweaver prompts you to attach the data source
when you create the new page.) You can create an XSLT page from scratch, or you can convert an existing HTML page
to an XSLT page. When you convert an existing HTML page to an XSLT page you must attach an XML data source
using the Bindings panel (Window > Bindings).

After you’ve created your XSLT page, you must link it to the XML file containing the XML data by inserting a reference
to the XSLT page in the XML file itself (much like you would insert a reference to an external CSS style sheet in the
section of an HTML page). Your site visitors must view the XML file (not the XSLT page) in a browser. When
your site visitors view the page, the browser performs the XSL transformation and displays the XML data, formatted by
the linked XSLT page.

The relationship between the linked XSLT and XML pages is conceptually similar, yet different from the external
CSS/HTML page model. When you have an HTML page that contains content (such as text), you use an external style
sheet to format that content. The HTML page determines the content, and the external CSS code, which the user never
sees, determines the presentation. With XSLT and XML, the situation is reversed. The XML file (which the user never
sees in its raw form), determines the content while the XSLT page determines the presentation. The XSLT page contains
the tables, layout, graphics, and so forth that the standard HTML usually contains. When a user views the XML file in
a browser, the XSLT page formats the content.

A Browser requests XML file B Server responds by sending XML file to browser C Browser reads XML directive and calls XSLT file D Server
sends XSLT file to browser

E Browser transforms XML data and displays it in browser

When you use Dreamweaver to link an XSLT page to an XML page, Dreamweaver inserts the appropriate code for you
at the top of the XML page. If you own the XML page to which you’re linking (that is, if the XML file exclusively lives
on your web server), all you need to do is use Dreamweaver to insert the appropriate code that links the two pages.
When you own the XML file, the XSL transformations performed by the client are fully dynamic. That is, whenever you
update the data in the XML file, any HTML output using the linked XSLT page will be automatically updated with the
new information.

Note: The XML and XSL files you use for client-side transformations must reside in the same directory. If they don’t, the
browser will read the XML file and find the XSLT page for the transformation, but will fail to find assets (style sheets,
images, and so on) defined by relative links in the XSLT page.