Corrections by Chapter
Chapter 1
Page 7, example 1 (Ch. 1)
Action should be "/result", not "/results"
| Revised example: | <FORM action="/result">
First: <INPUT name="fname" value="Mike"/> <BR/>
Last: <INPUT name="lname" value="Plusch"/>
<INPUT type="submit" value="Go"/>
</FORM> |
| Example in book (incorrect): | <FORM action="/results">
First: <INPUT name="fname" value="Mike"/> <BR/>
Last: <INPUT name="lname" value="Plusch"/>
<INPUT type="submit" value="Go"/>
</FORM> |
Page 7, example 4 (Ch. 1)
Action can be the symbol result, although the string '/result' will also work. The 'to_html_attr' method
converts an object into a URI string.
| Revised example: | <defmethod registration fname="Mike"=string lname="Plusch"=string>
<FORM action=result>
First: <INPUT name="fname" value=fname/> <BR/>
Last: <INPUT name="lname" value=lname/>
<INPUT type="submit" value="Go"/>
</FORM>
</defmethod> |
| Example in book (incorrect): | <defmethod registration fname="Mike"=string lname="Plusch"=string>
<FORM action="/result">
First: <INPUT name="fname" value=fname/> <BR/>
Last: <INPUT name="lname" value=lname/>
<INPUT type="submit" value="Go"/>
</FORM>
</defmethod> |
Page 8, example 5 (Ch. 1)
HTML should be BODY because in the XHTML
standard, HTML does not permit any content except for the tags
of BODY or HEAD. Although a valid XHTML file must start with an
HTML tag, BODY works fine in most browsers.
| Revised example: | <defmethod result fname lname>
<BODY>
<do fname/> <do lname/> has been registered.
</BODY>
</defmethod> |
| Example in book (incorrect): | <defmethod result fname lname>
<HTML>
<do fname/> <do lname/> has been registered.
</HTML>
</defmethod> |
Page 9, example 1 (Ch. 1)
The URI needed a file extension (xml). When accessing an object through a URI, the format for the response
is indicated though the file extension. If there is no file extension,
then it assumes '.htm'. By default, a generic object does not
have an HTML presentation defined on it, therefore the request
returned an empty string.
| Revised example: | <defclass point x y/>
<defmethod get_point>
<vector>
<point x=5 y=10/>
<point x=3 y=3/>
</vector>
</defmethod>
<web "http://localhost/get_point.xml?"/>.content |
| Example in book (incorrect): | <defclass point x y/>
<defmethod get_point>
<vector>
<point x=5 y=10/>
<point x=3 y=3/>
</vector>
</defmethod>
<web "http://localhost/get_point?"/>.content |
Chapter 2
Page 19, example 2 (Ch. 2)
This is a better example to show how the tagname can be any expression including
a local variable. "some_text" was changed to "editable". INPUT was changed to DIV.
| Revised example: | <set editable=true/>
<set text_region=
<if> editable
hypertext.TEXTAREA
else
hypertext.DIV
</if>
/>
<text_region>testing</> |
| Example in book (incorrect): | <set some_text="testing"/>
<set text_input=
<if> some_text.<more 30/>
hypertext.TEXTAREA
else
hypertext.INPUT
</if>
/>
<text_input 0=some_text/> |
Page 20, example 2 (Ch. 2)
Definitions for 'list' and 'item' were added.
This example shows a ConciseXML and XML 1.0 representation for
the same object. The change makes it possible to execute the example
without error.
| Revised example: | <defclass list rest=true/>
<defclass item name/>
<list <item name="bread"/> <item name="milk"/> /> |
| Example in book (incorrect): | <list <item name="bread"/> <item name="milk"/> /> |
Chapter 3
Page 25, example 1 (Ch. 3)
Added basic Water Contracts for purchase_order and line_item so that
the example could execute.
| Revised example: | <defclass purchase_order/> <defclass line_item/>
<purchase_order
po_number="1001"
line_items=<vector>
<line_item line=1 item="soap" quantity=2/>
<line_item line=2 item="ice" quantity=3/>
</>
/> |
Page 26, example 3 (Ch. 3)
Added simple class (Water Contract) for employee so that
the example could be executed.
| Revised example: | <defclass employee/>
<set employee_bob=<employee name="Bob"/> />
employee_bob.<set manager=employee_bob/>.manager.name |
Page 29, example 3 (Ch. 3)
_promote is not yet supported. See online
documentation of 'rest' for the current supported solution.
| Revised example: | <defclass grocery_list rest/>
<grocery_list
"apple"
"milk"
"pears"
/> |
| Example in book (incorrect): | <defclass grocery_list _promote='other_unkeyed_args'/>
<grocery_list
"apple"
"milk"
"pears"
/> |
Page 30, example 1 (Ch. 3)
Simple class definitions were added so that the example
can be executed.
| Revised example: | <defclass grocery_item/>
<defclass grocery_list rest/>
<defclass gallon value/>
<grocery_list
"apple"
<grocery_item name="milk" quantity=<gallon 2/> />
<grocery_item name="apple" quantity=2 />
/> |
Chapter 4
Page 36, example 3 (Ch. 4)
Call to 'set' was not properly closed.
| Revised example: | <set uppercase=type.<one_of <char "A"/> <char "B"/> <char "C"/> /> />
<thing last_name="AC"=type.<vector_of uppercase min=2 max=15/> /> |
| Example in book (incorrect): | <set uppercase=type.<one_of <char "A"/> <char "B"/> <char "C"/> />
<thing last_name="AC"=type.<vector_of uppercase min=2 max=15/> /> /> |
Page 37, example 4 (Ch. 4)
Water 3 uses '_subject' in place of 'this'.
The _subject is implied if you just use a single leading dot.
| Revised example: | <defmethod carry_on_luggage>
_subject.girth.<less 40/>.<and _subject.weight.<less 25/> />
</defmethod>
type.<call_method_of carry_on_luggage/>.
<is_type_for <thing girth=20 weight=10/> /> |
| Example in book (incorrect): | <defmethod carry_on_luggage>
this.girth.<less 40/>.<and this.weight.<less 25/> />
</defmethod>
type.<call_method_of carry_on_luggage/>.
<is_type_for <thing girth=20 weight=10/> /> |
Chapter 5
Page 45, example 1 (Ch. 5)
'other_unkeyed_args' is not yet supported. Use 'rest' instead.
| Revised example: | <defclass grocery_list store_name=required
rest />
<defclass grocery_item name=required quantity=1/>
<grocery_list
store_name="Acme Foods"
"apple"
<grocery_item name="milk"/>
<grocery_item name="pears" quantity=3/>
/> |
| Example in book (incorrect): | <defclass grocery_list store_name=required
items='other_unkeyed_args' />
<defclass grocery_item name=required quantity=1/>
<grocery_list
store_name="Acme Foods"
"apple"
<grocery_item name="milk"/>
<grocery_item name="pears" quantity=3/>
/> |
Page 46, example 3 (Ch. 5)
Changed 'defmethod' to 'defclass'. The use of 'other_keyed_args' is not yet supported.
| Revised example: | <defclass foo other_named_args=true/>
<foo yak="yum"/>.yak |
| Example in book (incorrect): | <defmethod foo misc=optional=other_keyed_args/>
<foo yak="yum"/>.misc |
Page 47, example 1 (Ch. 5)
Changed 'defmethod' to 'defclass'. The use of '_promote' and 'other_keyed_args' is not yet supported.
See on-line documentation for the description of 'other_named_args'.
| Revised example: | <defclass foo other_named_args=true/>
<foo yak="yum"/> |
| Example in book (incorrect): | <defmethod foo _promote=optional=other_keyed_args/>
<foo yak="yum"/> |
Page 48, example 1 (Ch. 5)
'_precond' and '_postcond' are not yet supported.
| Revised example: | <defmethod delete_my_database
_precond=<defmethod> thing.<has_key my_database/> </>
_postcond=<defmethod> thing.<has_key my_database/>.<not/> </>
/>
<defmethod increment_global_count_field
_precond=<defmethod>
thing.<has_key "count"/>.<and args.count.<more 0/> />
</defmethod>
_postcond=<defmethod>
_args.count.<is count.<minus 1/> />
</defmethod>
/>
<defmethod add_customer/>.
<doc
precond="customer has never had an account"
postcond="a single account exists for that customer"
/> |
Chapter 6
Page 50, example 6 (Ch. 6)
Any reference to 'starting_object' should be 'a_starting_object'.
This occurs in a number of examples in this chapter.
| Revised example: | a_starting_object."0" |
| Example in book (incorrect): | starting_object."0" |
Page 52, example 4 (Ch. 6)
'get_with_value' is not yet supported.
There are several examples that use it in this chapter.
| Revised example: | <set a_starting_object=
<thing a_field=<thing foo="bar"/>
b_field=100
0=<vector "water" "ice"/>
1=<thing x=5 y=10 foo="bar"/>
/>
/>
a_starting_object.<get_with_value "foo" "bar"/> |
Page 54, example 3 (Ch. 6)
'starting_object' should be 'a_starting_object'.
The 'include_value' argument is not yet supported. Use returns='all_except_null'
and an 'if' statement to achieve the same result.
| Revised example: | <set a_starting_object=
<thing a_field=<thing foo="bar"/>
b_field=100
0=<vector "water" "ice"/>
1=<thing x=5 y=10 foo="bar"/>
/>
/>
<defmethod foo_starts_with_ba>
.<has_key "foo"/>.<and .foo.<starts_with "ba"/> />
</defmethod>
a_starting_object.
<for_each returns='all_except_null'>
<if> value.<foo_starts_with_ba/>
value
</if>
</for_each> |
| Example in book (incorrect): | <set a_starting_object=
<thing a_field=<thing foo="bar"/>
b_field=100
0=<vector "water" "ice"/>
1=<thing x=5 y=10 foo="bar"/>
/>
/>
<defmethod foo_starts_with_ba>
.foo.<starts_with "ba"/>
</defmethod>
starting_object.<for_each include_value=foo_starts_with_ba returns='all'> value </for_each> |
Page 55, example 3 (Ch. 6)
'starting_object' should be 'a_starting_object'.
'include_key' should be 'include'.
| Revised example: | <set a_starting_object=
<thing a_field=<thing foo="bar"/>
b_field=100
0=<vector "water" "ice"/>
1=<thing x=5 y=10 foo="bar"/>
/>
/>
a_starting_object.<for_each include=vector_key returns='all'> value </for_each> |
| Example in book (incorrect): | <set a_starting_object=
<thing a_field=<thing foo="bar"/>
b_field=100
0=<vector "water" "ice"/>
1=<thing x=5 y=10 foo="bar"/>
/>
/>
starting_object.<for_each include_key=vector_key returns='all'> value </for_each>.<to_concise_xml/> |
Chapter 43
Page 352, example 1 (Ch. 43)
| Revised example: | <defclass faq
question=""
answer=""
storage=filesystem.<file "C:/faqs.h2o"/>
>
<set N=_new_object/> <!-- _new_object is faq here -->
N.<set edit=
<active_value>
<FORM action="/add">
Question: <INPUT name="question" size=50/><BR/>
Answer: <TEXTAREA name="answer" cols=50 rows=5/>
<INPUT type="submit" value="Add FAQ"/>
<P><A href="/">Show all FAQs</A></P>
<do .<last/> />
</FORM>
</active_value>
/>
<defmethod ui_detail alert_msg=optional>
<if> defclass.<is_type_for _subject/>
<BODY>
<H2>Frequently Asked Questions (FAQ's)</>
<P>Total of <do .<length/> /> entries.</P>
<do .<for_each include=vector_key returns='all'> value </> />
<P><A href="/edit">Add FAQ</></>
<P><A href="/save?">Save to disk</></>
<do alert_msg/>
</BODY>
else
<hypertext>
<DIV><B>Q:</B> <do .question/> </DIV>
<DIV><B>A:</B> <do .answer/> </DIV>
<BR/>
</hypertext>
</if>
</defmethod>
<defmethod add question answer>
<faq question answer/>
.edit
</defmethod>
<defmethod save>
<set the_faqs=""/>
.<for_each include=vector_key>
<set the_faqs=the_faqs.<concat value.<to_concise_xml/> /> />
</for_each>
.storage.<set content=the_faqs/>
.<ui_detail
alert_msg=<P><do .<length/> /> records saved in <do .storage/>
on <do datetime.current/>
</P>
/>
</defmethod>
<defmethod init>
<set N=_new_object/>
N._parent.<insert N/>
N
</defmethod>
<defmethod to_html>
.<ui_detail/>.<to_html/>
</defmethod>
<if> N.storage.<exists/>
N.storage.<execute/>
else
<do>
<faq "What's MPH?" "Miles per Hour" />
<faq "What's KPH?" "Kilometers per Hour" />
</do>
</if>
</defclass>
<server faq/>
<open_browser_window "http://localhost"/> |