
 
for SVG documents style by CSS style sheets. As a 
consequence, its CSS engine is specifically 
optimized to be used within SVG applications (e.g., 
it gives priority of computation to those CSS 
properties that are most used within SVG 
documents). Anyway, also in this case, the 
“optimization algorithm” could be added without 
modifying the existing optimizations.     
7  CONCLUSIONS 
In this paper, implementation of an optimized CSS 
engine was discussed. 
It can be used for every XML applications that 
need to adapt the layout of their Web services 
depending on different devices that often have 
limited environments.   
The focus was on an optimization algorithm that 
reduces memory and time consumption to process 
CSS documents. The idea for the optimization was 
that usually in a XML document, many elements 
match the same set of CSS style rules, so the final 
set of CSS style properties can be cached and 
shared, and not recalculated every time. This 
algorithm is based on a search tree data structure of 
matched CSS style rules. It was described both with 
flow charts and general classes’ objects, in order to 
emphasize the algorithm processes independently of 
the implementation chosen.     
This algorithm allows three levels of 
optimization (cf. Section 3.2.2); two are intrinsic in 
the CSS engine and in its structure and one 
depending on the XML applications' layout engines. 
Based on the optimizing algorithm, the CSS 
engine was implemented in a real environment, 
using Java as programming language. To evaluate 
such optimization, a browser was used, that supports 
many XML languages such as XHTML, SVG, 
XForms and SMIL. In order to enable a 
straightforward integration, the CSS parser exposes 
the CSS data through standards interfaces (i.e., 
CSSOM and SAC).     
Considering the innumerable factors that could 
be taken in account, no minimum threshold of 
performances requirements were defined. For the 
tests we used common well formatted XML 
documents styled with CSS style sheets found at site 
“CSS Zen Garden”. The optimization results are 
remarkable: measurements show that with largest 
document used, the optimized CSS engine can be 
45% faster and spare 85% of the memory.  
REFERENCES 
Apparao, V. et al., 1998. Document Object Model (DOM) 
level 1 specification – version 1.0, W3C 
Recommendation. 
Ayars, J. et al., 2001.Synchronized Multimedia Integration 
Language (SMIL 2.0), W3C Recommendation. 
Baron , D., 2005. Mozilla Style System Documentation 
available online at 
http://www.mozilla.org/newlayout/doc/style-
system.html.  
Bos, B. et al., 1998. Cascading Style Sheets, level 2 CSS2 
Specification, W3C Recommendation. 
Bos, B. et al., 2000. SAC: Simple API for CSS,” W3C 
Note. 
Bos, B. et al., 2005. CSS Level 3, available 
http://www.w3.org/Style/CSS/current-work. 
Didier, M., 2000.  A Family Affair, O'Reilly XML.com. 
Dubinko, M. at al., 2003. XForms 1.0, W3C 
Recommendation. 
Ferraiolo, J., 2001. Scalable Vector Graphics (SVG) 1.0 
Specification, W3C Recommendation. 
Glazman, D. et al., 2002. Media Queries, W3C Candidate 
Recommendation. 
Jacobs, I., 2005. About the World Wide Web Consortium 
(W3C) available online at 
http://www.w3.org/Consortium/, referred Jun. 2005 
Javacc Project home, 2005, available at 
https://javacc.dev.java.net/. 
Konqueror, 2005. available at http://www.konqueror.org 
LOOKAHEAD MiniTutorial, 2005, available at 
https://javacc.dev.java.net/doc/lookahead.html. 
Pemberton, S. et al., 2002. XHTML™ 1.0 The Extensible 
HyperText Markup Language (Second Edition), W3C 
Recommendation. 
The Apache Software Foundation, 2005, Squiggle the 
SVG browser, available at 
http://xml.apache.org/batik/svgviewer.html 
Schweinsberg, D., 2004. CSS Parser, available at 
http://cssparser.sourceforge.net. 
Vuorimaa, P. et al., 2002. A Java based XML browser for 
consumer devices. In the 17th ACM Symposium on 
Applied Computing, Madrid, Spain. 
Wilson, C. et al., 2000. Document Object Model (DOM) 
Level 2 Style Specification Version 1.0, W3C 
Recommendation. 
Wolter , R., 2001. XML Web Services Basics, Microsoft 
Corporation. 
Yergeau, F. et al., 2004. Extensible Markup Language 
(XML) 1.0 (Third Edition) W3C Recommendation. 
 
 
 
 
 
 
 
OPTIMIZED CSS ENGINE
213