table of contents
wax(4) | AFNIX Service | wax(4) |
NAME¶
wax - web application extension serviceWEB APPLICATION EXTENSION SERVICE¶
The Web Application Extension service is an original implementation that provides the support for low level HTTP transaction as well as high level XHTML page generation. The service combines various modules and provides access to the modern generation of web contents. Page service objects# create a new xhtml page const page (afnix:wax:XhtmlRoot "AFNIX wax service") # get the head node const head (page:get-head) # get the body node const body (page:get-body)The head and body nodes are part of the html node which is automatically instantiated as a XhtmlHtml object. The html node can always be retrieved from the root node with the get-child xml method. The root methods get-head and get-body are convenient methods that ease the page design by eliminating the references to the html node.
# create a new xhtml page const page (afnix:wax:XhtmlRoot "AFNIX wax service") # get the html node const html (page:get-child "html") # get the head node const head (html:get-head) # get the body node const body (html:get-body)Page header
# add a meta tag head:add-meta "copyright" "© 2000" # add a style path head:add-style "/style.css"The add-meta method adds a XhtmlMeta object which is a xml tag node. The first argument is the meta descriptor while the second argument is the meta content. Note that the add-meta method can be simulated by calling the XhtmlMeta constructor and then adding the node to the head node.
# create a meta node const node (afnix:wax:XhtmlMeta "copyright" "© 2012") # add the node to the head head:add nodeThe add-style method adds a XhtmlStyle object which is a xml tag node. The string argument is the url style sheet path which gets automatically transformed to the form @import(url). Note that the add-style method can be simulated by calling the XhtmlStyle constructor and then adding the node to the head node.
# create a style node const node (afnix:wax:XhtmlStyle "/style.css") # add the node to the head head:add nodePage body
# create a new xhtml page const page (afnix:wax:XhtmlRoot "AFNIX wax service") # get the body node const body (page:get-body) # add a node body:add-child nodePage emission
# create a new xhtml page const page (afnix:wax:XhtmlRoot "AFNIX wax service") # write to the output stream page:writeAnother mechanism for writing the page is to use the fact that the XhtmlRoot class implements also the Mime interface. With this in mind, the XhtmlRoot can be used within the HttpReply. This method is particularly useful when writing automated page generation, such like CGI scripts.
# create a new xhtml page const page (afnix:wax:XhtmlRoot "AFNIX wax service") # create an http reply object const reply (afnix:wax:HttpReply) # write the page as a mime object reply:add-buffer page # write the result to the output reply:writePage design objects
# add a comment to the body node body:add-child ( afnix:xml:XmlComment "this is a comment")Node style class
# create a xhtml div with a class attribute const div (afnix:wax:XhtmlDiv "nice") # create a xhtml div and set the class manually const div (afnix:wax:XhtmlDiv) div:set-attribute "class" "nice"Adding text paragraph
# add a text with some piece in italic node:parse "this is a <i>simple</i> method"The XhtmlPara node is the preferred node for adding text to a xhtml page. The node takes optionally the style name in the constructor. A boolean flag can also be used to create an empty paragraph node.
# create a paragraph node with a style const p (afnix:wax:XhtmlPara "title") # add some text p:parse "the paragraph text"Adding reference
# create a hyperlink const node ( afnix:wax:XhtmlRef "http://www.afnix.org" "afnix") # add the node in a paragraph p:add-child nodeFormatting elements
# create a div element const div (afnix:wax:XhtmlDiv "menu") # create a ruler element const hr (afnix:wax:XhtmlHr)Managing table
# create an element with a default tr and th/td style const tbl (afnix:wax:XhtmlTable "text" "text" "text") # get a new row with a default style const tr (tbl:new-row)In the previous example, a table is created with a default style for the table row. When a new row is created, the default style is used for that row. If there is no default style, the row is created without a style. Note that the new-row method takes also a style argument that overwrites the default one. Building the table
# get a new row with a default style trans tr (tbl:new-row) # create a row directly trans tr (afnix:wax:XhtmlTr "text")When a row has been created, the data can be added to the row. Normally, the new-data method is used to create a new table data element. If a default style is defined in the table row, the table data element is built with that style. The new-head method can also be used to create table header element. Again, if a default table header style exists in the table row, the element is built with that style. The XhtmlTd class is the table data class and the XhtmlTh class is the table header class.
# get a new data element trans td (tr:new-data) # create new head element trans th (tr:new-head)When the table data node has been created, the parse method or the add-child method can be called to add other nodes. another method for building the table is to use the add-table method which uses a print table object. In such case, the table rows and data elements are automatically added in the table. The table structure
# create a xhtml table const table (afnix:wax:XhtmlTable "text") # create a table body const tbody ( afnix:wax:XhtmlTable "text" "text" "text") # add a print tbl in the body tbody:add-table ptbl # add the body to the table table:ad-child tbodyA table caption node can also be set with the set-caption method. The method simply creates a XhtmlCaption node and adds it to the table. The caption text is part of the method call which is used by the caption node constructor. It is also possible to create the caption node by calling the XhtmlCaption constructor and adding it to the table with he add-child method.
# create a xhtml table const table (afnix:wax:XhtmlTable "text") # set a table caption table:set-caption "the afnix table system"The table structure can also be defined with the XhtmlCgr class which corresponds to the xhtml column group element. The column group element is designed to support the col element that formats the table column.
# create a table const table (afnix:wax:XhtmlTable "text") # set the table with to 100% table:add-attribute "width" "100%" # create a column group table:add-child (const xcgr (afnix:wax:XhtmlCgr)) # add a column with 30% width cgr:add-child (afnix:wax:XhtmlCol "30%") # add a column with 70% width cgr:add-child (afnix:wax:XhtmlCol "70%")
WEB APPLICATION EXTENSION SERVICE REFERENCE¶
XhtmlRootxhtml-root-p
Inheritance
XmlRootMime
Constructors
XhtmlRoot (String)
The XhtmlRoot constructor creates a default xhtml page with a head and a body.
The head node is set with the string title argument.
Methods
get-head -> XhtmlHead (none)
The get-head method returns the xhtml head node.
get-body -> XhtmlBody (none)
The get-body method returns the xhtml body node.
XhtmlHtml
xhtml-html-p
Inheritance
XmlTag
Constructors
XhtmlHtml (String)
The XhtmlHtml constructor creates a default xhtml html node with a head and a
body. The head node is set with the string title argument.
Methods
get-head -> XhtmlHead (none)
The get-head method returns the xhtml head node.
get-body -> XhtmlBody (none)
The get-body method returns the xhtml body node.
XhtmlHead
xhtml-head-p
Inheritance
XmlTag
Constructors
XhtmlHead (String)
The XhtmlHead constructor creates a default xhtml head node with a title. The
string argument is the head title.
Methods
add-meta -> none (String String)
The add-meta method adds a XhtmlMeta node to the head node. The first argument
is the meta descriptor. The second argument is the meta contents.
add-style -> none (String)
The add-style method adds a XhtmlLink node to the head node. The string argument
is the style url path. The link node is automatically configured to reference
a 'text/css' mime type.
XhtmlBody
xhtml-body-p
Inheritance
XmlTag
Constructors
XhtmlBody (none)
The XhtmlBody constructor creates a default xhtml body node.
XhtmlTitle
xhtml-title-p
Inheritance
XmlTag
Constructors
XhtmlTitle (String)
The XhtmlTitle constructor creates a xhtml title node. The string argument is
the title value. The title node is designed for the XhtmlHead class.
Methods
set-title -> none (String)
The set-title method set the node title by value.
XhtmlMeta
xhtml-meta-p
Inheritance
XmlTag
Constructors
XhtmlMeta (String String)
The XhtmlMeta constructor creates a xhtml meta node with a descriptor name and
content value. The first argument is he descriptor name which is used as the
node attribute name. The second argument is the content vale which is the
attribute value.
XhtmlLink
xhtml-link-p
Inheritance
XmlTag
Constructors
XhtmlLink (String)
The XhtmlLink constructor creates a xhtml link node by reference. The first
argument is the link reference.
XhtmlLink (String String)
The XhtmlLink constructor creates a xhtml link node by reference and type. The
first argument is the link reference. The second argument is the link type.
The link type is defined as a mime type.
XhtmlLink (String String String)
The XhtmlLink constructor creates a xhtml link node by reference, type and
relation. The first argument is the link reference. The second argument is the
link type. The link type is defined as a mime type. The third argument is the
link relation.
XhtmlStyle
xhtml-style-p
Inheritance
XmlTag
Constructors
XhtmlStyle (String)
The XhtmlStyle constructor creates a xhtml style node with a url path. The
string argument is the url path of the style sheet file.
XhtmlScript
xhtml-script-p
Inheritance
XmlTag
Constructors
XhtmlScript (String)
The XhtmlScript constructor creates a xhtml script node with a type. The string
argument is the mime type string such like 'text/javascript'.
XhtmlScript (String Boolean)
The XhtmlScript constructor creates a xhtml script node with a type and a CDATA
node control flag. The first argument is the mime type string such like
'text/javascript'. The second argument is the CDATA node control flag. If the
flag is true, all scripts attached to the node are placed into a 'CDATA'
node.
XhtmlScript (String String)
The XhtmlScript constructor creates a xhtml script node with a type and a url.
The first argument is the mime type string such like 'text/javascript'. The
second argument is the script source url.
XhtmlPara
xhtml-para-p
Inheritance
XmlTag
Constructors
XhtmlPara (none)
The XhtmlPara constructor creates a default xhtml paragraph node.
XhtmlPara (String)
The XhtmlPara constructor creates a xhtml paragraph node with a style. The
string argument is the style name.
XhtmlPara (Boolean)
The XhtmlPara constructor creates an empty xhtml paragraph if the boolean
argument is true.
XhtmlEmph
xhtml-emph-p
Inheritance
XmlTag
Constructors
XhtmlEmph (none)
The XhtmlEmph constructor creates a default xhtml emphasize node.
XhtmlEmph (String)
The Xhtmlemph constructor creates a xhtml emphasize node with a style. The
string argument is the style name.
XhtmlRef
xhtml-ref-p
Inheritance
XmlTag
Constructors
XhtmlRef (none)
The XhtmlRef constructor creates a default xhtml reference node.
XhtmlRef (String)
The XhtmlRef constructor creates a xhtml reference node with a uri. The string
argument is the uri to use.
XhtmlRef (String String)
The XhtmlRef constructor creates a xhtml reference node with a uri and a
reference text. The first argument is the uri. The second argument is the
reference text.
XhtmlImg
xhtml-img-p
Inheritance
XmlTag
Constructors
XhtmlImg (String String)
The XhtmlImg constructor creates a xhtml image node by source and alternate
name. The first argument is the image uri. The second argument is the
alternate name.
Methods
set-width -> none (String)
The set-width method set the image width attribute.
set-height -> none (String)
The set-height method set the image height attribute.
set-geometry -> none (String)
The set-geometry method set the image width and height attribute in one
call.
XhtmlDiv
xhtml-div-p
Inheritance
XmlTag
Constructors
XhtmlDiv (none)
The XhtmlDiv constructor creates a default xhtml div node.
XhtmlDiv (String)
The XhtmlDiv constructor creates a xhtml div node with a style. The string
argument is the style name.
XhtmlPre
xhtml-pre-p
Inheritance
XmlTag
Constructors
XhtmlPre (none)
The XhtmlPre constructor creates a default xhtml pre node.
XhtmlPre (String)
The XhtmlPre constructor creates a xhtml pre node with a style. The string
argument is the style name.
XhtmlHr
xhtml-hr-p
Inheritance
XmlTag
Constructors
XhtmlHr (none)
The XhtmlHr constructor creates a default xhtml hr node.
XhtmlHr (String)
The XhtmlHr constructor creates a xhtml hr node with a style. The string
argument is the style name.
XhtmlCgr
xhtml-cgr-p
Inheritance
XmlTag
Constructors
XhtmlCgr (none)
The XhtmlCgr constructor creates a default xhtml colgroup node.
XhtmlCol
xhtml-col-p
Inheritance
XmlTag
Constructors
XhtmlCol (none)
The XhtmlCol constructor creates a default xhtml col node.
XhtmlCol (String)
The XhtmlCol constructor creates a xhtml col node with a string width argument.
The argument is the width attribute value.
XhtmlTh
xhtml-th-p
Inheritance
XmlTag
Constructors
XhtmlTh (none)
The XhtmlTh constructor creates a default xhtml th node.
XhtmlTh (String)
The XhtmlTh constructor creates a xhtml th node with a style. The string
argument is the style name.
XhtmlTd
xhtml-td-p
Inheritance
XmlTag
Constructors
XhtmlTd (none)
The XhtmlTd constructor creates a default xhtml td node.
XhtmlTd (String)
The XhtmlTd constructor creates a xhtml td node with a style. The string
argument is the style name.
XhtmlTr
xhtml-tr-p
Inheritance
XmlTag
Constructors
XhtmlTr (none)
The XhtmlTr constructor creates a default xhtml tr node.
XhtmlTr (String)
The XhtmlTr constructor creates a xhtml tr node with a style. The string
argument is the style name.
XhtmlTr (String String)
The XhtmlTr constructor creates a xhtml tr node with a style and a default table
data style. The string argument is the table row style name. The second
argument is the default table data style.
Methods
new-head -> XhtmlTh (none | String)
The new-head method returns a new table head data object. Without argument, a
default XhtmlTh object is created. With a string argument, the XhtmlTh object
is constructed with a style name.
new-data -> XhtmlTd (none | String)
The new-data method returns a new table data object. Without argument, a default
XhtmlTd object is created. With a string argument, the XhtmlTd object is
constructed with a style name.
set-head-class -> none (String)
The set-head-class method sets the default table head style. The default style
is use with the new-head method.
set-data-class -> none (String)
The set-data-class method sets the default table data style. The default style
is use with the new-data method.
set-xdef-class -> none (String)
The set-xdef-class method sets the default table head and data style. The
default style is use with the new-head and new-data methods. This method
combines the set-head-class and the set-head-class
XhtmlTelem
xhtml-telem-p
Inheritance
XmlTag
Methods
new-row -> XhtmlTr (none | String)
The new-row method returns a new table row object. Without argument, a default
XhtmlTr object is created. With a string argument, the XhtmlTr object is
constructed with a style name.
add-table -> none (PrintTable [Boolean])
The add-table method adds a print table into the table element by adding
automatically the row and the associated formatting information such like the
data direction. The optional second argument controls whether or not the table
tag shall be used to build reference node for the table elements.
set-xrow-class -> none (String)
The set-xrow-class method sets the default table row data style. The default row
style is use with the new-row method.
set-xdef-class -> none (String)
The set-xdef-class method sets the default table head and data style. The
default style is use with the new-row method to set the table head and data
default style.
XhtmlThead
xhtml-thead-p
Inheritance
XhtmlTelem
Constructors
XhtmlThead (none)
The XhtmlThead constructor creates a default xhtml table head node.
XhtmlThead (String)
The XhtmlThead constructor creates a xhtml table head node with a style. The
string argument is the style name.
XhtmlThead (String String)
The XhtmlThead constructor creates a xhtml table head node with a style and a
default table row style. The string argument is the table head style name. The
second argument is the default table row style.
XhtmlThead (String String String)
The XhtmlThead constructor creates a xhtml table head node with a style, a
default table row style and a default table data style. The string argument is
the table head style name. The second argument is the default table row style.
The third argument is the table data style.
XhtmlTbody
xhtml-tbody-p
Inheritance
XhtmlTelem
Constructors
XhtmlTbody (none)
The XhtmlTbody constructor creates a default xhtml table body node.
XhtmlTbody (String)
The XhtmlTbody constructor creates a xhtml table body node with a style. The
string argument is the style name.
XhtmlTbody (String String)
The XhtmlTbody constructor creates a xhtml table body node with a style and a
default table row style. The string argument is the table body style name. The
second argument is the default table row style.
XhtmlTbody (String String String)
The XhtmlTbody constructor creates a xhtml table body node with a style, a
default table row style and a default table data style. The string argument is
the table body style name. The second argument is the default table row style.
The third argument is the table data style.
XhtmlTfoot
xhtml-tfoot-p
Inheritance
XhtmlTelem
Constructors
XhtmlTfoot (none)
The XhtmlTfoot constructor creates a default xhtml table foot node.
XhtmlTfoot (String)
The XhtmlTfoot constructor creates a xhtml table foot node with a style. The
string argument is the style name.
XhtmlTfoot (String String)
The XhtmlTfoot constructor creates a xhtml table foot node with a style and a
default table row style. The string argument is the table foot style name. The
second argument is the default table row style.
XhtmlTfoot (String String String)
The XhtmlTfoot constructor creates a xhtml table foot node with a style, a
default table row style and a default table data style. The string argument is
the table foot style name. The second argument is the default table row style.
The third argument is the table data style.
XhtmlTable
xhtml-table-p
Inheritance
XhtmlTelem
Constructors
XhtmlTable (none)
The XhtmlTable constructor creates a default xhtml table foot node.
XhtmlTable (String)
The XhtmlTable constructor creates a xhtml table foot node with a style. The
string argument is the style name.
XhtmlTable (String String)
The XhtmlTable constructor creates a xhtml table foot node with a style and a
default table row style. The string argument is the table foot style name. The
second argument is the default table row style.
XhtmlTable (String String String)
The XhtmlTable constructor creates a xhtml table foot node with a style, a
default table row style and a default table data style. The string argument is
the table foot style name. The second argument is the default table row style.
The third argument is the table data style.
Methods
set-caption -> none (String)
The set-caption method sets the table caption. A new XhtmlCaption node is
automatically added to the table tree during this method call.
XmlMime
xml-mime-p
Inheritance
XmlDocumentMime
Constructors
XmlMime (none)
The XmlMime constructor creates a default xml mime document.
XmlMime (String)
The XmlMime constructor creates a xml mime document by parsing a file. The file
name is the string argument.
XmlMime (String InputStream)
The XmlMime constructor creates a xml mime document by name and by parsing the
input stream. The first argument is the xml document name. The second argument
is the input stream to parse.
XhtmlMime
xhtml-mime-p
Inheritance
XmlMime
Constructors
XhtmlMime (none)
The XhtmlMime constructor creates a default xhtml mime document.
XhtmlMime (String)
The XhtmlMime constructor creates a xhtml mime document by parsing a file. The
file name is the string argument.
XhtmlMime (String InputStream)
The XhtmlMime constructor creates a xhtml mime document by name and by parsing
the input stream. The first argument is the xhtml document name. The second
argument is the input stream to parse.
2012-03-26 | AFNIX |