Oracle8i XML Reference Guide Release 3 (8.1.7) Part Number A83730-01 |
Library | Service | Contents | Index

# 7
XML Parser for C++

This chapter describes the following sections:

- Class APIs

- Parser APIs

- C++ Sax APIs

- C++ DOM APIs

## Class: Attr

This class contains methods for accessing the name and value of a single document node attribute.

getName | Return name of attribute
getValue | Return "value" (definition) of attribute
getSpecified | Return attribute's "specified" flag value
setValue | Set an attribute's value

### getName

#### Function

Return name of attribute

#### Prototype

    String getName()

#### Arguments

None

#### Returns

String -- Name of attribute

### getValue

#### Function

Return "value" (definition) of attribute

#### Prototype

    String getValue()

#### Arguments

None

#### Returns

Value of attribute

### getSpecified

#### Function

Return value of attribute's "specified" flag. The DOM says:

If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false. Note that the implementation is in charge of this attribute, not the user. If the user changes the value of the attribute (even if it ends up having the same value as the default value) then the specified flag is automatically flipped to true. To re-specify the attribute as the default value from the DTD, the user must delete the attribute. The implementation will then make a new attribute available with specified set to false and the default value (if one exists).

#### Prototype

    boolean getSpecified()

#### Arguments

None

#### Returns

Value of specified flag

### setValue

#### Function

Sets an attribute's "value"

#### Prototype

    void setValue(String value)

#### Arguments

    value -- Attribute's new value

#### Returns

Value of attribute

## Class: CDATASection

This class implements the CDATA node type, a subclass of Text.

## Class: Comment

This class implements the COMMENT node type, a subclass of CharacterData.

## Class: Document

This class contains methods for creating and retrieving nodes.

createAttribute | Create an ATTRIBUTE node
createCDATASection | Create a CDATA node
createComment | Create a COMMENT node
createDocumentFragment | Create a DOCUMENT_FRAGMENT node
createElement | Create an ELEMENT node
createEntityReference | Create an ENTITY_REFERENCE node
createProcessingInstruction | Create a PROCESSING_INSTRUCTION node
createTextNode | Create a TEXT node
getElementsByTagName | Select nodes based on tag name
getImplementation | Return DTD for document

### createAttribute

#### Function

Create a new attribute node. Use setValue to set its value.

#### Prototype

Attr* createAttribute(String name)

#### Arguments

name -- name of attribute

#### Returns

Attr* -- pointer to created node

### createCDATASection

#### Function

Create a new CDATA node with the given contents.

#### Prototype

    Attr* createCDATASection(String name)

#### Arguments

data -- contents of node

#### Returns

CDATASection* -- pointer to created node

### createComment

#### Function

Create a new comment node with the given contents.

#### Prototype

    Comment* createComment(String data)

#### Arguments

data -- contents of node

#### Returns

Comment* -- pointer to created node

### createDocumentFragment

#### Function

Create a new document fragment node.

#### Prototype

    DocumentFragment* createDocumentFragment()

#### Arguments

None

#### Returns

DocumentFragment* -- pointer to created node

### createElement

#### Function

Create a new element node with the given (tag) name.

#### Prototype

    Element* createElement(String tagName)

#### Arguments

tagName -- element's tagname

#### Returns

Element* -- pointer to created node

### createEntityReference

#### Function

Create a new entity reference node.

#### Prototype

    EntityReference* createEntityReference(String name)

#### Arguments

name -- name of entity to reference

#### Returns

EntityReference* -- pointer to created node

### createProcessingInstruction

#### Function

Create a new processing instruction node.

#### Prototype

    ProcessingInstruction* createProcessingInstruction(String target, String data)

#### Arguments

target -- target part of PI

data -- data for node

#### Returns

ProcessingInstruction* -- pointer to created node

### createTextNode

#### Function

Create a new TEXT node.

#### Prototype

    Text* createTextNode(String data)

#### Arguments

data -- data for node

#### Returns

Text* -- pointer to created node

### getElementsByTagName

#### Function

Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. The special value "*" matches all tags.

#### Prototype

    NodeList* getElementsByTagName(String tagname)

#### Arguments

tagname -- tag name to select

#### Returns

NodeList* -- list of matches, NULL if none

### getImplementation

#### Function

Returns the DOMImplementation structure, currently useless. Perhaps it will be used in later DOM versions.

#### Prototype

    DOMImplementation* getImplementation()

#### Arguments

None

#### Returns

DOMImplementation* -- pointer to structure

## Class: DocumentType

This class contains methods for accessing information about the Document Type Definition (DTD) of a document.

getName | Return name of DTD
getEntities | Return NamedNodeMap of DTD's (general) entities
getNotations | #### Return NamedNodeMap of DTD's notations

### getName

#### Function

Return name of DTD

#### Prototype

    String getName()

#### Arguments

None

#### Returns

String -- Name of DTD

### getEntities

#### Function

Returns map of DTD's (general) entities

#### Prototype

    NamedNodeMap* getEntities()

#### Arguments

None

#### Returns

NamedNodeMap* -- map of entities

### getNotations

#### Function

Return map of DTD's notations

#### Prototype

    NamedNodeMap* getNotations()

#### Arguments

None

#### Returns

NamedNodeMap* -- map of notations

## Class: DOMImplementation

This class contains methods relating to the specific DOM implementation supported by the parser.

hasFeature | Detect if the named feature is supported

### hasFeature

#### Function

Test if the DOM implementation implements a specific feature.

#### Prototype

    boolean hasFeature(DOMString feature, DOMString version)

#### Arguments

feature -- The package name of the feature to test. In Level 1, the legal values are "HTML" and "XML" (case-insensitive)

version -- This is the version number of the package name to test. In Level 1, this is the string "1.0". If the version is not specified, supporting any version of the feature will cause the method to return true.

#### Returns

boolean -- feature is supported

## Class: Element

This class contains methods pertaining to element nodes.

getTagName | Return the node's tag name
getAttribute | Select an attribute given its name
setAttribute | Create a new attribute given its name and value
removeAttribute | Remove an attribute given its name
getAttributeNode | Remove an attribute given its name
setAttributeNode | Add a new attribute node
removeAttributeNode | Remove an attribute node
getElementsByTagName | Return a list of element nodes with the given tag name
normalize | "Normalize" an element (merge adjacent text nodes)

### getTagName

#### Function

Return the tag name of the element. The DOM says: "...even though there is a generic nodeName attribute on the Node interface, there is still a tagName attribute on the Element interface; these two attributes must contain the same value, but the Working Group considers it worthwhile to support both, given the different constituencies the DOM API must satisfy

#### Prototype

    String getTagName()

#### Arguments

None

#### Returns

String -- Tag name of node

### getAttribute

#### Function

Return "value" (definition) of named attribute

#### Prototype

    String getAttribute(String name)

#### Arguments

name -- name of attribute

#### Returns

Value of attribute

### setAttribute

#### Function

Create a new attribute

#### Prototype

    Attr* setAttribute(String name, String value)

#### Arguments

name -- name of new attribute

value -- value of new attribute

#### Returns

Pointer to create attribute

### removeAttribute

#### Function

Removes the named attribute

#### Prototype

    void removeAttribute(String name)

#### Arguments

name -- name of attribute to remove

#### Returns

None

### getAttributeNode

#### Function

Return pointer to named attribute

#### Prototype

    Attr* getAttributeNode(DOMString name)

#### Arguments

name -- name of attribute

#### Returns

Attr* -- pointer to attribute, or NULL if none such

### setAttributeNode

#### Function

Set (add) new attribute

#### Prototype

    boolean setAttributeNode(Attr* newAttr, Attr** oldAttr)

#### Arguments

newAttr -- pointer to new attribute

oldAttr -- returned pointer to replaced attribute

#### Returns

boolean -- success

### removeAttributeNode

#### Function

Remove the named attribute

#### Prototype

    Attr* removeAttributeNode(Attr* oldAttr)

#### Arguments

oldAttr -- attribute to remove

#### Returns

Attr* -- oldAttr passed back

### getElementsByTagName

#### Function

Create a list of matching elements

#### Prototype

    NodeList* getElementsByTagName(DOMString name)

#### Arguments

name -- tagname to match, "*" for all

#### Returns

NodeList* -- list of matches

### normalize

#### Function

Normalize an element, i.e. merge all adjacent TEXT nodes

#### Prototype

    void normalize(void)

#### Arguments

None

#### Returns

None

## Class: Entity

This class implements the ENTITY node type, a subclass of Node.

getNotationName | Return entity's NDATA (notation name)
getPublicId | Return entity's public ID
getSystemId | #### Return entity's system ID

### getNotationName

#### Function

Return an entity node's notation name (NDATA)

#### Prototype

    String* getNotationName()

#### Arguments

None

#### Returns

String -- node's NDATA

### getPublicId

#### Function

Return an entity node's public ID

#### Prototype

    String getPublicId()

#### Arguments

None

#### Returns

String -- entity's public ID

### getSystemId

#### Function

Return an entity node's system ID

#### Prototype

    String getSystemId()

#### Arguments

None

#### Returns

String -- entity's system ID

## Class: EntityReference

This class implements the ENTITY_REFERENCE node type, a subclass of Node.

## Class: NamedNodeMap

This class contains methods for accessing the number of nodes in a node map and fetching individual nodes.

item | Return nth node in map.
getLength | Return number of nodes in map
getNamedItem | Select a node by name
setNamedItem | Set a node into the map
removeNamedItem | Remove the named node from map

### item

#### Function

Return nth node in node map

#### Prototype

    Node* item(size_t index)

#### Arguments

size_t index-- zero-based node number

#### Returns

Node* -- Pointer to index'th node in map

### getLength

#### Function

Return number of nodes in map

#### Prototype

    size_t getLength()

#### Arguments

None

#### Returns

size_t -- Number of nodes in map

### getNamedItem

#### Function

Selects the node with the given name from the map

#### Prototype

    Node* getNamedItem(String name)

#### Arguments

name -- Name of node to select

#### Returns

Node* -- Pointer to named node, NULL of none such exists

### setNamedItem

#### Function

Adds a node to the map, replacing any node that already exists with the same name

#### Prototype

    boolean setNamedItem(Node *node, Node **old)

#### Arguments

node -- Name of node to add

old -- Pointer to replaced node, NULL if node is new

#### Returns

boolean -- Success

### removeNamedItem

#### Function

Removes the node with the given name from the node map

#### Prototype

    Node* removeNamedItem(String name)

#### Arguments

name -- Name of node to remove

#### Returns

Node* -- Pointer to removed node, NULL if none such exists

## Class: Node

This class contains methods for details about a document node

appendChild | Append a new child to the end of the current node's list of children
cloneNode | Clone an existing node and optionally all its children
getAttributes | Return structure contains all defined node attributes
getChildNode | Return specific indexed child of given node
getChildNodes | Return structure contains all child nodes of given node
getFirstChild | Return first child of given node
getLastChild | Return last child of given node
getLocal | Returns the local name of the node
getNameSpace | Return a node's namespace
getNextSibling | Return a node's next sibling
getName | Return name of node
getType | Return numeric type-code of node
getValue | Return "value" (data) of node
getOwnerDocument | Return document node which contains a node
getParentNode | Return parent node of given node
getPrefix | Returns the namespace prefix for the node
getPreviousSibling | Returns the previous sibling of the current node
getQualifiedName | Return namespace qualified node of given node
hasAttributes | Determine if node has any defined attributes
hasChildNodes | Determine if node has children
insertBefore | Insert new child node into a node's list of children
numChildNodes | Return count of number of child nodes of given node
removeChild | Remove a node from the current node's list of children
replaceChild | Replace a child node with another
setValue | Sets a node's value (data)

### appendChild

#### Function

Append a new child to the current node's list of children

#### Prototype

    Node* appendChild(Node *newChild)

#### Arguments

newChild -- new child node

#### Returns

Node* -- newChild is passed back

### cloneNode

#### Function

Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode returns NULL).

Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning any other type of node simply returns a copy of this node.

#### Prototype

    Node* cloneNode(boolean deep)

#### Arguments

deep -- recursion flag

#### Returns

Node* -- Pointer to new clone

### getAttributes

#### Function

Return structure of all attributes for node

#### Prototype

    NamedNodeMap* getAttributes()

#### Arguments

None

#### Returns

NamedNodeMap* -- Pointer to structure describing all attributes for node, or NULL if no attributes are defined

### getChildNode

#### Function

Return one of the node's children

#### Prototype

    Node* getChildNode(uword index)

#### Arguments

index -- child number, starting at 0

#### Returns

Node* -- Pointer to index'th child of node

### getChildNodes

#### Function

Return node's children

#### Prototype

    NodeList* getChildNodes()

#### Arguments

None

#### Returns

NodeList* -- Pointer to structure describing all the node's children

### getFirstChild

#### Function

Return the node's first child

#### Prototype

    Node* getFirstChild()

#### Arguments

None

#### Returns

Node* -- Pointer to the node's first child

### getLastChild

#### Function

Return the node's last child

#### Prototype

    Node* getLastChild()

#### Arguments

None

#### Returns

Node* -- Pointer to the node's last child

### getLocal

#### Function

Return the node's local name

#### Prototype

    String getLocal()

#### Arguments

None

#### Returns

String -- node's local name

### getNamespace

#### Function

Return the node's namespace

#### Prototype

    String getNamespace()

#### Arguments

None

#### Returns

String -- node's namespace (may be NULL)

### getNextSibling

#### Function

Returns the next sibling of the node, that is, the child of its parent which comes next

#### Prototype

    Node* getNextSibling()

#### Arguments

None

#### Returns

Node* -- Node's next sibling, NULL if last child

### getName

#### Function

Return name of node, or NULL if the node has no name

#### Prototype

    String getName()

#### Arguments

None

#### Returns

String -- Node's name

### getType

#### Function

Return numeric type-code for node

#### Prototype

    short getType()

#### Arguments

None

#### Returns

short -- Node's numeric type code

#### Type codes:

    ELEMENT_NODE
    ATTRIBUTE_NODE
    TEXT_NODE
    CDATA_SECTION_NODE
    ENTITY_REFERENCE_NODE
    ENTITY_NODE
    PROCESSING_INSTRUCTION_NODE
    COMMENT_NODE
    DOCUMENT_NODE
    DOCUMENT_TYPE_NODE
    DOCUMENT_FRAGMENT_NODE
    NOTATION_NODE

### getValue

#### Function

Return "value" (data) of node, or NULL if the node has no value

#### Prototype

    String getValue()

#### Arguments

None

#### Returns

String -- Node's "value"

### getOwnerDocument

#### Function

Return document node which contains the current node

#### Prototype

    Document* getOwnerDocument()

#### Arguments

None

#### Returns

Document* -- Pointer to document node

### getParentNode

#### Function

Return node's parent

#### Prototype

    Node* getParentNode()

#### Arguments

None

#### Returns

Node* -- Pointer to the node's parent node

### getPrefix

#### Function

Return the namespace prefix of node

#### Prototype

    String getPrefix()

#### Arguments

None

#### Returns

String -- Node's namespace prefix, may be NULL

### getPreviousSibling

#### Function

Returns the previous sibling of the node, that is, the child of its parent which came before

#### Prototype

    Node* getPreviousSibling()

#### Arguments

None

#### Returns

Node* -- Node's previous sibling, NULL if first child

### getQualifiedName

#### Function

Return the fully qualified (namespace) name of node

#### Prototype

    String getQualifiedName()

#### Arguments

None

#### Returns

String -- Node's qualified name

### hasAttributes

#### Function

Determine if node has any defined attributes

#### Prototype

    boolean hasAttributes()

#### Arguments

None

#### Returns

boolean -- TRUE if node has attributes

### hasChildNodes

#### Function

Determine if node has any children

#### Prototype

    boolean hasChildNodes()

#### Arguments

None

#### Returns

boolean -- TRUE if node has child nodes

### insertBefore

#### Function

Insert a new child node into the list of children of a parent, before the reference node. If refChild is NULL, appends the new node to the end.

#### Prototype

    Node* insertBefore(Node *newChild, Node *refChild)

#### Arguments

newChild -- new node to insert

refChild -- reference node; new node comes before

#### Returns

Node* -- newChild passed back

### numChildNodes

#### Function

Return count of node's children

#### Prototype

    uword numChildNodes()

#### Arguments

None

#### Returns

uword -- Number of children this node has (might be 0)

### removeChild

#### Function

Remove a child node from the current node's list of children

#### Prototype

    Node* removeChild(Node *oldChild)

#### Arguments

oldChild -- old node being removed

#### Returns

Node* -- oldChild is passed back

### replaceChild

#### Function

Replace one node with another. newChild replaces oldChild in the list of children in oldChild's parent.

#### Prototype

    Node* replaceChild(Node *newChild, Node *oldChild)

#### Arguments

newChild -- new replacement node

oldChild -- old node being replaced

#### Returns

Node* -- oldChild is passed back

### setValue

#### Function

Sets a node's "value" (data)

#### Prototype

    void setValue(String data)

#### Arguments

data -- New data for node

#### Returns

void

## Class: NodeList

This class contains methods for extracting nodes from a NodeList

item | Return nth node in list
getLength | Return number of nodes in list

### item

#### Function

Return nth node in node list

#### Prototype

    Node* item(size_t index)

#### Arguments

size_t index-- zero-based node number

#### Returns

Pointer to index'th node in list

### getLength

#### Function

Return number of nodes in list

#### Prototype

    size_t getLength()

#### Arguments

None

#### Returns

Number of nodes in list

## Class: Notation

This class implements the NOTATION node type, a subclass of Node.

getData | Return notation's data
getTarget | Return notation's target
setData | Set notation's data

### getData

#### Function

Return a notation's data

#### Prototype

    String getData()

#### Arguments

None

#### Returns

String -- node's data

### getTarget

#### Function

Return a notation's target

#### Prototype

    String getTarget()

#### Arguments

None

#### Returns

String -- node's target

### setData

#### Function

Set a notation's data

#### Prototype

    void setData(String data)

#### Arguments

data -- new data

#### Returns

None

## Class: ProcessingInstruction

This class implements the PROCESSING_INSTRUCTION node type, a subclass of Node.

getData | Return the PI's data
getTarget | Return the PI's target
setData | Set the PI's data

### getData

#### Function

Return data for a processing instruction

#### Prototype

    String getData()

#### Arguments

None

#### Returns

String -- PI's data

### getTarget

#### Function

Return a processing instruction's target value

#### Prototype

    String getTarget()

#### Arguments

None

#### Returns

String -- target value

### setData

#### Function

Set the data for a processing instruction

#### Prototype

    void setData(String data)

#### Arguments

data -- PI's new data

#### Returns

None

## Class: Text

This class contains methods for accessing and modifying the data associated with text nodes (subclasses CharacterData).

splitText | Get data (value) of text node

### splitText

#### Function

Split a text node in two. The original node retains its data up to the split point, and the remaining data is turned into a new text node which follows.

#### Prototype

    Text* splitText(unsigned long offset)

#### Arguments

offset -- split point

#### Returns

Text* -- Pointer to new text node

## Class: XMLParser

This class contains top-level methods for invoking the parser and returning high-level information about a document.

xmlinit | Initialize XML parser
xmlterm | Terminate XML parser
xmlparse | Parse a document from a file
xmlParseBuffer | Parse a document from a buffer
getContent | Returns the content model for an element
getModifier | Returns the modifier ('?', '*' or '+') for a content-model node
getDocument | Returns the root node of a parsed document
getDocumentElement | Returns the root element (node) of a parsed document
getDocType | Returns the document type string
isStandAlone | Returns the value of the standalone flag

### xmlinit

#### Function

Initialize XML parser

#### Prototype

    uword xmlinit(oratext *encoding,
                     void (*msghdlr)(void *msgctx, oratext *msg, ub4 errcode),
                     void *msgctx, lpxsaxcb *saxcb, void *saxcbctx, oratext *lang)

#### Arguments

encoding -- Input file's encoding, default UTF8
msghdlr -- Error message callback
msgctx -- User-defined context pointer passed to msghdlr
saxcb -- SAX callback structure (iff using SAX)
saxcbctx -- User-defined SAX context structure passed to SAX callback functions
lang -- Language for error message (not used)

#### Returns

uword -- Numeric error code, 0 meaning success

### xmlterm

#### Function

Terminate XML parser, tear down, free memory, etc

#### Prototype

    void xmlterm()

#### Arguments

None

#### Returns

    void

### xmlparse

#### Function

Parses a document

#### Prototype

    uword xmlparse(oratext *doc, oratext *encoding, ub4 flags)

#### Arguments

doc -- document path

encoding -- document's encoding

flags -- Mask of flag bits

#### Flags:

XML_FLAG_VALIDATE -- Validate document against DTD

XML_FLAG_DISCARD_WHITESPACE -- Discard ignorable whitespace

#### Returns

uword -- Error code, 0 on success

### xmlparseBuffer

#### Function

Parses a document

#### Prototype

    uword xmlparseBuffer(oratext *buffer, size_t len, oratext *encoding, ub4 flags)

#### Arguments

buffer -- buffer containing document to parse

len -- length of document

encoding -- document's encoding

flags -- Mask of flag bits

#### Flags:

XML_FLAG_VALIDATE -- Validate document against DTD

XML_FLAG_DISCARD_WHITESPACE -- Discard ignorable whitespace

#### Returns

uword -- Error code, 0 on success

### getContent

#### Function

Returns the content model for a node. Content model nodes are Nodes and can be traversed and examined with the same functions as the parsed document.

#### Prototype

    Node* getContent(Node *node)

#### Arguments

node -- node whose content model to return

#### Returns

Node* -- root node of content model tree

### getModifier

#### Function

Returns the modifier for a content model node. The modifier is one of XMLCPMOD_NONE (no modifier), XMLCPMOD_OPT ('?', optional), XMLCPMOD_0MORE ('*', zero or more), or XMLCPMOD_1MORE ('+', one or more).

#### Prototype

    xmlcpmod getContent(Node *node)

#### Arguments

node -- content model node whose modifer to return

#### Returns

xmlcpmod -- enumeration as described above

### getDocument

#### Function

After a document has been successfully parsed, returns a pointer to the root node of the document. Compare with getDocumentElement which returns the root element node.

#### Prototype

    Node* getDocument()

#### Arguments

None

#### Returns

Node* -- Pointer to root node of document

### getDocumentElement

#### Function

After a document has been successfully parsed, returns a pointer to the root element (node) of the document

#### Prototype

    Element* getDocumentElement()

#### Arguments

None

#### Returns

Element* -- Pointer to root element (node) of document

### getDocType

#### Function

Returns a pointer to a "DocType" structure which describes the DTD

#### Prototype

    DocumentType* getDocType()

#### Arguments

None

#### Returns

DocumentType* -- Pointer to DTD descriptor

### isStandalone

#### Function

Returns TRUE if the document is specified as standalone on the <?xml?> line, FALSE otherwise

#### Prototype

    boolean isStandalone()

#### Arguments

None

#### Returns

boolean -- Value of standalone flag

## C++ Parser APIs

### XMLParser

## C++ SAX API

The SAX API is based on callbacks. Instead of the entire document being parsed and turned into a data structure which may be referenced (by the DOM interface), the SAX interface is serial. As the document is processed, appropriate SAX user callback functions are invoked. Each callback function returns an error code, zero meaning success, any non-zero value meaning failure. If a non-zero code is returned, document processing is stopped.

To use SAX, an xmlsaxcb structure is initialized with function pointers and passed to the xmlinit() call. A pointer to a user-defined context structure may also be included; that context pointer will be passed to each SAX function.

Note this SAX functionality is identical to the C version.

### SAX callback structure

    typedef struct
    {
       sword (*)(void *ctx);
       sword (*)(void *ctx);
       sword (*)(void *ctx, const oratext *name, struct xmlarray *attrs);
       sword (*)(void *ctx, const oratext *name);
       sword (*)(void *ctx, const oratext *ch, size_t len);
       sword (*)(void *ctx, const oratext *ch, size_t len);
       sword (*)(void *ctx, const oratext *target, const oratext *data);
       sword (*)(void *ctx, const oratext *name,
                             const oratext *publicId, const oratext *systemId);
       sword (*)(void *ctx, const oratext *name, const oratext *publicId,
                                   const oratext *systemId, const oratext
    *notationName);
       sword (*)(void *ctx, const oratext *qname,
                               const oratext *local, const oratext *namespace);
    } xmlsaxcb;

### startDocument

#### Function

Called once when document processing is first starting

#### Prototype

    sword startDocument(void *ctx)

#### Arguments

ctx -- User-defined context as passed to initialize()

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### endDocument

#### Function

Called once when document processing is finished

#### Prototype

    sword endDocument(void *ctx)

#### Arguments

ctx -- User-defined context as passed to initialize()

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### startElement

#### Function

Called once for each new document element

#### Prototype

    sword startElement(void *ctx, const oratext *name, struct xmlarray *attrs)

#### Arguments

ctx -- User-defined context as passed to initialize()

name -- name of node

attrs -- array of node's attributes

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### endElement

#### Function

Called once when each document element closes

#### Prototype

    sword endElement(void *ctx, const oratext *name)

#### Arguments

ctx -- User-defined context as passed to initialize()

name -- name of node

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### characters

#### Function

Called for each piece of literal text

#### Prototype

    sword characters(void *ctx, const oratext *ch, size_t len)

#### Arguments

ctx -- User-defined context as passed to initialize()

ch -- pointer to text

len -- number of character in text

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### IgnorableWhitespace

#### Function

Called for each piece of ignorable (non-significant) whitespace

#### Prototype

    sword ignorableWhitespace(void *ctx, const oratext *ch, size_t len)

#### Arguments

ctx -- User-defined context as passed to initialize()

ch -- pointer to whitespace text

len -- number of characters of whitespace

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### processingInstruction

#### Function

Called once for each PI (Processing Instruction)

#### Prototype

    sword processingInstruction(void *ctx, const oratext *target,
                                const oratext *data)

#### Arguments

ctx -- User-defined context as passed to initialize()

target -- PI target

data -- PI data

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### notationDecl

#### Function

Called once for each NOTATION

#### Prototype

    sword notationDecl(void *ctx, const oratext *name,
                       const oratext *publicId, const oratext *systemId)

#### Arguments

ctx -- User-defined context as passed to initialize()

name -- name of notation

publicId -- Public ID

systemId -- System ID

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### unparsedEntityDecl

#### Function

Called once for each unparsed entity declaration

#### Prototype

    sword unparsedEntityDecl(void *ctx, const oratext *name, const oratext
    *publicId,
                             const oratext *systemId, const oratext *notationName)

#### Arguments

ctx -- User-defined context as passed to initialize()

name -- name of entity

publicId -- Public ID

systemId -- System ID

notationName -- notation name

#### Returns

sword -- Error code, 0 for success, non-0 for error.

### nsStartElement

#### Function

Namespace variant of startElement: Called once for each new document element, when the element uses uses an explicit namespace

#### Prototype

    sword startElement(void *ctx, const oratext *qname,
                       const oratext *local, const oratext *namespace)

#### Arguments

ctx -- User-defined context as passed to initialize()

qname -- qualified namespace

local -- umm

namespace -- yes, well

#### Returns

sword -- Error code, 0 for success, non-0 for error.

## C++ DOM API's

### Class (Subclass)

Attr | Node
CDATASection | Text
CharacterData | Node
Comment | CharacterData
Document | Node
DocumentFragment | Node
DocumentType | Node
DOMImplementation |
Element | Node
Entity | Node
EntityReference | Node
NamedNodeMap |
Node |
NodeList |
Notation | Node
ProcessingInstruction | Node
Text | CharacterData

####

####

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index