Oracle8i XML Reference Guide Release 3 (8.1.7) Part Number A83730-01 |
|
This chapter describes the following sections:
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 |
Return name of attribute
String getName()
None
String -- Name of attribute
Return "value" (definition) of attribute
String getValue()
None
Value of attribute
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).
boolean getSpecified()
None
Value of specified flag
Sets an attribute's "value"
void setValue(String value)
value -- Attribute's new value
Value of attribute
This class implements the CDATA node type, a subclass of Text.
This class implements the COMMENT node type, a subclass of CharacterData.
This class contains methods for creating and retrieving nodes.
Create a new attribute node. Use setValue to set its value.
Attr* createAttribute(String name)
name -- name of attribute
Attr* -- pointer to created node
Create a new CDATA node with the given contents.
Attr* createCDATASection(String name)
data -- contents of node
CDATASection* -- pointer to created node
Create a new comment node with the given contents.
Comment* createComment(String data)
data -- contents of node
Comment* -- pointer to created node
Create a new document fragment node.
DocumentFragment* createDocumentFragment()
None
DocumentFragment* -- pointer to created node
Create a new element node with the given (tag) name.
Element* createElement(String tagName)
tagName -- element's tagname
Element* -- pointer to created node
Create a new entity reference node.
EntityReference* createEntityReference(String name)
name -- name of entity to reference
EntityReference* -- pointer to created node
Create a new processing instruction node.
ProcessingInstruction* createProcessingInstruction(String target, String data)
target -- target part of PI
data -- data for node
ProcessingInstruction* -- pointer to created node
Create a new TEXT node.
Text* createTextNode(String data)
data -- data for node
Text* -- pointer to created node
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.
NodeList* getElementsByTagName(String tagname)
tagname -- tag name to select
NodeList* -- list of matches, NULL if none
Returns the DOMImplementation structure, currently useless. Perhaps it will be used in later DOM versions.
DOMImplementation* getImplementation()
None
DOMImplementation* -- pointer to structure
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 |
Return name of DTD
String getName()
None
String -- Name of DTD
Returns map of DTD's (general) entities
NamedNodeMap* getEntities()
None
NamedNodeMap* -- map of entities
Return map of DTD's notations
NamedNodeMap* getNotations()
None
NamedNodeMap* -- map of notations
This class contains methods relating to the specific DOM implementation supported by the parser.
hasFeature |
Detect if the named feature is supported |
Test if the DOM implementation implements a specific feature.
boolean hasFeature(DOMString feature, DOMString version)
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.
boolean -- feature is supported
This class contains methods pertaining to element nodes.
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
String getTagName()
None
String -- Tag name of node
Return "value" (definition) of named attribute
String getAttribute(String name)
name -- name of attribute
Value of attribute
Create a new attribute
Attr* setAttribute(String name, String value)
name -- name of new attribute
value -- value of new attribute
Pointer to create attribute
Removes the named attribute
void removeAttribute(String name)
name -- name of attribute to remove
None
Return pointer to named attribute
Attr* getAttributeNode(DOMString name)
name -- name of attribute
Attr* -- pointer to attribute, or NULL if none such
Set (add) new attribute
boolean setAttributeNode(Attr* newAttr, Attr** oldAttr)
newAttr -- pointer to new attribute
oldAttr -- returned pointer to replaced attribute
boolean -- success
Remove the named attribute
Attr* removeAttributeNode(Attr* oldAttr)
oldAttr -- attribute to remove
Attr* -- oldAttr passed back
Create a list of matching elements
NodeList* getElementsByTagName(DOMString name)
name -- tagname to match, "*" for all
NodeList* -- list of matches
Normalize an element, i.e. merge all adjacent TEXT nodes
void normalize(void)
None
None
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 |
Return an entity node's notation name (NDATA)
String* getNotationName()
None
String -- node's NDATA
Return an entity node's public ID
String getPublicId()
None
String -- entity's public ID
Return an entity node's system ID
String getSystemId()
None
String -- entity's system ID
This class implements the ENTITY_REFERENCE node type, a subclass of Node.
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 |
Return nth node in node map
Node* item(size_t index)
size_t index-- zero-based node number
Node* -- Pointer to index'th node in map
Return number of nodes in map
size_t getLength()
None
size_t -- Number of nodes in map
Selects the node with the given name from the map
Node* getNamedItem(String name)
name -- Name of node to select
Node* -- Pointer to named node, NULL of none such exists
Adds a node to the map, replacing any node that already exists with the same name
boolean setNamedItem(Node *node, Node **old)
node -- Name of node to add
old -- Pointer to replaced node, NULL if node is new
boolean -- Success
Removes the node with the given name from the node map
Node* removeNamedItem(String name)
name -- Name of node to remove
Node* -- Pointer to removed node, NULL if none such exists
This class contains methods for details about a document node
Append a new child to the current node's list of children
Node* appendChild(Node *newChild)
newChild -- new child node
Node* -- newChild is passed back
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.
Node* cloneNode(boolean deep)
deep -- recursion flag
Node* -- Pointer to new clone
Return structure of all attributes for node
NamedNodeMap* getAttributes()
None
NamedNodeMap* -- Pointer to structure describing all attributes for node, or NULL if no attributes are defined
Return one of the node's children
Node* getChildNode(uword index)
index -- child number, starting at 0
Node* -- Pointer to index'th child of node
Return node's children
NodeList* getChildNodes()
None
NodeList* -- Pointer to structure describing all the node's children
Return the node's first child
Node* getFirstChild()
None
Node* -- Pointer to the node's first child
Return the node's last child
Node* getLastChild()
None
Node* -- Pointer to the node's last child
Return the node's local name
String getLocal()
None
String -- node's local name
Return the node's namespace
String getNamespace()
None
String -- node's namespace (may be NULL)
Returns the next sibling of the node, that is, the child of its parent which comes next
Node* getNextSibling()
None
Node* -- Node's next sibling, NULL if last child
Return name of node, or NULL if the node has no name
String getName()
None
String -- Node's name
Return numeric type-code for node
short getType()
None
short -- Node's numeric type code
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
Return "value" (data) of node, or NULL if the node has no value
String getValue()
None
String -- Node's "value"
Return document node which contains the current node
Document* getOwnerDocument()
None
Document* -- Pointer to document node
Return node's parent
Node* getParentNode()
None
Node* -- Pointer to the node's parent node
Return the namespace prefix of node
String getPrefix()
None
String -- Node's namespace prefix, may be NULL
Returns the previous sibling of the node, that is, the child of its parent which came before
Node* getPreviousSibling()
None
Node* -- Node's previous sibling, NULL if first child
Return the fully qualified (namespace) name of node
String getQualifiedName()
None
String -- Node's qualified name
Determine if node has any defined attributes
boolean hasAttributes()
None
boolean -- TRUE if node has attributes
Determine if node has any children
boolean hasChildNodes()
None
boolean -- TRUE if node has child nodes
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.
Node* insertBefore(Node *newChild, Node *refChild)
newChild -- new node to insert
refChild -- reference node; new node comes before
Node* -- newChild passed back
Return count of node's children
uword numChildNodes()
None
uword -- Number of children this node has (might be 0)
Remove a child node from the current node's list of children
Node* removeChild(Node *oldChild)
oldChild -- old node being removed
Node* -- oldChild is passed back
Replace one node with another. newChild replaces oldChild in the list of children in oldChild's parent.
Node* replaceChild(Node *newChild, Node *oldChild)
newChild -- new replacement node
oldChild -- old node being replaced
Node* -- oldChild is passed back
Sets a node's "value" (data)
void setValue(String data)
data -- New data for node
void
This class contains methods for extracting nodes from a NodeList
item |
Return nth node in list |
getLength |
Return number of nodes in list |
Return nth node in node list
Node* item(size_t index)
size_t index-- zero-based node number
Pointer to index'th node in list
Return number of nodes in list
size_t getLength()
None
Number of nodes in list
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 |
Return a notation's data
String getData()
None
String -- node's data
Return a notation's target
String getTarget()
None
String -- node's target
Set a notation's data
void setData(String data)
data -- new data
None
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 |
Return data for a processing instruction
String getData()
None
String -- PI's data
Return a processing instruction's target value
String getTarget()
None
String -- target value
Set the data for a processing instruction
void setData(String data)
data -- PI's new data
None
This class contains methods for accessing and modifying the data associated with text nodes (subclasses CharacterData).
splitText |
Get data (value) of text node |
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.
Text* splitText(unsigned long offset)
offset -- split point
Text* -- Pointer to new text node
This class contains top-level methods for invoking the parser and returning high-level information about a document.
Initialize XML parser
uword xmlinit(oratext *encoding, void (*msghdlr)(void *msgctx, oratext *msg, ub4 errcode), void *msgctx, lpxsaxcb *saxcb, void *saxcbctx, oratext *lang)
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)
uword -- Numeric error code, 0 meaning success
Terminate XML parser, tear down, free memory, etc
void xmlterm()
None
void
Parses a document
uword xmlparse(oratext *doc, oratext *encoding, ub4 flags)
doc -- document path
encoding -- document's encoding
flags -- Mask of flag bits
XML_FLAG_VALIDATE -- Validate document against DTD
XML_FLAG_DISCARD_WHITESPACE -- Discard ignorable whitespace
uword -- Error code, 0 on success
Parses a document
uword xmlparseBuffer(oratext *buffer, size_t len, oratext *encoding, ub4 flags)
buffer -- buffer containing document to parse
len -- length of document
encoding -- document's encoding
flags -- Mask of flag bits
XML_FLAG_VALIDATE -- Validate document against DTD
XML_FLAG_DISCARD_WHITESPACE -- Discard ignorable whitespace
uword -- Error code, 0 on success
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.
Node* getContent(Node *node)
node -- node whose content model to return
Node* -- root node of content model tree
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).
xmlcpmod getContent(Node *node)
node -- content model node whose modifer to return
xmlcpmod -- enumeration as described above
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.
Node* getDocument()
None
Node* -- Pointer to root node of document
After a document has been successfully parsed, returns a pointer to the root element (node) of the document
Element* getDocumentElement()
None
Element* -- Pointer to root element (node) of document
Returns a pointer to a "DocType" structure which describes the DTD
DocumentType* getDocType()
None
DocumentType* -- Pointer to DTD descriptor
Returns TRUE if the document is specified as standalone on the <?xml?> line, FALSE otherwise
boolean isStandalone()
None
boolean -- Value of standalone flag
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.
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;
Called once when document processing is first starting
sword startDocument(void *ctx)
ctx -- User-defined context as passed to initialize()
sword -- Error code, 0 for success, non-0 for error.
Called once when document processing is finished
sword endDocument(void *ctx)
ctx -- User-defined context as passed to initialize()
sword -- Error code, 0 for success, non-0 for error.
Called once for each new document element
sword startElement(void *ctx, const oratext *name, struct xmlarray *attrs)
ctx -- User-defined context as passed to initialize()
name -- name of node
attrs -- array of node's attributes
sword -- Error code, 0 for success, non-0 for error.
Called once when each document element closes
sword endElement(void *ctx, const oratext *name)
ctx -- User-defined context as passed to initialize()
name -- name of node
sword -- Error code, 0 for success, non-0 for error.
Called for each piece of literal text
sword characters(void *ctx, const oratext *ch, size_t len)
ctx -- User-defined context as passed to initialize()
ch -- pointer to text
len -- number of character in text
sword -- Error code, 0 for success, non-0 for error.
Called for each piece of ignorable (non-significant) whitespace
sword ignorableWhitespace(void *ctx, const oratext *ch, size_t len)
ctx -- User-defined context as passed to initialize()
ch -- pointer to whitespace text
len -- number of characters of whitespace
sword -- Error code, 0 for success, non-0 for error.
Called once for each PI (Processing Instruction)
sword processingInstruction(void *ctx, const oratext *target, const oratext *data)
ctx -- User-defined context as passed to initialize()
target -- PI target
data -- PI data
sword -- Error code, 0 for success, non-0 for error.
Called once for each NOTATION
sword notationDecl(void *ctx, const oratext *name, const oratext *publicId, const oratext *systemId)
ctx -- User-defined context as passed to initialize()
name -- name of notation
publicId -- Public ID
systemId -- System ID
sword -- Error code, 0 for success, non-0 for error.
Called once for each unparsed entity declaration
sword unparsedEntityDecl(void *ctx, const oratext *name, const oratext *publicId, const oratext *systemId, const oratext *notationName)
ctx -- User-defined context as passed to initialize()
name -- name of entity
publicId -- Public ID
systemId -- System ID
notationName -- notation name
sword -- Error code, 0 for success, non-0 for error.
Namespace variant of startElement: Called once for each new document element, when the element uses uses an explicit namespace
sword startElement(void *ctx, const oratext *qname, const oratext *local, const oratext *namespace)
ctx -- User-defined context as passed to initialize()
qname -- qualified namespace
local -- umm
namespace -- yes, well
sword -- Error code, 0 for success, non-0 for error.
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|