1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/** -*-C-*-ish
ElementTreeData.k Copyright (C) 2005 Chris Morris
This file is distributed under the terms of the GNU Lesser General
Public Licence. See COPYING for licence.
*/
"<summary>Data types for representation of XML and XML-like trees</summary>
<prose>This module contains data types for the representation of XML and XML-like tree structures. The <moduleref>HTMLDocument</moduleref> and <moduleref>KayaDoc</moduleref> modules both use this package.</prose>"
module ElementTreeData;
import public Dict;
// isempty is true for things like <br> (or <br/> if it's an XML
// representation)
"<summary>An element and its descendants</summary>
<prose>This data type represents a node in the tree and its descendants (in XML, an element and its contents). The <code>elements</code> field is a list of the descendant <dataref>Element</dataref>s, the <code>name</code> field is the name of the element, and the <code>attributes</code> field is a dictionary of attribute names and values.</prose>
<example>attrs = newTiny();
add(attrs,\"title\",\"Hello\");
el = ElementTree(subs,\"example\",attrs);
// converts to a string as
// <example title=\"Hello\">...contents of subs here...</example></example>"
public data ElementTree([Element] elements, String name, TinyDict<String,String> attributes);
"<summary>Types of element</summary>
<prose>This data type represents the three different types of descendant elements that an <dataref>ElementTree</dataref> may contain:</prose>
<list><item><code>SubElement</code>: a descendant <code>ElementTree</code></item>
<item><code>CData</code>: an anonymous string of text</item>
<item><code>SubTree</code>: a function that returns an <code>ElementTree</code>, for lazy generation of trees.</item></list>"
public data Element = SubElement(ElementTree nested) | CData(String cdata) | SubTree(ElementTree() generator);
// we use CData a little sloppily here - it's just string data, not
// necessarily the XML CData type.
// no longer used
// Exception ElementParseError();
"<summary>Controls printing of empty elements</summary>
<prose>This data type is used by <functionref>ElementTree::string</functionref> and <functionref>ElementTree::lazyPrint</functionref> to control the printing of empty elements (i.e. elements that are defined as empty, not merely elements that happen to have no content).</prose>
<prose><code>Singleton</code> or <code>OpenAndClose</code> are both usable in XML (<code>Singleton</code> is usually more readable). If you are using this module to generate HTML (or other non-XML-based markup languages) then <code>ImpliedSingleton</code> should be used. The following list shows how each displays an empty <code>br</code> element.</prose>
<list>
<item><code>Singleton</code>: <output><br /></output></item>
<item><code>ImpliedSingleton</code>: <output><br></output></item>
<item><code>OpenAndClose</code>: <output><br></br></output></item>
</list>"
public data EmptyTagMode = Singleton | ImpliedSingleton | OpenAndClose;
//"Controls code formatting."
//public data PrettyFormat = NoBreak | OuterBreak | FullBreak;
// replaced with Bool breaks
"<summary>Controls the output format of non-ASCII characters</summary>
<prose>Characters in Unicode that are not in ASCII can either be output as literal characters (<code>LiteralUTF8</code>) or as a numeric entity reference (<code>NumericReference</code>). Entity references give a larger file but will continue if the output will be used in an environment where the character encoding is not UTF-8 (for example, if the output is inserted into a HTML document in a different encoding)</prose>"
public data UnicodeFormat = LiteralUTF8 | NumericReference;
|