/*
* $Id: XMLModule.java,v 1.31 2002/09/16 08:05:03 jkl Exp $
*
* Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
*
* Use is subject to license terms, as defined in
* Anvil Sofware License, Version 1.1. See LICENSE
* file, or http://njet.org/license-1.1.txt
*/
package anvil.core.xml;
import anvil.ErrorListener;
import anvil.core.Any;
import anvil.core.Array;
import anvil.core.io.AnyFile;
import anvil.core.io.AnyInputStream;
import anvil.core.net.AnyURL;
import anvil.script.Context;
import anvil.java.util.BindingEnumeration;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.StringReader;
import java.io.ByteArrayInputStream;
import java.net.URL;
import org.apache.xerces.framework.XMLParser;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.parsers.SAXParser;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
///
/// @module anvil.xml
/// Operations for parsing and inspecting XML documents.
///
public class XMLModule
{
static final InputSource createInputSource(Context context, Any source)
throws SAXException, IOException
{
if (source.isString()) {
return new InputSource(new StringReader(source.toString()));
} else if (source instanceof AnyFile) {
File file = (File)source.toObject();
context.checkRead(file.getPath());
return new InputSource(new FileInputStream(file));
} else if (source instanceof AnyURL) {
URL url = (URL)source.toObject();
return new InputSource(url.openStream());
} else if (source instanceof AnyInputStream) {
InputStream input = (InputStream)source.toObject();
return new InputSource(input);
}
return null;
}
static final anvil.parser.InputSource createAnvilInputSource(Context context, Any source) throws IOException
{
if (source.isString()) {
return new anvil.parser.StreamInputSource(new ByteArrayInputStream(
anvil.util.Conversions.getBytes(source.toString())));
} else if (source instanceof AnyFile) {
File file = (File)source.toObject();
context.checkRead(file.getPath());
return new anvil.parser.StreamInputSource(new FileInputStream(file));
} else if (source instanceof AnyURL) {
URL url = (URL)source.toObject();
return new anvil.parser.URLInputSource(url);
} else if (source instanceof AnyInputStream) {
InputStream input = (InputStream)source.toObject();
return new anvil.parser.StreamInputSource(input);
}
return null;
}
private static final void setupParser(Context context, XMLParser parser, Any features)
throws SAXException, IOException
{
if ((features != null) && features.isArray()) {
BindingEnumeration enum = features.toArray().keysAndElements();
boolean state;
Object key;
while(enum.hasMoreElements()) {
key = enum.nextKey().toString();
state = ((Any)enum.nextElement()).toBoolean();
try {
parser.setFeature((String)key, state);
} catch (SAXException e) {
throw context.XMLError(e.getMessage(), null);
}
}
}
}
/// @function makeTag
/// @synopsis string makeTag(string name)
/// @synopsis string makeTag(string name, array attrs)
/// @synopsis string makeTag(string name, array attrs, boolean withEnd)
public static final Object[] p_makeTag = new Object[] { "name", "*attrs", null, "*withEnd", Boolean.FALSE };
public static final Any makeTag(String name, Any attrs, boolean withEnd)
{
StringBuffer tag = new StringBuffer(100);
tag.append('<');
tag.append(name);
if (attrs != null && attrs.isArray()) {
BindingEnumeration e = ((Array)attrs).keysAndElements();
while(e.hasMoreElements()) {
tag.append(' ');
tag.append(e.nextKey());
Any value = Any.create(e.nextElement());
if (!(value.isNull() || value.isUndefined())) {
tag.append('=');
tag.append('"');
tag.append(value);
tag.append('"');
}
}
}
if (withEnd) {
tag.append(' ');
tag.append('/');
}
tag.append('>');
return Any.create(tag.toString());
}
/// @function parseDOM
/// <p>
/// Parses document from given source and returns the root node of
/// document object model, or <code>null</code> if error occured
/// while parsing.
/// </p>
///
/// <p>
/// Behaviour of parser can be controlled through 'features'
/// which is array with strings mapped to boolean's. Features are:
/// </p>
///
/// <dl>
/// <dt><b>http://xml.org/sax/features/validation</b></dt>
/// <dd>
/// Default: false.
///
/// If this feature is set to true, the document must specify a grammar. If this feature is set to
/// false, the document may specify a grammar and that grammar will be parsed but no validation
/// of the document contents will be performed.
/// </dd>
///
/// <dt><b>http://xml.org/sax/features/external-general-entities</b></dt>
/// <dd>
/// Default: true.
///
/// Should external general entities be included.
/// </dd>
///
/// <dt><b>http://xml.org/sax/features/external-parameter-entities</b></dt>
/// <dd>
/// Default: true.
///
/// Should the external parameter entities and the external DTD subset
/// be included.
/// </dd>
///
/// <dt><b>http://xml.org/sax/features/namespaces</b></dt>
/// <dd>
/// Default: false.
///
/// If the validation feature is set to true, then the document must
/// contain a grammar that supports the use of namespaces.
/// </dd>
/// <dt><b>http://apache.org/xml/features/validation/schema</b></dt>
/// <dd>
/// Default: true.
///
/// XML schema support.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/validation/dynamic</b></dt>
/// <dd>
/// Default: false.
///
/// If true, document is validated only if grammar is specified,
/// otherwise validation is controlled by
/// http://xml.org/sax/features/validation feature.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/validation/warn-on-duplicate-attdef</b></dt>
/// <dd>
/// Default: true.
///
/// Should the parser warn on duplicated attribute definitions.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/validation/warn-on-undeclared-elemdef</b></dt>
/// <dd>
/// Default: true.
///
/// Should the parser warn on undeclared element references.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/continue-after-fatal-error</b></dt>
/// <dd>
/// Default: false.
///
/// Should the parsing continue even after fatal error.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/nonvalidating/load-dtd-grammar</b></dt>
/// <dd>
/// Default: true.
///
/// If validation is turned off, should the DTD grammar be loaded.
/// </dd>
///
/// <dd>
/// Default: true.
/// </dd-->
///
/// <dt><b>http://apache.org/xml/features/dom/create-entity-ref-nodes</b></dt>
/// <dd>
/// Default: true.
/// Should entity reference nodes be created to DOM tree.
/// </dd>
///
/// <dt><b>http://apache.org/xml/features/dom/include-ignorable-whitespace</b></dt>
/// <dd>
/// Default: true.
/// Should "ignorable whitespace nodes" be ignored in the tree.
/// </dd>
///
/// <!--dt><b>http://apache.org/xml/features/domx/grammar-access</b></dt>
/// <dd>
/// Default: false.
/// </dd-->
///
/// <dt><b>http://xml.org/sax/features/namespace-prefixes</b></dt>
/// <dd>
/// Default: true.
/// Should original prefixed names and attributes used for namespace
/// types be reported.
/// </dd>
///
/// <!--dt><b>http://xml.org/sax/features/string-interning</b></dt>
/// <dd>
/// Default: false.
/// </dd-->
///
/// </dl>
///
/// @synopsis Node parseDOM(string content [, array features] )
/// @synopsis Node parseDOM(URL url [, array features] )
/// @synopsis Node Node parseDOM(File file [, array features] )
/// @synopsis Node Node parseDOM(InputStream inputStream [, array features] )
/// @param content string content
/// @param url url content
/// @param file file content
/// @param inputStream input stream content
/// @param features array of features
/// @return node
/// @throws XMLError if an XML error occured
/// @throws IOError if an I/O error occured.
public static final Object[] p_parseDOM = { null, "source", "*features", null };
public static final Any parseDOM(Context context, Any source, Any features)
{
try {
InputSource inputSource = createInputSource(context, source);
if (source == null) {
throw context.BadParameter("File, InputStream, URL or string expected");
}
DOMParser parser = new DOMParser();
setupParser(context, parser, features);
parser.parse(inputSource);
return new AnyNode(parser.getDocument());
} catch (SAXException e) {
throw context.XMLError(e.getMessage(), null);
} catch (IOException e) {
throw context.exception(e);
}
}
/// @function parseSAX
/// Parses XML document using SAX parser. Callbacks can be given
/// as namespace, module, class or array or functions.
///
/// <dl>
/// <dt><b>function error(tuple location, string message, object userdata)</b></dt>
/// <dd>
/// Notification of error. 'location' is list with four elements:
/// publicId, systemId, lineNumber, columnNumber.
/// </dd>
///
/// <dt><b>function fatalError(tuple location, string message, object userdata)</b></dt>
/// <dd>
/// Notification of fatal error. 'location' is list with four elements:
/// publicId, systemId, lineNumber, columnNumber.
/// </dd>
///
/// <dt><b>function warning(tuple location, string message, object userdata)</b></dt>
/// <dd>
/// Notification of warning. 'location' is list with four elements:
/// publicId, systemId, lineNumber, columnNumber.
/// </dd>
///
/// <dt><b>function notationDecl(string name, string publicId, string systemId, object userdata)</b></dt>
/// <dd>
/// Receive notification of a notation type event.
/// </dd>
///
/// <dt><b>function unparsedEntityDecl(string name, string publicId, string systemId, string notationName, object userdata)</b></dt>
/// <dd>
/// Receive notification of an unparsed entity type event.
/// </dd>
///
/// <dt><b>function resolveEntity(string publicId, string systemId, object userdata)</b></dt>
/// <dd>
/// Customized handling of external entities, function should return one of following
/// datatypes:
/// <ul>
/// <li>string, contents of string is parsed
/// <li>URL, contents of URL is parsed
/// <li>InputSource, contents of stream is parsed
/// <li>File, contents of file is parsed.
/// <li>null, default resolver is used
/// </ul>
/// </dd>
///
/// <dt><b>function setDocumentLocator(Function locator, object userdata)</b></dt>
/// <dd>
/// Registers function for getting origin of document events. Function returns
/// tuple with four elements: publicId, systemId, lineNumber, columnNumber.
/// </dd>
///
/// <dt><b>function startDocument(object userdata)</b></dt>
/// <dd>
/// Receive notification of the beginning of a document.
/// </dd>
///
/// <dt><b>function endDocument(object userdata)</b></dt>
/// <dd>
/// Receive notification of the end of a document.
/// </dd>
///
/// <dt><b>function startElement(string namespaceURI, string localName, string qName, array attributes, object userdata)</b></dt>
/// <dd>
/// Receive notification of the beginning of an element. 'attributes'
/// is array with prefixed attribute names mapped to respective values.
/// </dd>
///
/// <dt><b>function endElement(string namespaceURI, string localName, string qName, object userdata)</b></dt>
/// <dd>
/// Receive notification of the end of an element.
/// </dd>
///
/// <dt><b>function characters(string cdata, object userdata)</b></dt>
/// <dd>
/// Receive notification of the end of an element.
/// </dd>
///
/// <dt><b>function ignorableWhitespace(string cdata, object userdata)</b></dt>
/// <dd>
/// Receive notification of character data.
/// </dd>
///
/// <dt><b>function startPrefixMapping(string prefix, string uri, object userdata)</b></dt>
/// <dd>
/// Begin the scope of a prefix-URI Namespace mapping.
/// </dd>
///
/// <dt><b>function endPrefixMapping(string prefix, object userdata)</b></dt>
/// <dd>
/// End the scope of a prefix-URI mapping.
/// </dd>
///
/// <dt><b>function skippedEntity(string name, object userdata)</b></dt>
/// <dd>
/// Receive notification of a skipped entity.
/// </dd>
///
/// <dt><b>function processingInstruction(string target, string data, object userdata)</b></dt>
/// <dd>
/// Receive notification of a processing instruction.
/// </dd>
/// </dl>
///
/// @synopsis void parseSAX(string content, object callbacks, [array features, object userdata] )
/// @synopsis void parseSAX(URL url, object callbacks, [array features, object userdata] )
/// @synopsis void parseSAX(File file, object callbacks, [array features, object userdata] )
/// @synopsis void parseSAX(InputStream inputStream, object callbacks, [array features, object userdata] )
/// @param content string content
/// @param url url content
/// @param file file content
/// @param inputStream input stream content
/// @param callbacks bundle of functions
/// @param features array of features
/// @param userdata optional data passed to callbacks
/// @return userdata
/// @throws XMLError if an XML error occured
/// @throws IOError if an I/O error occured
public static final Object[] p_parseSAX = { null, "source", "callbacks", "*features", null, "*userdata", null };
public static final Any parseSAX(Context context, Any source, Any callbacks, Any features, Any userdata)
{
SAXHandler handler = null;
ErrorListener listener = null;
try {
InputSource inputSource = createInputSource(context, source);
if (source == null) {
throw context.BadParameter("File, InputStream, URL or string expected");
}
SAXParser parser = new SAXParser();
setupParser(context, parser, features);
handler = new SAXHandler(context, callbacks, userdata);
parser.setErrorHandler(handler);
parser.setDTDHandler(handler);
parser.setEntityResolver(handler);
parser.setContentHandler(handler);
parser.parse(inputSource);
listener = handler.getListener();
if (listener != null) {
throw context.XMLError("Parsing failed", listener);
}
return Any.create(userdata);
} catch (SAXException e) {
Exception saxEmb = e.getException();
if (saxEmb != null) {
context.log().error(saxEmb);
}
if (handler != null) {
listener = handler.getListener();
}
throw context.XMLError("Parsing failed: "+e.getMessage(), listener);
} catch (IOException e) {
throw context.exception(e);
}
}
/// @function parse
/// Parser tagged data using simple parser (anvil.parser.Parser).
/// This parser never generates any errors, except possible IO error
/// while reading from stream.
/// @synopsis void parse(source, callbacks)
/// @synopsis object parse(source, callbacks, userdata)
/// @param source String, InputStream or URL
/// @param callbacks Module, Array or instanceof class containg
/// set of callback functions:
/// <dl>
/// <dt><b>function setDocumentLocator(function locator)</b></dt>
/// <dd>Supplies function that can be called to retrieve the
/// the current location as tuple (url, line, column)</dd>
/// <dt><b>function startDocument([userdata])</b></dt>
/// <dd>Called on the start of document</dd>
/// <dt><b>function endDocument([userdata])</b></dt>
/// <dd>Called on the end of document</dd>
/// <dt><b>function handleCharacters(string cdata [,userdata])</b></dt>
/// <dd>Called when sequence of characeters is encountered</dd>
/// <dt><b>function handleComment(string cdata [,userdata])</b></dt>
/// <dd>Called when a comment is encountered</dd>
/// <dt><b>function handleTag(string name, array attributes, boolean hasEndSlash, string tagAsString [,userdata])</b></dt>
/// <dd>Called when a tag is encountered</dd>
/// <dt><b>function handleProcessingInstruction(string data)</b></dt>
/// <dd>Called when a processing instruction is encountered.</dd>
/// </dl>
/// @param userdata
/// Optional userdata passed as a last parameter to callback functions
/// @return userdata
///
public static final Object[] p_parse = { null, "source", "callbacks", "*userdata", null };
public static final Any parse(Context context, Any source, Any callbacks, Any userdata)
{
try {
anvil.parser.InputSource inputSource = createAnvilInputSource(context, source);
if (inputSource == null) {
throw context.BadParameter("File, InputStream, URL or string expected");
}
anvil.parser.Parser parser = new anvil.parser.Parser();
SimpleHandler handler = new SimpleHandler(context, callbacks, userdata);
parser.parse(handler, inputSource);
return Any.create(userdata);
} catch (IOException e) {
throw context.exception(e);
}
}
public static final anvil.script.compiler.NativeNamespace __module__ =
new anvil.script.compiler.NativeNamespace(
"xml",
XMLModule.class,
new Class[] {
AnyNode.class,
},
//DOC{{
""+
"\n" +
" @module anvil.xml\n" +
" Operations for parsing and inspecting XML documents.\n" +
"\n" +
" @function makeTag\n" +
" @synopsis string makeTag(string name)\n" +
" @synopsis string makeTag(string name, array attrs)\n" +
" @synopsis string makeTag(string name, array attrs, boolean withEnd)\n" +
" @function parseDOM\n" +
" <p>\n" +
" Parses document from given source and returns the root node of\n" +
" document object model, or <code>null</code> if error occured\n" +
" while parsing.\n" +
" </p>\n" +
"\n" +
" <p>\n" +
" Behaviour of parser can be controlled through 'features'\n" +
" which is array with strings mapped to boolean's. Features are:\n" +
" </p>\n" +
"\n" +
" <dl>\n" +
" <dt><b>http://xml.org/sax/features/validation</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
"\n" +
" If this feature is set to true, the document must specify a grammar. If this feature is set to\n" +
" false, the document may specify a grammar and that grammar will be parsed but no validation\n" +
" of the document contents will be performed.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://xml.org/sax/features/external-general-entities</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" Should external general entities be included.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://xml.org/sax/features/external-parameter-entities</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" Should the external parameter entities and the external DTD subset\n" +
" be included.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://xml.org/sax/features/namespaces</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
"\n" +
" If the validation feature is set to true, then the document must\n" +
" contain a grammar that supports the use of namespaces.\n" +
" </dd>\n" +
" <dt><b>http://apache.org/xml/features/validation/schema</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" XML schema support.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/validation/dynamic</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
"\n" +
" If true, document is validated only if grammar is specified,\n" +
" otherwise validation is controlled by\n" +
" http://xml.org/sax/features/validation feature.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/validation/warn-on-duplicate-attdef</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" Should the parser warn on duplicated attribute definitions.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/validation/warn-on-undeclared-elemdef</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" Should the parser warn on undeclared element references.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/continue-after-fatal-error</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
"\n" +
" Should the parsing continue even after fatal error.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/nonvalidating/load-dtd-grammar</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
"\n" +
" If validation is turned off, should the DTD grammar be loaded.\n" +
" </dd>\n" +
"\n" +
" <dd>\n" +
" Default: true.\n" +
" </dd-->\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/dom/create-entity-ref-nodes</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
" Should entity reference nodes be created to DOM tree.\n" +
" </dd>\n" +
"\n" +
" <dt><b>http://apache.org/xml/features/dom/include-ignorable-whitespace</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
" Should \"ignorable whitespace nodes\" be ignored in the tree.\n" +
" </dd>\n" +
"\n" +
" <!--dt><b>http://apache.org/xml/features/domx/grammar-access</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
" </dd-->\n" +
"\n" +
" <dt><b>http://xml.org/sax/features/namespace-prefixes</b></dt>\n" +
" <dd>\n" +
" Default: true.\n" +
" Should original prefixed names and attributes used for namespace\n" +
" types be reported.\n" +
" </dd>\n" +
"\n" +
" <!--dt><b>http://xml.org/sax/features/string-interning</b></dt>\n" +
" <dd>\n" +
" Default: false.\n" +
" </dd-->\n" +
"\n" +
" </dl>\n" +
"\n" +
" @synopsis Node parseDOM(string content [, array features] )\n" +
" @synopsis Node parseDOM(URL url [, array features] )\n" +
" @synopsis Node Node parseDOM(File file [, array features] )\n" +
" @synopsis Node Node parseDOM(InputStream inputStream [, array features] )\n" +
" @param content string content\n" +
" @param url url content\n" +
" @param file file content\n" +
" @param inputStream input stream content\n" +
" @param features array of features\n" +
" @return node\n" +
" @throws XMLError if an XML error occured\n" +
" @throws IOError if an I/O error occured.\n" +
" @function parseSAX\n" +
" Parses XML document using SAX parser. Callbacks can be given\n" +
" as namespace, module, class or array or functions.\n" +
"\n" +
" <dl>\n" +
" <dt><b>function error(tuple location, string message, object userdata)</b></dt>\n" +
" <dd>\n" +
" Notification of error. 'location' is list with four elements:\n" +
" publicId, systemId, lineNumber, columnNumber.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function fatalError(tuple location, string message, object userdata)</b></dt>\n" +
" <dd>\n" +
" Notification of fatal error. 'location' is list with four elements:\n" +
" publicId, systemId, lineNumber, columnNumber.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function warning(tuple location, string message, object userdata)</b></dt>\n" +
" <dd>\n" +
" Notification of warning. 'location' is list with four elements:\n" +
" publicId, systemId, lineNumber, columnNumber.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function notationDecl(string name, string publicId, string systemId, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of a notation type event. \n" +
" </dd>\n" +
"\n" +
" <dt><b>function unparsedEntityDecl(string name, string publicId, string systemId, string notationName, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of an unparsed entity type event.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function resolveEntity(string publicId, string systemId, object userdata)</b></dt>\n" +
" <dd>\n" +
" Customized handling of external entities, function should return one of following\n" +
" datatypes:\n" +
" <ul>\n" +
" <li>string, contents of string is parsed\n" +
" <li>URL, contents of URL is parsed\n" +
" <li>InputSource, contents of stream is parsed\n" +
" <li>File, contents of file is parsed.\n" +
" <li>null, default resolver is used\n" +
" </ul>\n" +
" </dd>\n" +
"\n" +
" <dt><b>function setDocumentLocator(Function locator, object userdata)</b></dt>\n" +
" <dd>\n" +
" Registers function for getting origin of document events. Function returns\n" +
" tuple with four elements: publicId, systemId, lineNumber, columnNumber.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function startDocument(object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of the beginning of a document.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function endDocument(object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of the end of a document.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function startElement(string namespaceURI, string localName, string qName, array attributes, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of the beginning of an element. 'attributes'\n" +
" is array with prefixed attribute names mapped to respective values.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function endElement(string namespaceURI, string localName, string qName, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of the end of an element.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function characters(string cdata, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of the end of an element.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function ignorableWhitespace(string cdata, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of character data.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function startPrefixMapping(string prefix, string uri, object userdata)</b></dt>\n" +
" <dd>\n" +
" Begin the scope of a prefix-URI Namespace mapping.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function endPrefixMapping(string prefix, object userdata)</b></dt>\n" +
" <dd>\n" +
" End the scope of a prefix-URI mapping.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function skippedEntity(string name, object userdata)</b></dt>\n" +
" <dd>\n" +
" Receive notification of a skipped entity.\n" +
" </dd>\n" +
"\n" +
" <dt><b>function processingInstruction(string target, string data, object userdata)</b></dt>\n" +
" <dd> \n" +
" Receive notification of a processing instruction.\n" +
" </dd>\n" +
" </dl>\n" +
"\n" +
" @synopsis void parseSAX(string content, object callbacks, [array features, object userdata] )\n" +
" @synopsis void parseSAX(URL url, object callbacks, [array features, object userdata] )\n" +
" @synopsis void parseSAX(File file, object callbacks, [array features, object userdata] )\n" +
" @synopsis void parseSAX(InputStream inputStream, object callbacks, [array features, object userdata] )\n" +
" @param content string content\n" +
" @param url url content\n" +
" @param file file content\n" +
" @param inputStream input stream content\n" +
" @param callbacks bundle of functions\n" +
" @param features array of features\n" +
" @param userdata optional data passed to callbacks\n" +
" @return userdata\n" +
" @throws XMLError if an XML error occured\n" +
" @throws IOError if an I/O error occured\n" +
" @function parse\n" +
" Parser tagged data using simple parser (anvil.parser.Parser).\n" +
" This parser never generates any errors, except possible IO error\n" +
" while reading from stream.\n" +
" @synopsis void parse(source, callbacks)\n" +
" @synopsis object parse(source, callbacks, userdata)\n" +
" @param source String, InputStream or URL\n" +
" @param callbacks Module, Array or instanceof class containg\n" +
" set of callback functions:\n" +
" <dl>\n" +
" <dt><b>function setDocumentLocator(function locator)</b></dt>\n" +
" <dd>Supplies function that can be called to retrieve the\n" +
" the current location as tuple (url, line, column)</dd>\n" +
" <dt><b>function startDocument([userdata])</b></dt>\n" +
" <dd>Called on the start of document</dd>\n" +
" <dt><b>function endDocument([userdata])</b></dt>\n" +
" <dd>Called on the end of document</dd>\n" +
" <dt><b>function handleCharacters(string cdata [,userdata])</b></dt>\n" +
" <dd>Called when sequence of characeters is encountered</dd>\n" +
" <dt><b>function handleComment(string cdata [,userdata])</b></dt>\n" +
" <dd>Called when a comment is encountered</dd>\n" +
" <dt><b>function handleTag(string name, array attributes, boolean hasEndSlash, string tagAsString [,userdata])</b></dt>\n" +
" <dd>Called when a tag is encountered</dd>\n" +
" <dt><b>function handleProcessingInstruction(string data)</b></dt>\n" +
" <dd>Called when a processing instruction is encountered.</dd>\n" +
" </dl>\n" +
" @param userdata\n" +
" Optional userdata passed as a last parameter to callback functions\n" +
" @return userdata\n" +
"\n"
//}}DOC
);
}