| ||
| General Concepts |
Some general concepts of XML/XSL development.
(Specifics about the Nun.Me.Shu framework can be found in the Nun.Me.Shu section) Separation of logic, content and presentation
In most web development technologies (WYSIWYG HTML editors, JSP, ASP, PERL, JAVA servlets, PHP, Python, Storyserver, Coldfusion, etc) the editorial content of a web page, the layout and styling of that content and the business logic that has to be applied to some of the content are somehow mixed together. For instance a JSP file generaly contains both content and layout, and often times also contains business logic. A content editor or a web user interface designer or a programmer all at some point might have to change the same physical file when a web page has to be updated. In the process, a content editor might for instance accidently break some of the programming logic. The fact that people with different roles in the development of a web site have to access the same file is not ideal and prone to lead to errors at some point.In contrast to the above mentioned technologies, building a web site using XML and XSL allows for a clean separation between business logic, content and presentation: Explanation of the above figure: Content (dynamic) can come from several sources (database for instance) and some business logic -say a JAVA program- fetches this content, applies business logic, and transforms it into XML. Other content (static) is stored as XML files. XSL files define the layout for the content, and XML sources are transformed by XSLT into HTML. Style is defined in CSS files and a browser uses these style definitions to present the generated HTML to a web surfer. People with different roles thus have access to different files (that are relevant to them only): content editors access XML files, programmers access JAVA files, interface designers access XSL and CSS files. With a little effort these can be kept completely independent of each other, except for some "interface definitions": the XML generated by JAVA, the XML in static files and the XML-templates in the XSL all need to conform to the same definition; the styles defined in CSS need to conform to the style-tags generated by the XSL; etc. The resulting HTML is always completely generated, untouched by a human editor: changes in a web page are made in the elements that are ultimately transformed in to the HTML. The separation between content and transformation is not enforced by either XML or XSL standards and it is easy to ignore the desired separation. The most common violation of the separation concept is to include text fragments in XSL stylesheets. This is not desirable because this would require content editors to have access to the stylesheets. In the ideal world there are distinct roles that contributors to the development of a web site play (content editor, user interface developer, style designer, graphic designer, application developer, database developer, etc), and each of those roles has access to physical files that do not require access by the other roles: (This table is just an example, based on development in a Java environment; more roles can be defined, and some roles are in reality combined)
Note that the aspect of "logic", the retrieval, manipulation and XML-izing of data from external sources is not handled by a pure XML/XSL framework. However, Cocoon2, an XML/XSL publishing architecture, supports "logic sheets" (XSP files) which interface with application programs in Java to take care of this aspect. Content categories, their XML representation and their XSL transformation
Good XML/XSL design depends on data analysis of content to be displayed. There are basically two categories of content:
<xsl:template match="book">
<b><xsl:value-of select="title"/></b><br/> Author: <xsl:value-of select="author"/> </xsl:template> Non-identifiable elements should be represented in XML by elements that are generic: for instance para for any type of paragraph (be it an introduction, or copyright statement or quote, etc). These types of elements can be transformed in XSLT with "push" (or "recursive-descent") templates, which use <xsl:apply-templates/>. You don't specifically specify what has to be processed, but the stylesheet looks for a matching template for the child elements of the current XML element. For instance, to transform an XML element that contains a generic paragraph, one can instruct the stylesheet to generaly look for and apply templates for any element that occurs within the para element:
<xsl:template match="para">
<xsl:apply-templates/> </xsl:template> With "pull" processing you have specific control over the transformation of each XML element, but consequently you need to define more (complex) templates. With "push" processing, the xsl stylesheet can be kept simple and generic, and most of the templates will be reusable or replaceable. |
This page, and all contents, is Copyright © 2002-
Edward Maesen, San Francisco, CA, USA.
|