HTMLDocument module
This module contains functions for creating and editing a HTML document using a tree-based approach. This ensures that documents are of a high code quality, makes maintenance easier, and provides protection against some common web security problems.
Data types
- HTMLDocument::ClientScript - An client-side script
- HTMLDocument::ControlInputType - Types of control input
- HTMLDocument::ConversionSafety - The conversion safety level for String->HTML conversion
- HTMLDocument::Doctype - The document type declaration.
- HTMLDocument::FormType - The method used by a form
- HTMLDocument::HTMLDocument - A HTML document
- HTMLDocument::HeadLink - A document-level link
- HTMLDocument::ImageData - An inline image.
- HTMLDocument::ImageDimensions - Image dimensions
- HTMLDocument::InitialTableData - Initial table data
- HTMLDocument::InlineElement - Inline elements
- HTMLDocument::ListType - List type
- HTMLDocument::MediaType - A display media type
- HTMLDocument::MetaData - Meta data about a HTML document
- HTMLDocument::Relationship - A document relationship
- HTMLDocument::SelectOption - An option for selection
- HTMLDocument::StyleSheet - A CSS stylesheet
- HTMLDocument::TextInputType - Types of text input
- HTMLDocument::WhiteList - Elements to allow in String->HTML conversion
Exceptions
- InvalidNesting - The specified range causes invalid nesting
- InvalidRange - The specified range is invalid
- RequiresAttribute - A required attribute is missing
- RequiresElement - A required element is missing
- TagSoupNotForOutput - TagSoup is not an output format
Functions
- ElementTree addAddress(ElementTree parent,String initialtext=createString(0)) - Add an address
- ElementTree addBlockQuote(ElementTree parent) - Add a quotation block
- ElementTree addDivision(ElementTree parent,String initialtext=createString(0),String cssclass=createString(0)) - Add a generic block
- Void addDocumentLink(HTMLDocument doc,Relationship relate,String uri,String title=createString(0),String ctype=createString(0)) - Adds a document-level link
- Void addDocumentMetaData(HTMLDocument doc,String key,String value) - Adds a meta-data key/value pair to the document
- Void addDocumentScripting(HTMLDocument doc,String scripturi) - Adds an external script to the document
- Void addDocumentStylesheet(HTMLDocument doc,[MediaType] media,String uri) - Adds a linked external stylesheet to the document
- ElementTree addFieldset(ElementTree parent,String legendtext) - Add a new fieldset
- Void addHTTPHeader(HTMLDocument doc,Pair<String, String> header) - Adds a HTTP header to the document
- Void addHTTPHeader(HTMLDocument doc,String name,String value) - Adds a HTTP header to the document
- ElementTree addHeading(ElementTree parent,Int headinglevel,String initialtext=createString(0)) - Add a heading
- ElementTree addHorizontalRule(ElementTree block) - Add a separator
- ElementTree addImage(ElementTree block,ImageData image) - Add an image
- ElementTree addInlineElementAt(ElementTree block,InlineElement inline,Int startpos,Int endpos) - Wrap existing text in an inline element
- ElementTree addLabelledInput(ElementTree parent,String labeltext,TextInputType itype,String iname,String ivalue=createString(0),Int isize=0) - Adds a labelled text input
- ElementTree addLabelledSelect(ElementTree block,String labeltext,String name,Int ssize,[Pair<String, [SelectOption]> ] optgroups,Bool lazy=false) - Adds a labelled selection box
- ElementTree addLabelledTextarea(ElementTree parent,String name,String labeltext,String initialtext=createString(0),Int rows=5,Int cols=40) - Adds a labelled textarea
- ElementTree addLazySelect(ElementTree block,String name,Int ssize,[Pair<String, [SelectOption]> ] optgroups) - Lazily adds a selection box
- ElementTree addLineBreak(ElementTree block) - Add a line break
- ElementTree addList(ElementTree parent,ListType ltype,Int initialsize,[String] initialcontents=createArray(1)) - Add a list
- ElementTree addListItem(ElementTree list,Int index,String initialcontents=createString(0)) - Add a list item
- ElementTree addLocalControlInput(ElementTree parent,String label,b(a) fn,a state,String prefix="") - Add a form submit button
- ElementTree addLocalForm(ElementTree parent,Bool fileupload=false) - Add a form for the current application
- ElementTree addOption(ElementTree parent,String iname,SelectOption option) - Adds a labelled checkbox to a form.
- ElementTree addOptionList(ElementTree parent,String legend,String iname,[SelectOption] options,Bool allowmultiple=true) - Adds a set of checkboxes or radio buttons
- ElementTree addParagraph(ElementTree parent,String initialtext=createString(0)) - Add a paragraph
- ElementTree addPreformatted(ElementTree parent,String initialtext=createString(0)) - Add a preformatted block
- ElementTree addRemoteControlInput(ElementTree parent,ControlInputType itype,String iname=createString(0),String ivalue=createString(0)) - Add a form submit button
- ElementTree addRemoteForm(ElementTree parent,String action,FormType method) - Add a form to call another application
- ElementTree addSelectElement(ElementTree block,String name,Int ssize,[Pair<String, [SelectOption]> ] optgroups) - Adds a selection box
- Void addStateFields(ElementTree parent,Void(a) fn,a state) - Call a CGI function
- Void addString(ElementTree block,String text) - Append text to an element
- ElementTree addTable(ElementTree parent,String captiontext=createString(0)) - Add a new empty table
- ElementTree addTableBodySection(ElementTree table) - Add a new table body section
- Void addTableColumns(ElementTree table,Int num=1) - Add a new table column
- ElementTree addTableRow(ElementTree tsect,String class=createString(0)) - Adds a table row
- ElementTree addTextInput(ElementTree parent,TextInputType itype,String iname,String ivalue=createString(0),Int isize=0) - Adds a text input
- ElementTree addTextarea(ElementTree parent,String name,String initialtext=createString(0),Int rows=5,Int cols=40) - Adds a textarea
- ElementTree anonymousBlock() - Make an anonymous block
- Void appendExisting(ElementTree dest,ElementTree block) - Append an existing element
- Void appendGenerator(ElementTree dest,ElementTree() generator) - Append an element generator
- ElementTree appendInlineElement(ElementTree block,InlineElement inline,String initialtext) - Append an inline element
- Void associateTextAndInput(ElementTree block,Int startpos,Int endpos,ElementTree control) - Associates some text with a form control
- String encodeControlState(b(a) fn,a state,String prefix="") - Encode application state for later retrieval
- Maybe<String> getAttribute(ElementTree element,String name) - Gets an attribute value from a HTML element
- [ElementTree] getChildren(ElementTree parent) - Return sub-elements
- ElementTree getListItem(ElementTree list,Int index) - Retrieve a list item
- [ElementTree] getTableBodySections(ElementTree table) - Get the table body sections
- ElementTree getTableCell(ElementTree tsect,Int row,Int col) - Retrieve a table cell
- ElementTree getTableFooter(ElementTree table) - Get the table footer section
- ElementTree getTableHeader(ElementTree table) - Get the table header section
- ElementTree initialiseTable(ElementTree parent,InitialTableData itd,String caption=createString(0)) - Create a table and initialise contents
- ElementTree lazyTable(ElementTree parent,InitialTableData itd,String caption=createString(0)) - Create a lazy table
- String localControlURL(b(a) fn,a state,String prefix="") - Create a URL that calls a local function
- ElementTree makeDataCell(ElementTree tsect,Int row,Int col) - Make a table cell a data cell
- ElementTree makeHeaderCell(ElementTree tsect,Int row,Int col) - Make a table cell a header cell
- Void moveBlock(ElementTree parentsrc,Int srcidx,ElementTree parentdest,Int destidx) - Move a block
- HTMLDocument new(Doctype doctype,String title) - A new empty HTML document
- Int numTableColumns(ElementTree table) - Get the number of columns in a table
- Void prependExisting(ElementTree dest,ElementTree block) - Prepend an existing element
- Void prependGenerator(ElementTree dest,ElementTree() generator) - Prepend an element generator
- ElementTree pushListItem(ElementTree list,String initialcontents=createString(0)) - Append a list item
- Void readFromString(ElementTree location,String input,WhiteList safety,Doctype doctype) - Convert a String to HTML
- Void readFromTemplate(ElementTree location,String input,WhiteList safety,Doctype doctype,Dict<String, ElementTree([Pair<String, String> ])> templates,Bool lazy=true) - Convert a HTML template to HTML
- Void setAttribute(ElementTree element,String name,String value) - Sets an attribute on a HTML element
- Void setClass(ElementTree element,String classname) - Set the CSS class
- Void setDocumentTitle(HTMLDocument doc,String newtitle) - Changes the document title
- Void setID(ElementTree element,String idname) - Sets the ID of a HTML element
- Void setTableCaption(ElementTree table,String captiontext) - Sets the table caption
- Void setTitle(ElementTree element,String title) - Sets the title of a HTML element
- String string(HTMLDocument doc,UnicodeFormat uform=LiteralUTF8) - Convert an entire HTML document to a String
- String substring(ElementTree tree,UnicodeFormat uform=LiteralUTF8,Doctype doctype=HTML4Strict) - Converts a part of the document to string form
- Void write(HTMLDocument doc,UnicodeFormat uform=LiteralUTF8) - Print a HTML document on standard output
- Void writeTo(HTMLDocument doc,Void(String) output,UnicodeFormat uform=LiteralUTF8) - Print a HTML document with a specified output function