The menu experiment

Subject: The menu experiment
From: "Didier PH Martin" <martind@xxxxxxxxxxxxx>
Date: Wed, 27 Jan 1999 14:57:25 -0500
Hi,

My previous posting concerned problems about a script. I'll give you more
info about the experiment I am doing.

Microsoft provides a XSL script on a simple document. That document is a xml
document. What I am trying to do is to have with DSSSL the same kind of
output as I have with XSL to see how we can implement the same output with
two different stylesheet languages. The goal is to write an article about
this experiment and share with others the results. Obviously I'll include as
co-authors all people having helped build the experiment. Now that we have
concrete XSL implementations (and obviously a concrete DSSSL
implementation), we can study how things could be done with both.

I am near having the same thing as with the XSL script but I still can't
include the calories object. The difficulty is to include: " (<calories
object> calories per serving)" at the end of the description object.Note
that a "(" is to be included in the output before the calories object
content, then followed by a literal and then finished by a ")".

So for each food object we have the follwing output objects

DIV
 |__ SPAN
DIV
 |_ SPAN

This should translate by two blocks the first one being a kind of green
(real color) and the second block is the same color as the document
background. The name and the price are in the first block. The description
and the calories in the second.

In this message I provide the desired output, the document, the XSL script
(ou can run it with IE5.x) and the DSSSL script.

Resultant output:
-----------------
<HTML><BODY STYLE="font-family:helvetica,sans
sherif;font-size:12pt;background-color:#EEEEEE">
<DIV STYLE="background-color:teal;color:white;padding:4px"><SPAN
STYLE="font-weight:bold;color:white">Belgian Waffles</SPAN> -
$5.95</DIV><DIV
STYLE="margin-left:20px;margin-bottom:1em;font-size:10pt;">two of our famous
Belgian waffles with plenty of real maple syrup
<SPAN STYLE="font-style:italic">(650 calories per serving)</SPAN></DIV>
<DIV
STYLE="background-color:teal;color:white;padding:4px"><SPANSTYLE="font-weigh
t:bold;color:white">Strawberry Belgian Waffles</SPAN> - >$7.95 </DIV> <DIV
STYLE="margin-left:20px;margin-bottom:1em;font-size:10pt;">light Belgian
waffles covered with strawberries and whipped cream<SPAN
STYLE="font-style:italic">(900 calories per serving)</SPAN></DIV>
<DIV STYLE="background-color:teal;color:white;padding:4px"><SPAN
STYLE="font-weight:bold;color:white">Berry-Berry Belgian Waffles</SPAN> -
$8.95</DIV><DIV
STYLE="margin-left:20px;margin-bottom:1em;font-size:10pt;">light Belgian
waffles covered with an assortment of fresh berries and whipped cream<SPAN
STYLE="font-style:italic">(900 calories per serving)</SPAN></DIV>
<DIV STYLE="background-color:teal;color:white;padding:4px"><SPAN
STYLE="font-weight:bold;color:white">French Toast</SPAN> - $4.50</DIV>
<DIV STYLE="margin-left:20px;margin-bottom:1em;font-size:10pt;">thick slices
made from our homemade sourdough bread<SPAN STYLE="font-style:italic">(950
calories per serving)</SPAN></DIV>
<DIV STYLE="background-color:teal;color:white;padding:4px"><SPAN
STYLE="font-weight:bold;color:white">Homestyle Breakfast</SPAN> -
$6.95</DIV><DIV
STYLE="margin-left:20px;margin-bottom:1em;font-size:10pt;">two eggs, bacon
or sausage, toast, and our ever-popular hash browns</DIV></BODY
></HTML>

The document:
------------
<?xml version='1.0'?>
<?xml:stylesheet type="text/dsssl" href="simple.xsl" format="sgml"?> <-----
replace this for XSL script
<breakfast-menu>
  <food>
    <name>Belgian Waffles</name>
    <price>$5.95</price>
    <description>two of our famous Belgian waffles with plenty of real maple
syrup</description>
    <calories>650</calories>
  </food>
  <food>
    <name>Strawberry Belgian Waffles</name>
    <price>$7.95</price>
    <description>light Belgian waffles covered with strawberries and whipped
cream</description>
    <calories>900</calories>
  </food>
  <food>
    <name>Berry-Berry Belgian Waffles</name>
    <price>$8.95</price>
    <description>light Belgian waffles covered with an assortment of fresh
berries and whipped cream</description>
    <calories>900</calories>
  </food>
  <food>
    <name>French Toast</name>
    <price>$4.50</price>
    <description>thick slices made from our homemade sourdough
bread</description>
    <calories>600</calories>
  </food>
  <food>
    <name>Homestyle Breakfast</name>
    <price>$6.95</price>
    <description>two eggs, bacon or sausage, toast, and our ever-popular
hash browns</description>
    <calories>950</calories>
  </food>
</breakfast-menu>

The XSL script:
---------------
<?xml version="1.0"?>
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
  <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt;
        background-color:#EEEEEE">
    <xsl:for-each select="breakfast-menu/food">
      <DIV STYLE="background-color:teal; color:white; padding:4px">
        <SPAN STYLE="font-weight:bold; color:white"><xsl:value-of
select="name"/></SPAN>
        - <xsl:value-of select="price"/>
      </DIV>
      <DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">
        <xsl:value-of select="description"/>
        <SPAN STYLE="font-style:italic">
          (<xsl:value-of select="calories"/> calories per serving)
        </SPAN>
      </DIV>
    </xsl:for-each>
  </BODY>
</HTML>

the DSSSSL script:
------------------
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">
(declare-flow-object-class element "UNREGISTERED::James Clark//Flow Object
Class::element")
(root
    (make element
	    gi: "HTML"
	    (process-children)))

(element breakfast-menu
    (make element
	  gi: "BODY"
	  attributes: '(("STYLE" "font-family:helvetica,sans
sherif;font-size:12pt;background-color:#EEEEEE"))
        (process-children)))

(element food
	(make display-group
	   (make element
		  gi: "DIV"
		  attributes: '(("STYLE" "background-color:teal;color:white;padding:4px"))
         	 (process-matching-children "name")
		 (literal " - ")
		 (process-matching-children "price"))
	   (process-matching-children "description") ))

(element name
    (make element
	  gi: "SPAN"
	  attributes: '(("STYLE" "font-weight:bold;color:white")) ))

(element price
    (make sequence))

(element description
    (make element
	   gi: "DIV"
	   attributes: '(("STYLE"
"margin-left:20px;margin-bottom:1em;font-size:10pt;")) ))

(element calories
    (make element
	   gi: "SPAN"
	   attributes: '(("STYLE" "font-style:italic"))
	   (literal "calories per serving") ))

Regards

Didier PH Martin
mailto:martind@xxxxxxxxxxxxx
http://www.netfolder.com


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread