Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Pike Module Reference:

module version 1.14, prepared

  MODULE Public
Modules
Parser

  MODULE Public.Parser
Modules
XML2

  MODULE Public.Parser.XML2
Classes
Node
SAX
Stylesheet
XMLReader

Methods
clear_xslt_docloader()
get_encodings()
new_xml()
parse_html()
parse_xml()
parse_xslt()
render_html()
render_xml()
select_xpath_nodes()
set_html_parser_options()
set_xml_parser_options()
set_xslt_docloader()
substituteEntitiesDefault()
utf8_check()
utf8_to_html()
utf8_to_isolat1()

Method select_xpath_nodes

array(object(Node)) Public.Parser.XML2.select_xpath_nodes(string xpath, object node)

Description

selects nodes based on an XPath query and returns the result.


Method set_xslt_docloader

void Public.Parser.XML2.set_xslt_docloader(function f)

Description

sets the xslt loader function. this is global for the process.

the callout should have the following signature:

Node f(string uri, int options, int type)

where: uri is the URI of the document to load options are a set of xmlParserOption the xsltLoadType indicating the kind of loading required


Method clear_xslt_docloader

void Public.Parser.XML2.clear_xslt_docloader()

Description

clears the system wide docloader callout, if one was set.


Method set_xml_parser_options

void Public.Parser.XML2.set_xml_parser_options(int options)

Description

sets parser options.

Parameter options

a bitwise or of Public.Parser.XML2.Constants options where valid options start with PARSE_.


Method set_html_parser_options

void Public.Parser.XML2.set_html_parser_options(int options)

Description

sets parser options.

Parameter options

a bitwise or of Public.Parser.XML2.Constants options where valid options start with PARSE_.


Method substituteEntitiesDefault

int Public.Parser.XML2.substituteEntitiesDefault(int def)


Method utf8_to_html

string Public.Parser.XML2.utf8_to_html(string str)


Method utf8_to_isolat1

string Public.Parser.XML2.utf8_to_isolat1(string str)


Method utf8_check

int Public.Parser.XML2.utf8_check(string str)


Method get_encodings

array(int) Public.Parser.XML2.get_encodings()

Description

gets the list of available character encoders.

Returns

an array of available encoder identifiers.


Method render_xml

string Public.Parser.XML2.render_xml(object(Node) n)

Description

Renders a node tree as an XML string. The entire document tree will be rendered. To render a portion of a tree, use Node.render_xml.

Parameter n

a Node object for a given XML document.


Method render_html

string Public.Parser.XML2.render_html(object(Node) n)

Description

Renders a node tree as an HTML string. The entire document tree will be rendered. To render a portion of a tree, use Node.render_html.

Parameter n

a Node object for a given HTML document.


Method parse_xml

object(Node) Public.Parser.XML2.parse_xml(string xml, string|void name)

Description

Parse an string containing XML.

Parameter xml

String containing XML data to parse.

Parameter name

String containing name/URI of file.

Returns

a Node object containing the root of the tree.


Method parse_html

object(Node) Public.Parser.XML2.parse_html(string html, string|void name)

Description

Parse an string containing HTML.

Parameter xml

String containing HTML data to parse.

Parameter name

String containing name/URI of file.

Returns

a Node object containing the root of the tree.


Method new_xml

object(Node) Public.Parser.XML2.new_xml(string version)

Description

Create a new XML document with a root node.

Parameter version

the version of XML to create

Parameter root_name

the name of the root node

Returns

a Node object containing the root of the tree.


Method parse_xslt

object(Node) Public.Parser.XML2.parse_xslt(string xslt, string|void name)

Description

Parse a string containing an XSLT stylesheet.

Parameter name

String containing name/URI of file.

Returns

a Stylesheet object containing the parsed stylesheet.

  CLASS Public.Parser.XML2.Node
Methods
()
add_child()
add_next_sibling()
add_ns()
add_prev_sibling()
add_sibling()
children()
delete_attribute()
get_attributes()
get_base()
get_lang()
get_last_child()
get_line_no()
get_no_ns_attributes()
get_node_name()
get_node_path()
get_node_type()
get_ns()
get_ns_attributes()
get_nss()
get_root_node()
get_space_preserve()
get_text()
is_blank()
is_text()
new_cdata_block()
new_char_ref()
new_child()
new_comment()
new_pi()
next()
parent()
prev()
render_html()
render_xml()
set_content()
set_node_name()
set_ns()
set_root_node()

Method get_line_no

int Public.Parser.XML2.Node()->get_line_no()

Returns

the line number the node is present on


Method set_ns

object(Node) Public.Parser.XML2.Node()->set_ns(string ns_prefix)


Method set_content

object(Node) Public.Parser.XML2.Node()->set_content(string content)

Description

sets the content for a node


Method get_text

string Public.Parser.XML2.Node()->get_text()

Description

gets the contents of a text node, or the contents and children of an element, or the value of an attribute node.


Method get_node_path

string Public.Parser.XML2.Node()->get_node_path()

Description

returns an XPath/XQuery based path for this Node.


Method get_ns

string Public.Parser.XML2.Node()->get_ns()

Description

returns the default name space uri for the element


Method get_nss

mapping Public.Parser.XML2.Node()->get_nss()

Description

gets a list of all known namespaces for this element.

Returns

a mapping of "short" prefixes to namespace uris.


Method get_base

string Public.Parser.XML2.Node()->get_base()


Method get_lang

string Public.Parser.XML2.Node()->get_lang()


Method get_space_preserve

int Public.Parser.XML2.Node()->get_space_preserve()


Method get_attributes

mapping Public.Parser.XML2.Node()->get_attributes()

Description

returns all attributes, irrespective of namespace

Returns

a mapping of attribute name to attribute value.


Method get_no_ns_attributes

mapping Public.Parser.XML2.Node()->get_no_ns_attributes()

Description

returns all attributes not present in a namespace

Returns

a mapping of attribute name to attribute value.


Method get_ns_attributes

mapping Public.Parser.XML2.Node()->get_ns_attributes(string ns_prefix)

Description

given a namespace uri, return all elements for that namespace present in the element.

Returns

a mapping of attribute names to attribute values.


Method children

array Public.Parser.XML2.Node()->children()

Description

get all children of this node

Returns

an array of all elements with are a direct child of this element.


Method parent

object(Node) Public.Parser.XML2.Node()->parent()

Description

get the Node which is the parent of this Node.


Method get_root_node

object(Node) Public.Parser.XML2.Node()->get_root_node()

Description

get the Node which is the root of this tree.


Method set_root_node

object(Node) Public.Parser.XML2.Node()->set_root_node()

Description

set this Node to be the root of this tree.

Returns

the old root of the tree, if any existed.


Method new_cdata_block

object(Node) Public.Parser.XML2.Node()->new_cdata_block(string contents)

Description

returns an unlinked CDATA block.


Method new_pi

object(Node) Public.Parser.XML2.Node()->new_pi(string name, string contents)

Description

returns a linked Processing Instruction node.


Methods

object(Node) Public.Parser.XML2.Node()->set_attribute(string name, string value)
object(Node) Public.Parser.XML2.Node()->set_ns_attribute(string name, string ns, string value)

Description

sets a new attribute, overwriting any existing value. if value is zero, the attribute will be removed from the node.


Method delete_attribute

object Public.Parser.XML2.Node()->delete_attribute(string name, string|void ns)


Method new_char_ref

object(Node) Public.Parser.XML2.Node()->new_char_ref(string name)

Description

returns an unlinked character reference node.


Method new_comment

object(Node) Public.Parser.XML2.Node()->new_comment(string content)

Description

returns an unlinked character reference node.


Method new_child

object(Node) Public.Parser.XML2.Node()->new_child(string ns, string name, string content)

Description

add a new child element, added to end of children for this node.


Method add_ns

object(Node) Public.Parser.XML2.Node()->add_ns(string href, string prefix)


Method add_child

object(Node) Public.Parser.XML2.Node()->add_child(object(Node) child)

Description

add a node to end of children for this node.


Method add_sibling

object(Node) Public.Parser.XML2.Node()->add_sibling(object(Node) sibling)

Description

add a node to end of siblings for this node.


Method add_next_sibling

object(Node) Public.Parser.XML2.Node()->add_next_sibling(object(Node) sibling)

Description

add a sibling node after this node.


Method add_prev_sibling

object(Node) Public.Parser.XML2.Node()->add_prev_sibling(object(Node) sibling)

Description

add a sibling node after this node.


Method get_last_child

object(Node) Public.Parser.XML2.Node()->get_last_child()

Description

get the Node which is the last child of this Node.


Method next

object(Node) Public.Parser.XML2.Node()->next()

Description

get the next sibling of this Node.

Returns

the next node which is a sibling of this node.


Method prev

object(Node) Public.Parser.XML2.Node()->prev()

Description

get the previous sibling of this Node.

Returns

the previous node which is a sibling of this node.


Method is_blank

int Public.Parser.XML2.Node()->is_blank()

Description

is this node empty?


Method is_text

int Public.Parser.XML2.Node()->is_text()

Description

is this a text node?


Method get_node_type

int Public.Parser.XML2.Node()->get_node_type()

Description

get the type of node.

Returns

the integer node type. Node type constants are defined in Constants.


Method get_node_name

string Public.Parser.XML2.Node()->get_node_name()

Description

gets the name of this node, if it has one.


Method set_node_name

string Public.Parser.XML2.Node()->set_node_name(string name)

Description

gets the name of this node, if it has one.


Method render_xml

string Public.Parser.XML2.Node()->render_xml(int level, int format)

Description

renders the node and all children as xml.

Parameter level

the indentation level to use

Parameter format

should the xml be formated for ease of human reading. this setting only takes effect if Public.Parser.XML2.xmlKeepBlanksDefault(0) has been called.


Method render_html

string Public.Parser.XML2.Node()->render_html()

Description

renders the node and all children as html.

  CLASS Public.Parser.XML2.SAX
Methods
clear_callback()
end()
feed()
parse()
set_callback()
Description

a SAX v1 parser featuring both pull and push (chunked) parsing.


Method set_callback

void Public.Parser.XML2.SAX()->set_callback(int callback_id, function f, mixed ... extra_args)

Description

sets a SAX handler callback function.

Parameter callback_id

the id of the type of handler you wish to set. this should be one of the Public.Parser.XML2.Constants.SAX_CB_* members.

Parameter f

the function to call when the selected parsing event occurs. prototypes for each event function are found in Public.Parser.XML2.SAXHandlers.

Parameter extra_args

extra data to supply to the callback function. these will be passed as extra parameters after any provided by the parser.

void serror_cb(mapping(string:mixed) error, mixed ... extra_args); mapping elements: domain, code, message, level, line, column

void entitydecl_cb(string name, int type, string publicId, string systemId, string content, mixed ... extra_args);

void elementdecl_cb(string name, int type, mixed ... extra_args);

void unparsedentitydecl_cb(string name, string publicId, string systemId, string notationName, mixed ... extra_args);

void attributedecl_cb(string elem, string fullname, int type, int def, string defaultValue, mixed ... extra_args);

void notationdecl_cb(string name, string publicId, string systemId, mixed ... extra_args);

void internalsubset_cb(string name, string ExternalId, string SystemId, mixed ... extra_args);

void externalsubset_cb(string name, string ExternalId, string SystemId, mixed ... extra_args);

void processinginstruction_cb(string target, string data, mixed ... extra_args);

void endelement_cb(string name, mixed ... extra_args);

void cdatablock_cb(string chars, mixed ... extra_args);

void ignorablewhitespace(string chars, mixed ... extra_args);

void characters_cb(string chars, mixed ... extra_args);

void reference_cb(string name, mixed ... extra_args);

void comment_cb(string value, mixed ... extra_args);

void startelement_cb(string name, mapping(string:string) attributes, mixed ... extra_args);

int isstandalone_cb(mixed ... extra_args);

void startdocument_cb(mixed ... extra_args);

void enddocument_cb(mixed ... extra_args);

int hasinternalsubset(mixed ... extra_args);

int hasexternalsubset(mixed ... extra_args);

string resolveentity(string publicId, string systemId, mixed ... extra_args);


Method clear_callback

int Public.Parser.XML2.SAX()->clear_callback(int callback_id)

Description

clears a SAX handler callback.

Parameter callback_id

the id of the type of handler you wish to set. this should be one of the Public.Parser.XML2.Constants.SAX_CB_* members.

Returns

1 if the handler existed, 0 otherwise.


Method feed

int Public.Parser.XML2.SAX()->feed(string d)

Description

feed some XML data to the parser. feed may be called multiple times to pass an entire XML document to the parser. The document will be processed as data is fed to the parser.

Parameter d

some XML data to be parsed. need not be a complete XML document.

Returns

the number of bytes processed.


Method end

int Public.Parser.XML2.SAX()->end()

Description

end parsing of a document and prepare for the next document.

resets the document parsing context and prepares for the next document. end should be called after the last chunk of data in an XML document has been passed to feed.


Method parse

int Public.Parser.XML2.SAX()->parse(string d)

Description

feed a complete XML document to the parser. data from the document will be processed and any registered SAX handler callbacks will be called as SAX events occur. this method contains an implicit call to end, so that the context is prepared to receive a new document after this function returns.

you may call this method with an (ending) fragment of an XML document, as long as any previous data needed to produce a valid XML document has already been fed to the parser using feed.

Parameter d

some XML data to be parsed. need not be a complete XML document.

Returns

the number of bytes processed.

  CLASS Public.Parser.XML2.Stylesheet
Methods
apply()
output()

Method apply

object(Node) Public.Parser.XML2.Stylesheet()->apply(object(Node) xml)

Description

apply the stylesheet object to an xml file.

Parameter xml

a Node object from the parsed XML document to apply. Any node from the XML document may be used.

Returns

a Node object for the transformed document.


Method output

string Public.Parser.XML2.Stylesheet()->output(object(Node) xml, int|void encoding)

Description

render the applied stylesheet Node to a string.

Parameter xml

the transformed xml object

Parameter encoding

an optional encoding for the string. if not supplied, defaults to ISO-8859-1 (ISO Latin 1). Valid options are found in Public.XML2.Constants, XML_CHAR_ENCODING*.

Returns

the string representation of the transformed XML.

  CLASS Public.Parser.XML2.XMLReader
Methods
create()
get_node_inner_xml()
get_node_name()
get_node_outer_xml()
get_node_prefix()
get_node_prefix()
get_node_prefix()
get_node_string()
get_node_type()
get_node_value()
Description

A simplified parser for XML documents. Similar to the C# XMLReader class.


Method get_node_type

int Public.Parser.XML2.XMLReader()->get_node_type()


Method get_node_name

int Public.Parser.XML2.XMLReader()->get_node_name()


Method get_node_prefix

int Public.Parser.XML2.XMLReader()->get_node_prefix()


Method get_node_prefix

int Public.Parser.XML2.XMLReader()->get_node_prefix()


Method get_node_prefix

int Public.Parser.XML2.XMLReader()->get_node_prefix()


Method get_node_value

int Public.Parser.XML2.XMLReader()->get_node_value()


Method get_node_string

int Public.Parser.XML2.XMLReader()->get_node_string()


Method get_node_inner_xml

int Public.Parser.XML2.XMLReader()->get_node_inner_xml()


Method get_node_outer_xml

int Public.Parser.XML2.XMLReader()->get_node_outer_xml()


Method create

void Public.Parser.XML2.XMLReader()->create(string xml, string|void url, int|void options)

gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University