XML Europe 2003 logo

Creating Web Based Virtual Publications

Abstract

This paper will describe the creation of web-based publications where the content, residing on disparate servers throughout the world, is composed at runtime using an XML 'template' and XSLT. The publisher can push the assembly of the publication to the client by simply sending the XML 'template' and associated stylesheets. This method also allows authors to maintain and control their own content, having their changes automatically propagate to the appropriate 'virtual' publications as needed.

Keywords


Table of Contents

1. Introduction
2. The Template
2.1. Publication.xml
2.2. Article.xml
3. The Transform
3.1. Publication.xslt
3.2. Article.xslt
4. The Formatting
4.1. Publication.css
4.2. Article.css
5. Applications
5.1. Online Magazine
5.2. Status Reports
6. Conclusion
Biography

1. Introduction

Just as the creation of the Internet facilitated the establishment of virtual organizations and development teams, so does XML facilitate the development of virtual publications. Publication content no longer needs to reside on a single server. An XML based Virtual Publication (VP) can include content, residing on disparate servers throughout the world, composed at runtime in a straightforward manner using XSLT. The servers on which the content resides don't even have to be running compatible software; they simply have to allow http access to the content being published in the VP.

The four major benefits of this method are:

  1. It allows authors to maintain and control their own content. If they make a change, this change automatically propagates to all the appropriate VPs.

  2. The VP can be assembled on clients where the latest browsers are installed. The publisher need only send the XML 'template' and stylesheets to the client for assembly. This pushes the majority of the processing to the client, and therefore reduces the amount of server resources required for each request.

  3. Users can assemble their own personal Virtual Publication.

  4. No complex server-side scripting is necessary.

There are three pairs of files that make this possible. Each pair consists of one file each for the Publication and the Article components that are assembled at runtime:

  1. Publication.xml: The Template. The publisher uses this file to assemble the publication. It includes all the information necessary to locate the various content and determine where and how it is to be presented on the page. This file utilizes aspects of the W3C XLink recommendation in order to facilitate the creation and display of content. Article.xml: There will be one or more of these files that will be pulled into the publication when the template is opened.

  2. Publication.xslt: This is the file that transforms the template into the Virtual Publication. It implements some aspects of XLink, in lieu of current browser support. Article.xslt: This is the file that will transform all the Article.xml files that are pulled into the publication. This stylesheet also implements aspects of the XLink specification.

  3. Publication.css: This stylesheet implements the general look and feel of the VP as a whole as well as determining the position and format of the separate sections. Article.css: All the articles in the VP will use the same stylesheet.

The reason for maintaining separate stylesheet files for the publication as a whole and the components that comprise the publication is to separate the logic needed for each. One can modify either stylesheet without concern for affecting the other.

Because a server is not needed to process these files, users would also have the ability to save the XML and stylesheets to their computers and the publication will be rebuilt, and updated if applicable, each time they open the XML template.

2. The Template

2.1. Publication.xml

Publication.xml is the file that determines what content will be drawn into the publication and where it will be placed. It contains one or more Article elements, each containing the following attributes:

  • priority: This is where the publisher can assign a priority to each of the articles being pulled into the publication. The Publication stylesheets use the value of this attribute to determine where on the page the article is to be displayed as well as other formatting styles.

  • xlink:type: Currently, the only value for xlink:type that the stylesheet implements is "simple".

  • xlink:href: The value of this attribute is a URL pointing to the article.

  • xlink:title: The value of this attribute is the title of the article that the xlink:href attribute points to.

  • xlink:show: This attribute accepts one of three enumerated values: (embed|replace|new). The embed value indicates that the content from the article should be embedded in the result document. The replace value indicates that the content from the article should replace the content of the result document. The new value indicates that the content from the article should be displayed in a new result document.

  • xlink:actuate:This attribute accepts one of two enumerated values: (onLoad|onRequest). The onLoad value indicates that the content from the article should be displayed when the result document is loaded. The onRequest value indicates that the content from the article should only be displayed upon some action by the user.

For the purposes of this application, if an Article element has an xlink:actuate value of "onLoad", then the xlink:show attribute must have a value of "embed". Otherwise,it would result in either the article being the only one displayed (xlink:show="replace") or opening up a second window when the publication is opened (xlink:show="new").

The Article element may also contain a Description element, which may be used to include a description of the article. This will be useful when the xlink:actuate attribute is set to "onRequest"; the user will be able to read the description of the article before deciding whether to 'request' the article or not.

Here is an example of a Publication.xml instance:

          <Publication title="My New Publication" xmlns:xlink="http://www.w3.org/1999/xlink">
            
            <Article priority="3" xlink:type="simple" 
                                  xlink:href="http://www.umassx.edu/VP/Article_C.xml" 
                                  xlink:title="Article C Title"
                                  xlink:show="embed"
                                  xlink:actuate="onLoad"/>
            
            <Article priority="2" xlink:type="simple"
                                  xlink:href="http://www.myplace.net/VP/Article_B.xml"
                                  xlink:title="Article B Title"
                                  xlink:show="embed"
                                  xlink:actuate="onRequest">
              <Description>This is a description of Article B. If you would like to read the article,
                           just click anywhere on this text and it will appear here.</Description>
            </Article>
            
            <Article priority="1" xlink:type="simple"
                                  xlink:href="http://www.yourplace.com.au/Article_A.xml"
                                  xlink:title="Article A Title"
                                  xlink:show="embed"
                                  xlink:actuate="onLoad"/>
            
            <Article priority="4" xlink:type="simple"
                                  xlink:href="http://www.nowhere.org/VP/Article_E.xml"
                                  xlink:title="Article E Title"
                                  xlink:show="new"
                                  xlink:actuate="onRequest">
              <Description>This is a description of Article E. If you would like to read this article,
                           just click anywhere on this text and it will open in a new window.</Description>
            </Article>
          
          </Publication>
        

2.2. Article.xml

Article.xml can be based on any schema you desire, as long as all your articles are instances of the same one and Article.xslt is able to transform them into the desired format.

3. The Transform

3.1. Publication.xslt

This is the file that does all the work. It evaluates the Publication.xml file and creates the XHTML that will be delivered to the users' browser. As might be expected, most of the work is done within a single template, for the Article element.

The first thing it does is create a div element with the value of the class attribute determined by the value of the priority attribute of the Article element.

          <xsl:element name="div">
              <xsl:attribute name="class">Pri<xsl:value-of select='@priority'/></xsl:attribute>
        

This class attribute will then be referenced in Publication.css to determine the position and formatting of the article in the VP.

Next, it evaluates the value of the xlink:actuate attribute to determine whether to include the entire article in the VP as it loads(xlink:actuate="onLoad") or just a link (xlink:actuate="onRequest") that will display the article when activated.

If the article is to be displayed when the VP is loaded, the stylesheet uses the xlink:href attribute to locate the article and the document() method to pull it into the VP.

          <xsl:variable name="Source"><xsl:value-of select='@xlink:href'/></xsl:variable>
          <xsl:variable name="Content" select="document($Source)"/>
          <xsl:apply-templates  select="$Content"/>
        

This code takes advantage of the fact that we 'imported' the Article.xslt into the Publication.xslt using the xsl:import construct. The reason I chose this method of pulling in the Article stylesheet, rather than xsl:include, is because it allows the definitions and template rules in the Publication stylesheet to take precedence over the ones in the Article stylesheet. This will eliminate any unanticipated affects from template rules in the Article stylesheet.

If only a link to the article is to be displayed when the VP is loaded, the stylesheet evaluates the value of the xlink:show attribute to determine the action to perform when the link is activated. If the article only needs to be opened in a new window (xlink:show="new"), or replace the content of the existing window (xlink:show="replace"), we simply create a regular XHTML hyperlink with the value of the Description element becoming the displayed text of the link. We can use the target attribute of the <a> tag to indicate where the article is be opened (target="_blank" to open in a new window or target="_self" to replace the content of the existing window).[1] [1]

          <xsl:when test="@xlink:show='new'">
            <a>
              <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
              <xsl:attribute name="title"><xsl:value-of select="@xlink:title"/></xsl:attribute>
              <xsl:value-of select="Description"/>
            </a>
          </xsl:when>
        

However, if the article is to be embedded in the existing page (xlink:show="embed") we have quite a bit more work to do. First, an XML data island is created with the src attribute set to the value of the xlink:href attribute; this will identify the source of the transformation when the link is activated. Next, we create a div element that contains the hyperlink to the article. This same element will also contain the article itself when the link is activated.

          <xsl:when test="@xlink:show='embed'">
            <xsl:element name="xml">
              <xsl:attribute name="id">Source<xsl:value-of select="@priority"/></xsl:attribute>
              <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
            </xsl:element>
            <div>
              <xsl:attribute name="id">Div<xsl:value-of select="@priority"/></xsl:attribute>
              <a>
                <xsl:attribute name="onClick">call getContent(Div<xsl:value-of select="@priority"/>,Source<xsl:value-of select="@priority"/>)</xsl:attribute>
                <xsl:attribute name="title"><xsl:value-of select="@xlink:title"/></xsl:attribute>
                <xsl:value-of select="Description"/>
              </a>
            </div>
          </xsl:when>
        

The getContent() function called by the onClick event is a script that replaces the hyperlink text with the actual article it references.[2] [2]

          <script TYPE="text/vbscript">
            Function getContent(Target,Source)

              Target.innerHTML = Source.transformNode(Style.xmlDocument)

            End Function
          </script>

          <xml id="Style" src="Stylesheets\Article.xslt"></xml>
        

The Target input to this function is the ID of the div element into which the article will be placed. The Source input is the ID of the XML data island which references the article we wish to display. The function replaces the current contents of the 'Target' <div> with the result of the transformation of the 'Source' xml via the Article.xslt stylesheet.

The stylesheet will then repeat this process for each Article element contained in the Publication.xml file.

3.2. Article.xslt

This is the file that transforms the content of Article.xml into the desired format to be displayed within the Virtual Publication. You can use any stylesheet that is designed to transform the Article.xml file you are using. The Virtual Publication gains access to this file via the <xsl:import href="Article.xslt"/> statement in the Publication stylesheet. The Article stylesheet should be designed to take into account that Publication.xslt will provide all the necessary XHTML opening code.

4. The Formatting

4.1. Publication.css

This file handles the formatting for the Publication as a whole, rather than the individual articles. Its most important function is to define the location and general look and feel of the Articles included in the Publication. It does this by declaring a style block for each of the classes assigned to the div elements that contain the Articles.

          .Pri1{
              font-size: 12pt;
              background-color: #CCFFFF;
              position: fixed;
              width: 100%;
              border: thick;
              border-style: groove;
          }
          .Pri2{
              font-size: 10pt;
              background-color: #CDCCFF;
              position: absolute;
              width: 50%;
              border:thin;
              border-style: groove;
          }
          .Pri3{
              font-size: 10pt;
              background-color: #FFCCFE;
              position: absolute;
              left: 50%;
              width: 50%;
              border:thin;
              border-style: groove;
          }
        

The article that was given a priority of '1' in the Publication.xml file is placed at the top of the window and spans its entire width. It is also assigned a larger default font size than the other articles. The articles given a priority of '2' and '3' are placed below the 'main' article, side by side, each taking up 50% of the width of the window. The other articles can be placed in a similar fashion.[3] [3] Each article is also given a different background color.

4.2. Article.css

This stylesheet, like the Article.xslt stylesheet, is simply used to define the style and formatting of the individual articles. Any appropriate stylesheet can be used and can be plugged in via the style element produced in the Publication.xslt file.

          <style type="text/css">
            @import url(Stylesheets/Publication.css);
            @import url(Stylesheets/Article.css);
          </style>
        

5. Applications

This method can be useful in any situation where there is a need to gather information from numerous sources. An interface can be created so the XML template can be edited by a user unfamiliar with XML. They can simply choose the items they want to see from a list of available content and assign a 'priority' to each one. They can then view a custom publication tailored to their immediate needs.

5.1. Online Magazine

Elements representing monthly columns need never be altered. The content is automatically updated when the new column is submitted. As far as the author is concerned, submitting the article may only consist of replacing the previous article on his own server. Authors retain complete control of their own content.

5.2. Status Reports

A department head can get up-to-the-minute status reports of any project or combination of projects. Each Project Manager is responsible for his own status report which can reside on any computer, in any directory, that the Department Head has read access to. Whenever the Project Manager needs to update something in his report, he simply edits the copy on his machine and, the next time the Depatment Head opens her 'template', she will have the latest update.

6. Conclusion

I've only listed a couple of the potential uses of this system; however, it is easily adaptable to many situations. You can easily plug in any content and stylesheets you want to replace the Article files. Even the way the VP is delivered is flexible:

  • You can assemble the VP on a server and deliver straight XHTML to the users' browser.

  • You can deliver the Publication.xml file to the users, and the VP gets assembled on their computers and minimizes resource usage on the server.

  • The users can save the 'Template' on their own computers and will be able to see the latest content whenever they open it.

  • You can create an application that acts as an interface to the 'Template' and let the users select items from a list that they want displayed in their own personal VP.

However you choose to implement it, it will give you, your authors, and your users more flexibility then ever before.

Biography

Computer Scientist
»Newport, Rhode Island
»USA

Michael is a Computer Scientist for the United States Navy and a member of the US Department of the Navy (DON) XML Work Group. As such, he is involved in the development of XML related policy, procedures and guidance for the DON. He is also the DON representative to the Organization for the Advancement of Structured Information Standards (OASIS) Universal Business Language (UBL) Technical Committee and participates in the Naming and Design Rules Subcommittee (NDR SC).

Michael's areas of focus are XML based Interactive Electronic Technical Manuals (IETMs) and Interactive Electronic Procedures (IEPs). He has presented several times on these topics and has developed the Navy's first XML based IEP.



[1] If you use this method, keep in mind that the XHTML Strict DTD does not support the target attribute.

[2] XML data islands and VBSript are Microsoft extensions and, therefore, require Internet Explorer.

[3] If we wanted to have more than one page to our publication, we would have to create some XHTML templates to be used as wrappers for each of the pages.