deutsche Version
 

 

 

 

 

Putting XML to work: Scalable Vector Graphics

Michael Champion
Senior R&D Advisor, Software AG

 

About the Author: Michael Champion is a member of the W3C's Document Object Model Working Group and co-editor of the core XML portion of the DOM Level 1 recommendation. Champion is currently a senior R&D advisor for new technologies at Software AG.

Many of the recent developments in the XML world have been focused on the "back office," that is, on the exchange of data between applications, across enterprises, or throughout a trading community. SVG, or "Scalar Vector Graphics," is an XML format for drawings and for images that is just as significant for the multinational corporation as it is for the ordinary Web user. In combination with an XML database, SVG can be used to build "industrial strength" applications that have appealing and useful visual content.

SVG advantages

SVG is a language that describes two-dimensional graphical objects in XML. Such objects may include lines, polygons, circles, ellipses, as well as text and bitmapped images. SVG graphic types include text, and XSLT can transform XML documents into SVG output. SVG works with the CSS stylesheet standard to define the color and layout of these objects, and has a set of extensions to the standard DOM API that allows the objects to be manipulated by programs and scripts.

This provides the Web developer and user a number of advantages over today’s HTML and bitmap graphics (JPEG, GIF, PNG) technology:

  • Speed and Scalability – The complete Web page, including graphics, can be stored in a single, relatively small file rather than having the HTML page reference multiple external image files. This shortens download times and allows the display device (a Web browser on a PC, a handheld computer, or even a mobile phone) to scale the image appropriately.
  • Improved display and print quality – SVG has been developed with substantial input from companies such as Adobe and incorporates many of the ideas of Postscript and PDF. For example, SVG can be used to draw fonts that are not installed on the target device.
  • Advanced graphics features – SVG tools have built-in capabilities for panning, zooming, clipping, animating, and transforming images
  • All the usual advantages of XML – vendor-neutral, platform-neutral, common interchange format that is almost universally supported.
  • Separation of form from content – SVG images can be treated as data by generic XML applications; the text descriptions and labels can be indexed, searched and transformed by applications that know nothing about the graphical representation of the data. For example, a time inside a SVG image of a clock or a street address inside a SVG image of a map might be extracted and used by a personal information manager program.

Currently SVG is supported by standalone applications (such as drawing and imaging programs) and browser plug-ins (which support it much as PDF is supported). The major browser vendors have promised "native" SVG support soon, and this will allow SVG data to be freely intermixed with HTML/XHTML data to realize the full advantages of SVG.

SVG in action

SVG images are XML text, so, by storing them in a native XML database (such as Software AG’s Tamino), one can query for SVG files by their own attributes and element values rather than maintaining a separate metadata store. For example, one can look for SVG maps that contain specific text, such as street names, directly off the XML content using an XML query language such as XQL or XPath.

Existing databases and file systems can easily store images as binary large objects (BLOBs). With Tamino, the content of an SVG image to be treated as an XML document that can be queried and whose hierarchical structure can be navigated and manipulated at the generic XML level without specialized knowledge of the image format. In other words, SVG data stored in a true XML database does not need pre-processing or hand coding to define the searchable "metadata." The actual descriptive data and text labels on the graphic data can be searched. This would make SVG a "killer app" for a database like Tamino because it would radically simplify the development of sites that combine geographic and other data, especially for mobile users.

Tamino’s native XML support makes it easy to develop Web applications by including standards-based tools. Tamino queries return data in XML format, which allows a Web developer to use XSLT or simple DOM scripts to transform the data into SVG format for graphical display. Thus it is easy to produce attractive and readable graphical displays of numerical data extracted from Tamino.

For example, in a project to integrate patient data from different data sources into a common XML database, Dr. Walter Fierz of the University of St. Gallen and the Swiss HIV Cohort Study uses the combination of an SVG "template" file and some JavaScript to produce bar charts and line graphs to visually display XML-encoded laboratory data for a patient. This allows a clinician or epidemiologist to see an image of the values of various tests plotted over time, simplifying the task of interpreting their significance.

Further reading:

http://www.webdeveloper.com/design/design_svg_intro.html
http://wdvl.internet.com/Authoring/Languages/XML/SVG/DoingIt/index.html
http://www.zdnet.de/internet/artikel/html/200004/svg_00-wc.html (German)