SCOL LibXml2 Stax (reader) api

To use this api, it's easy : create the reader, read the content and destroy !

Scoltype

ObjXmlRead2

The Scol type to use with this api. .........

Creation

_readxml2CreateFromFile

Create an object from a file (within the active partition). This creation is made in the specific thread. All threatment should be done after a nul return by the callback.

Prototype :

fun [Chn P S I fun [ObjXmlRead2 u0 I] u1 u0] ObjXmlRead2

Return : a new Scol object

_readxml2CreateFromUrl

Create an object from an url. This creation is made in the specific thread. All threatment should be done after a nul return by the callback.

Prototype :

fun [Chn S S I fun [ObjXmlRead2 u0 I] u1 u0] ObjXmlRead2

Return : a new Scol object

_readxml2CreateFromString

Create an object from a string in memory. This creation is made in the specific thread. All threatment should be done after a nul return by the callback.

Prototype :

fun [Chn S S I fun [ObjXmlRead2 u0 I] u1 u0] ObjXmlRead2

Return : a new Scol object

Flags :

These few flags are available. READXML2_OPTION_NONE should be the most useful.

READXML2_OPTION_NONE

No flag asked

READXML2_OPTION_RECOVER

Recover on errors

READXML2_OPTION_NONET

Forbid network access

READXML2_OPTION_NOBLANKS

Remove any blank nodes

READXML2_NSCLEAN

Remove the redundant namespaces declarations

Destroy

_readxml2Destroy

Destroy an object. You should destroy it when you no longer needed.

Prototype :

fun [ObjXmlRead2] I

Return 0 if success, nil if the object is already destroyed.

Read

_readxml2Read

Reads the content of any valid object. ....

Prototype :

fun [ObjXmlRead2 I] [[I S] r1]

Return a list of tuples [[I S] r1]. The first member is one of these flags, the second is the result.

Flags (integer : I) :

All return are a string (S). If a value doesn't exist / available, return nil.

READXML2_VERSION

return the xml used version, if available

READXML2_ENCODING

return the xml encoding, if available. Example : "UTF-8"

READXML2_STANDALONE

Return whether is a standalone or not. Example : "1"

READXML2_LANG

Return the xml language, if available

READXML2_NODE_VALUE

Return any text of an element. Example : xml file => <TEST> it is a test</TEST> will return "it is a test"

READXML2_NODE_NAME

Return the name of an element. Example : xml file => <TEST> it is a test</TEST> will return "TEST"

READXML2_VALIDITY

Not really implemented. Tests the validity (via a DTD or others).

READXML2_ATTRIBUTES

Return the attributes of the elements.

READXML2_ATTRVALUES

Return the values of each attribute.

READXML2_NODE_DEPTH

Return the depth of the current node.

READXML2_LINECOL

"line;column"

READXML2_NODE_TYPE

"NONE", "ELEMENT_START", "ELEMENT_END", "ATTRIBUTE", "TEXT", "CDATA", "COMMENT", "DOCUMENT", "DOCUMENT_TYPE", "DOCUMENT_FRAGMENT", "XML_DECLARATION", "ENTITY_START", "ENTITY_END" or nil

READXML2_NODE_STRING

Don't use this flag

...

Others

_readxml2EntitySet

By default the xmlReader will report entities as such and not replace them with their content. To replace them, set this function to 1.

Prototype :

fun [ObjXmlRead2 I] I

Return 0 if success, else nil

_readxml2EntityGet

By default the xmlReader will report entities as such and not replace them with their content. This function returns the current behavior.

Prototype :

fun [ObjXmlRead2] I

Return 1 if replace them, 0 if not replace them (default), nil if error

Example