This week's SAS tip comes from Frederick Pratter and his book Web Development with SAS by Example, Third Edition. Frederick's book contains a wealth of good information, including the following excerpt.
The following excerpt is from SAS Press author Frederick Pratter and his book "Web Development with SAS by Example, Third Edition" Copyright © 2011, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software).
Formatting XML Documents
There is one more topic that is important for an understanding of how XML can be used, one that allows the introduction of two more acronyms—CSS and XSL. Cascading Style Sheets (CSS) were introduced in HTML 4.0 to specify document formatting. Style tags define how HTML elements are displayed. In this way, they are an extension of the <font> tag and color= attribute in earlier HTML versions.
While styles can be included in the document, it is customary to save the styles in external files. In this way, a common “look and feel” can be maintained across a Web site. If all of the developers use a common set of style sheets, it is possible to change the appearance and format of all the pages in the site just by editing a single CSS document. (They are called “cascading” because if more than one style sheet is used, each successive style definition will add new values and override values previously defined.)
Microsoft Internet Explorer and Firefox both come with a built-in style sheet that can be used to display XML as a tree structure. In order to view XML as anything other than the browser default, a link statement needs to be added to the XML, pointing to a custom style sheet for that site. (Note that Firefox displays a warning message indicating that it is using the default style for displaying the page):
Although it is certainly possible to use CSS for displaying XML, it usually does not work very well. If you want more control over how the document is displayed, it is possible to use XSL, the Extensible Style sheet Language. This is a style sheet language specifically developed for formatting XML for display.
XSL is generally conceded to be a lot of bother for very little marginal improvement over what you can do with CSS. The XSL transformation language (XSLT) on the other hand, has been widely adopted and continues to be a focus of considerable developer interest. XSLT is used, just like it sounds, to transform an XML document into something else, such as a different XML document, HTML, or even CSV. What is more, XSLT can filter and sort XML, address parts of an XML document, and output XML to different devices. SAS XML Maps are based on the XSL style sheet language.
For more information about Frederick Pratter (including a free chapter from his book), visit his author page. You can also view two previously featured excerpts from Web Development with SAS by Example, Third Edition on this blog: Configuring TCP security and SQL pass-through.