At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search

Visualizing SAPI Grammar Using XSLT

Recently, I wanted a way to visualize large SAPI grammar files in a slightly easier way than using Microsoft Internet Explorer's default XML viewing capability. The obvious solution to me seemed to be to write a XSL stylesheet to convert the grammar into pretty HTML. Therefore, I set out trying my hand at producing a XSL stylesheet, and sure enough, 3 hours later, I had something that produced relatively nice results. The features are as follows:

  • Displays rules as boxes.
  • Toplevel rules are bolded, all rules have their numerical ID displayed beside them.
  • Rule references are hyperlinked.
  • Optional text is greyed out.
  • Lists are listed in an easy to read form. <P> items are listed with their values both in string and numerical form. Rulerefs are linked, and have their PROPID and PROPID values listed.
I think the following before/after screenshots testify to the power of the stylesheet:



Usage

Using the stylesheet is very simple to do. Open up your grammar file, and add the following lines at the very top:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" 
  href="http://www.generation5.org/data/xml/sapi2html.xsl"?>
Open up your grammar file and hopefully things will look a lot neater. Alternatively, you can download sapi2html.xsl as a local copy and modify it as you wish. Using the hyperlinked version means you don't need to copy the file between projects, and ensures you always have the most up-to-date version formatting your SAPI grammar.

History

5.4.03 v0.9 A few bugs fixed, and a few additional features added. Now recognizes both P and PHRASE, L and LIST, O and OPT. The stylesheet also formats some additional TITLE tags so that tooltips popup with additional phrase information (Min, Max, Propname attributes). The embedded RULEREF issue is now fixed too.

Last Updated: 04/05/2003

Article content copyright © James Matthews, 2003.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -