libxml2
Loading...
Searching...
No Matches
SAX2.h File Reference

SAX2 parser interface used to build the DOM tree. More...

Functions

const xmlCharxmlSAX2GetPublicId (void *ctx)
 Provides the public ID e.g.
const xmlCharxmlSAX2GetSystemId (void *ctx)
 Provides the system ID, basically URL or filename e.g.
void xmlSAX2SetDocumentLocator (void *ctx, xmlSAXLocator *loc)
 Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.
int xmlSAX2GetLineNumber (void *ctx)
 Provide the line number of the current parsing point.
int xmlSAX2GetColumnNumber (void *ctx)
 Provide the column number of the current parsing point.
int xmlSAX2IsStandalone (void *ctx)
 Is this document tagged standalone ?
int xmlSAX2HasInternalSubset (void *ctx)
 Does this document has an internal subset.
int xmlSAX2HasExternalSubset (void *ctx)
 Does this document has an external subset.
void xmlSAX2InternalSubset (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 Callback on internal subset declaration.
void xmlSAX2ExternalSubset (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 Callback on external subset declaration.
xmlEntityxmlSAX2GetEntity (void *ctx, const xmlChar *name)
 Get an entity by name.
xmlEntityxmlSAX2GetParameterEntity (void *ctx, const xmlChar *name)
 Get a parameter entity by name.
xmlParserInputxmlSAX2ResolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 This is only used to load DTDs.
void xmlSAX2EntityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 An entity definition has been parsed.
void xmlSAX2AttributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumeration *tree)
 An attribute definition has been parsed.
void xmlSAX2ElementDecl (void *ctx, const xmlChar *name, int type, xmlElementContent *content)
 An element definition has been parsed.
void xmlSAX2NotationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 What to do when a notation declaration has been parsed.
void xmlSAX2UnparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 What to do when an unparsed entity declaration is parsed.
void xmlSAX2StartDocument (void *ctx)
 called when the document start being processed.
void xmlSAX2EndDocument (void *ctx)
 called when the document end has been detected.
void xmlSAX2StartElement (void *ctx, const xmlChar *fullname, const xmlChar **atts)
 Called when an opening tag has been processed.
void xmlSAX2EndElement (void *ctx, const xmlChar *name)
 called when the end of an element has been detected.
void xmlSAX2StartElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
 SAX2 callback when an element start has been detected by the parser.
void xmlSAX2EndElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 SAX2 callback when an element end has been detected by the parser.
void xmlSAX2Reference (void *ctx, const xmlChar *name)
 called when an entity xmlSAX2Reference is detected.
void xmlSAX2Characters (void *ctx, const xmlChar *ch, int len)
 receiving some chars from the parser.
void xmlSAX2IgnorableWhitespace (void *ctx, const xmlChar *ch, int len)
 receiving some ignorable whitespaces from the parser.
void xmlSAX2ProcessingInstruction (void *ctx, const xmlChar *target, const xmlChar *data)
 A processing instruction has been parsed.
void xmlSAX2Comment (void *ctx, const xmlChar *value)
 A xmlSAX2Comment has been parsed.
void xmlSAX2CDataBlock (void *ctx, const xmlChar *value, int len)
 called when a pcdata block has been parsed
int xmlSAXDefaultVersion (int version)
 Has no effect.
int xmlSAXVersion (xmlSAXHandler *hdlr, int version)
 Initialize the default XML SAX handler according to the version.
void xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, int warning)
 Initialize the default XML SAX2 handler.
void xmlSAX2InitHtmlDefaultSAXHandler (xmlSAXHandler *hdlr)
 Initialize the default HTML SAX2 handler.
void htmlDefaultSAXHandlerInit (void)
void xmlDefaultSAXHandlerInit (void)
 Initialize the default SAX2 handler.

Detailed Description

SAX2 parser interface used to build the DOM tree.

those are the default SAX2 interfaces used by the library when building DOM tree.

Author
Daniel Veillard

Function Documentation

◆ htmlDefaultSAXHandlerInit()

void htmlDefaultSAXHandlerInit ( void )
Deprecated
This function is a no-op. Call xmlInitParser to initialize the library.

◆ xmlDefaultSAXHandlerInit()

void xmlDefaultSAXHandlerInit ( void )

Initialize the default SAX2 handler.

Deprecated
This function is a no-op. Call xmlInitParser to initialize the library.

◆ xmlSAX2AttributeDecl()

void xmlSAX2AttributeDecl ( void * ctx,
const xmlChar * elem,
const xmlChar * fullname,
int type,
int def,
const xmlChar * defaultValue,
xmlEnumeration * tree )

An attribute definition has been parsed.

Parameters
ctxthe user data (XML parser context)
elemthe name of the element
fullnamethe attribute name
typethe attribute type
defthe type of default value
defaultValuethe attribute default value
treethe tree of enumerated value set

◆ xmlSAX2CDataBlock()

void xmlSAX2CDataBlock ( void * ctx,
const xmlChar * value,
int len )

called when a pcdata block has been parsed

Parameters
ctxthe user data (XML parser context)
valueThe pcdata content
lenthe block length

◆ xmlSAX2Characters()

void xmlSAX2Characters ( void * ctx,
const xmlChar * ch,
int len )

receiving some chars from the parser.

Parameters
ctxthe user data (XML parser context)
cha xmlChar string
lenthe number of xmlChar

◆ xmlSAX2Comment()

void xmlSAX2Comment ( void * ctx,
const xmlChar * value )

A xmlSAX2Comment has been parsed.

Parameters
ctxthe user data (XML parser context)
valuethe xmlSAX2Comment content

◆ xmlSAX2ElementDecl()

void xmlSAX2ElementDecl ( void * ctx,
const xmlChar * name,
int type,
xmlElementContent * content )

An element definition has been parsed.

Parameters
ctxthe user data (XML parser context)
namethe element name
typethe element type
contentthe element value tree

◆ xmlSAX2EndDocument()

void xmlSAX2EndDocument ( void * ctx)

called when the document end has been detected.

Parameters
ctxthe user data (XML parser context)

◆ xmlSAX2EndElement()

void xmlSAX2EndElement ( void * ctx,
const xmlChar * name )

called when the end of an element has been detected.

Deprecated
Don't call this function directly.

Used for HTML and SAX1.

Parameters
ctxthe user data (XML parser context)
nameThe element name

◆ xmlSAX2EndElementNs()

void xmlSAX2EndElementNs ( void * ctx,
const xmlChar * localname,
const xmlChar * prefix,
const xmlChar * URI )

SAX2 callback when an element end has been detected by the parser.

It provides the namespace information for the element.

Parameters
ctxthe user data (XML parser context)
localnamethe local name of the element
prefixthe element namespace prefix if available
URIthe element namespace name if available

◆ xmlSAX2EntityDecl()

void xmlSAX2EntityDecl ( void * ctx,
const xmlChar * name,
int type,
const xmlChar * publicId,
const xmlChar * systemId,
xmlChar * content )

An entity definition has been parsed.

Parameters
ctxthe user data (XML parser context)
namethe entity name
typethe entity type
publicIdThe public ID of the entity
systemIdThe system ID of the entity
contentthe entity value (without processing).

◆ xmlSAX2ExternalSubset()

void xmlSAX2ExternalSubset ( void * ctx,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId )

Callback on external subset declaration.

Parameters
ctxthe user data (XML parser context)
namethe root element name
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD

◆ xmlSAX2GetColumnNumber()

int xmlSAX2GetColumnNumber ( void * ctx)

Provide the column number of the current parsing point.

Parameters
ctxthe user data (XML parser context)
Returns
an int

◆ xmlSAX2GetEntity()

xmlEntity * xmlSAX2GetEntity ( void * ctx,
const xmlChar * name )

Get an entity by name.

Parameters
ctxthe user data (XML parser context)
nameThe entity name
Returns
the xmlEntity if found.

◆ xmlSAX2GetLineNumber()

int xmlSAX2GetLineNumber ( void * ctx)

Provide the line number of the current parsing point.

Parameters
ctxthe user data (XML parser context)
Returns
an int

◆ xmlSAX2GetParameterEntity()

xmlEntity * xmlSAX2GetParameterEntity ( void * ctx,
const xmlChar * name )

Get a parameter entity by name.

Parameters
ctxthe user data (XML parser context)
nameThe entity name
Returns
the xmlEntity if found.

◆ xmlSAX2GetPublicId()

const xmlChar * xmlSAX2GetPublicId ( void * ctx)

Provides the public ID e.g.

"-//SGMLSOURCE//DTD DEMO//EN"

Parameters
ctxthe user data (XML parser context)
Returns
a xmlChar *

◆ xmlSAX2GetSystemId()

const xmlChar * xmlSAX2GetSystemId ( void * ctx)

Provides the system ID, basically URL or filename e.g.

http://www.sgmlsource.com/dtds/memo.dtd

Parameters
ctxthe user data (XML parser context)
Returns
a xmlChar *

◆ xmlSAX2HasExternalSubset()

int xmlSAX2HasExternalSubset ( void * ctx)

Does this document has an external subset.

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ xmlSAX2HasInternalSubset()

int xmlSAX2HasInternalSubset ( void * ctx)

Does this document has an internal subset.

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ xmlSAX2IgnorableWhitespace()

void xmlSAX2IgnorableWhitespace ( void * ctx,
const xmlChar * ch,
int len )

receiving some ignorable whitespaces from the parser.

UNUSED: by default the DOM building will use xmlSAX2Characters

Parameters
ctxthe user data (XML parser context)
cha xmlChar string
lenthe number of xmlChar

◆ xmlSAX2InitDefaultSAXHandler()

void xmlSAX2InitDefaultSAXHandler ( xmlSAXHandler * hdlr,
int warning )

Initialize the default XML SAX2 handler.

Parameters
hdlrthe SAX handler
warningflag if non-zero sets the handler warning procedure

◆ xmlSAX2InitHtmlDefaultSAXHandler()

void xmlSAX2InitHtmlDefaultSAXHandler ( xmlSAXHandler * hdlr)

Initialize the default HTML SAX2 handler.

Parameters
hdlrthe SAX handler

◆ xmlSAX2InternalSubset()

void xmlSAX2InternalSubset ( void * ctx,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId )

Callback on internal subset declaration.

Parameters
ctxthe user data (XML parser context)
namethe root element name
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD

◆ xmlSAX2IsStandalone()

int xmlSAX2IsStandalone ( void * ctx)

Is this document tagged standalone ?

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ xmlSAX2NotationDecl()

void xmlSAX2NotationDecl ( void * ctx,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId )

What to do when a notation declaration has been parsed.

Parameters
ctxthe user data (XML parser context)
nameThe name of the notation
publicIdThe public ID of the entity
systemIdThe system ID of the entity

◆ xmlSAX2ProcessingInstruction()

void xmlSAX2ProcessingInstruction ( void * ctx,
const xmlChar * target,
const xmlChar * data )

A processing instruction has been parsed.

Parameters
ctxthe user data (XML parser context)
targetthe target name
datathe PI data's

◆ xmlSAX2Reference()

void xmlSAX2Reference ( void * ctx,
const xmlChar * name )

called when an entity xmlSAX2Reference is detected.

Parameters
ctxthe user data (XML parser context)
nameThe entity name

◆ xmlSAX2ResolveEntity()

xmlParserInput * xmlSAX2ResolveEntity ( void * ctx,
const xmlChar * publicId,
const xmlChar * systemId )

This is only used to load DTDs.

The preferred way to install custom resolvers is xmlCtxtSetResourceLoader.

Parameters
ctxthe user data (XML parser context)
publicIdThe public ID of the entity
systemIdThe system ID (URL) of the entity
Returns
a parser input.

◆ xmlSAX2SetDocumentLocator()

void xmlSAX2SetDocumentLocator ( void * ctx,
xmlSAXLocator * loc )

Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.

Parameters
ctxthe user data (XML parser context)
locA SAX Locator

◆ xmlSAX2StartDocument()

void xmlSAX2StartDocument ( void * ctx)

called when the document start being processed.

Parameters
ctxthe user data (XML parser context)

◆ xmlSAX2StartElement()

void xmlSAX2StartElement ( void * ctx,
const xmlChar * fullname,
const xmlChar ** atts )

Called when an opening tag has been processed.

Deprecated
Don't call this function directly.

Used for HTML and SAX1.

Parameters
ctxthe user data (XML parser context)
fullnameThe element name, including namespace prefix
attsAn array of name/value attributes pairs, NULL terminated

◆ xmlSAX2StartElementNs()

void xmlSAX2StartElementNs ( void * ctx,
const xmlChar * localname,
const xmlChar * prefix,
const xmlChar * URI,
int nb_namespaces,
const xmlChar ** namespaces,
int nb_attributes,
int nb_defaulted,
const xmlChar ** attributes )

SAX2 callback when an element start has been detected by the parser.

It provides the namespace information for the element, as well as the new namespace declarations on the element.

Parameters
ctxthe user data (XML parser context)
localnamethe local name of the element
prefixthe element namespace prefix if available
URIthe element namespace name if available
nb_namespacesnumber of namespace definitions on that node
namespacespointer to the array of prefix/URI pairs namespace definitions
nb_attributesthe number of attributes on that node
nb_defaultedthe number of defaulted attributes.
attributespointer to the array of (localname/prefix/URI/value/end) attribute values.

◆ xmlSAX2UnparsedEntityDecl()

void xmlSAX2UnparsedEntityDecl ( void * ctx,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId,
const xmlChar * notationName )

What to do when an unparsed entity declaration is parsed.

Parameters
ctxthe user data (XML parser context)
nameThe name of the entity
publicIdThe public ID of the entity
systemIdThe system ID of the entity
notationNamethe name of the notation

◆ xmlSAXDefaultVersion()

int xmlSAXDefaultVersion ( int version)

Has no effect.

Deprecated
Use parser option XML_PARSE_SAX1.
Parameters
versionthe version, must be 2
Returns
2 in case of success and -1 in case of error.

◆ xmlSAXVersion()

int xmlSAXVersion ( xmlSAXHandler * hdlr,
int version )

Initialize the default XML SAX handler according to the version.

Parameters
hdlrthe SAX handler
versionthe version, 1 or 2
Returns
0 in case of success and -1 in case of error.