Oracle® XML Reference 10g (9.0.4) Part Number B10926-01 |
|
This chapter contains the following sections:
Accessing the name and value of a single document node attribute.
Method | Description |
---|---|
Returns name of an attribute. |
|
Returns definition of an attribute. |
|
Returns attribute's "specified" flag value. |
|
Sets an attribute's value. |
Returns name of an attribute.
String getName()
Returns the definition of an attribute.
String getValue()
Returns value of attribute's "specified" flag. The DOM specifies"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()
Sets an attribute's "value".
void setValue(String value)
Parameter | Description |
---|---|
value |
Attribute's new value |
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. Returns a pointer to node.
Attr* createAttribute(String name)
Parameter | Description |
---|---|
name |
name of attribute |
Create a new CDATA node with the given contents. Returns a pointer to node.
Attr* createCDATASection(String name)
Parameter | Description |
---|---|
data |
contents of node |
Create a new comment node with the given contents. Returns a pointer to node.
Comment* createComment(String data)
Parameter | Description |
---|---|
data |
contents of node |
Create a new document fragment node. Returns a pointer to created node.
DocumentFragment* createDocumentFragment()
Create a new element node with the given (tag) name. Returns a pointer to node.
Element* createElement(String tagName)
Parameter | Description |
---|---|
tagName |
element's tag name |
Create a new entity reference node. Returns a pointer to created node.
EntityReference* createEntityReference(String name)
Parameter | Description |
---|---|
name |
name of entity to reference |
Create a new processing instruction node. Returns a pointer to created node.
ProcessingInstruction* createProcessingInstruction(String target, String data)
Parameter | Description |
---|---|
target |
target part of PI |
data |
data for node |
Create a new TEXT node. Returns a pointer to created node.
Text* createTextNode(String data)
Parameter | Description |
---|---|
data |
data for 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. Returns list of matches, NULL if none.
NodeList* getElementsByTagName(String tagname)
Parameter | Description |
---|---|
tagname |
tag name to select |
Returns the DOMImplementation structure, currently useless. Perhaps it will be used in later DOM versions. Returns pointer to structure.
DOMImplementation* getImplementation()
This class contains methods for accessing information about the Document Type Definition (DTD) of a document.
Method | Description |
---|---|
Returns name of DTD. |
|
Returns map of DTD's entities. |
|
Returns map of DTD's notations. |
Return name of DTD.
String getName()
Returns map of DTD's (general) entities.
NamedNodeMap* getEntities()
Returns map of DTD's notations.
NamedNodeMap* getNotations()
This class contains methods relating to the specific DOM implementation supported by the parser.
Test if the DOM implementation implements a specific feature. Returns TRUE if the feature is supported.
boolean hasFeature(DOMString feature, DOMString version)
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()
Return "value" (definition) of named attribute
String getAttribute(String name)
Parameter | Description |
---|---|
name |
name of attribute |
Create a new attribute.
Attr* setAttribute(String name, String value)
Parameter | Description |
---|---|
name |
name of new attribute |
value |
value of new attribute |
Removes the named attribute
void removeAttribute(String name)
Parameter | Description |
---|---|
name |
name of attribute to remove |
Return pointer to named attribute.
Attr* getAttributeNode(DOMString name)
Parameter | Description |
---|---|
naem |
name of attribute |
Set (add) new attribute. Returns TRUE on success.
boolean setAttributeNode(Attr* newAttr, Attr** oldAttr)
Parameter | Description |
---|---|
newAttr |
pointer to new attribute |
oldAttr |
returned pointer to replaced attribute |
Remove the named attribute
Attr* removeAttributeNode(Attr* oldAttr)
Parameter | Description |
---|---|
oldAttr |
attribute to remove |
Create a list of matching elements.
NodeList* getElementsByTagName(DOMString name)
Parameter | Description |
---|---|
name |
tagname to match, "*" for all |
Normalize an element, i.e. merge all adjacent TEXT nodes.
void normalize(void)
This class implements the ENTITY node type, a subclass of Node.
Method | Description |
---|---|
Return entity's NDATA (notation name) |
|
Return entity's public ID |
|
Return entity's system ID |
Return an entity node's notation name NDATA.
String* getNotationName()
Return an entity node's public ID.
String getPublicId()
Return an entity node's system ID.
String getSystemId()
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.
Method | Description |
---|---|
Return nth node in map. |
|
Return number of nodes in map |
|
Select a node by name |
|
Set a node into the map |
|
Remove the named node from map |
Return nth node in node map.
Node* item(size_t index)
Parameter | Description |
---|---|
index |
zero-based node number |
Return number of nodes in map.
size_t getLength()
Selects the node with the given name from the map.
Node* getNamedItem(String name)
Parameter | Description |
---|---|
name |
name of node to select |
Adds a node to the map replacing any node that already exists with the same name.
boolean setNamedItem(Node *node, Node **old)
Parameter | Description |
---|---|
node |
Name of node to add |
old |
Pointer to replaced node, NULL if node is new |
Removes the node with the given name from the node map.
Node* removeNamedItem(String name)
Parameter | Description |
---|---|
name |
name of node to remove |
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)
Parameter | Description |
---|---|
newChild |
new child node |
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)
Parameter | Description |
---|---|
deep |
recursion flag |
Return structure of all attributes for node
NamedNodeMap* getAttributes()
Return one of the node's children.
Node* getChildNode(uword index)
Parameter | Description |
---|---|
index |
child number, starting at 0 |
Return node's children.
NodeList* getChildNodes()
Return the node's first child.
Node* getFirstChild()
Return the node's last child.
Node* getLastChild()
Return the node's local name.
String getLocal()
Return the node's namespace.
String getNamespace()
Returns the next sibling of the node.
Node* getNextSibling()
Return name of node, or NULL if the node has no name.
String getName()
Return numeric type-code for node. These include 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
.
short getType()
Return "value" (data) of node, or NULL if the node has no value.
String getValue()
Return document node which contains the current node.
Document* getOwnerDocument()
Return node's parent.
Node* getParentNode()
Return the namespace prefix of node.
String getPrefix()
Returns the previous sibling of the node.
Node* getPreviousSibling()
Return the fully qualified (namespace) name of node.
String getQualifiedName()
Determine if node has any defined attributes.
boolean hasAttributes()
Determine if node has any children.
boolean hasChildNodes()
Insert a new child node before the reference node into the list of children nodes.
Node* insertBefore(Node *newChild, Node *refChild)
Parameter | Description |
---|---|
newChild |
new node to insert |
refChild |
reference node; new node comes before |
Return count of node's children.
uword numChildNodes()
Removes a child node from the current node's list of children.
Node* removeChild(Node *oldChild)
Parameter | Description |
---|---|
oldChild |
old node being removed |
Replaces one node in the list of children with another.
Node* replaceChild(Node *newChild, Node *oldChild)
Parameter | Description |
---|---|
newChild |
new replacement node |
oldChild |
old node being replaced |
Sets a node's "value" (data)
void setValue(String data)
Parameter | Description |
---|---|
data |
New data for node |
This class contains methods for extracting nodes from a NodeList
Method | Description |
---|---|
Return nth node in list. |
|
Return number of nodes in list |
Return nth node in node list.
Node* item(size_t index)
Parameter | Description |
---|---|
index |
zero-based node number |
Return number of nodes in list.
size_t getLength()
This class implements the NOTATION node type, a subclass of Node.
Method | Description |
---|---|
Return notation's data |
|
Return notation's target |
|
Set notation's data |
Return a notation's data.
String getData()
Return a notation's target.
String getTarget()
Set a notation's data
void setData(String data)
Parameter | Description |
---|---|
data |
new data |
Implements the PROCESSING_INSTRUCTION node type, a subclass of Node.
Method | Description |
---|---|
Return the PI's data. |
|
Return the PI's target. |
|
Set the PI's data. |
Return data for a processing instruction.
String getData()
Return a processing instruction's target value.
String getTarget()
Set the data for a processing instruction.
void setData(String data)
Parameter | Description |
---|---|
data |
PI's new data |
Accesses and modifies the data associated with text nodes (subclasses CharacterData).
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. Returns the pointer to new text node.
Text* splitText(unsigned long offset)
Parameter | Description |
---|---|
offset |
split point |
This class contains top-level methods for invoking the parser and returning high-level information about a document.
Initialize XML parser. Returns error code, 0 on success.
uword xmlinit(oratext *encoding, void (*msghdlr)(void *msgctx, oratext *msg, ub4 errcode), void *msgctx, lpxsaxcb *saxcb, void *saxcbctx, oratext *lang)
Terminate XML parser, tear down, free memory, and so on.
void xmlterm()
Parses a document. Returns error code, 0 on success.
uword xmlparse(oratext *doc, oratext *encoding, ub4 flags)
Parameter | Description |
---|---|
doc |
document path |
encoding |
document's encoding |
flags |
Mask of flag bits: |
Parses a document. Returns error code, 0 on success.
uword xmlparseBuffer(oratext *buffer, size_t len, oratext *encoding, ub4 flags)
Parameter | Description |
---|---|
buffer |
buffer containing document to parse |
len |
length of document |
encoding |
document's encoding |
flags |
Mask of flag bits |
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)
Parameter | Description |
---|---|
node |
content model node whose modifer to return |
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)
Parameter | Description |
---|---|
node |
content model node whose modifer to return |
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. Pointer to root node of document.
Node* getDocument()
Returns a pointer to the root element (node) of a parsed document.
Element* getDocumentElement()
Element* -- Pointer to root element (node) of document
Returns a pointer to a "DocType" structure which describes the DTD.
DocumentType* getDocType()
Returns TRUE if the document is specified as standalone on the <?xml?> line, FALSE otherwise. Value of standalone flag.
boolean isStandalone()
Returns a flag which specifies whether the current document is encoded as single-byte characters, ASCII, or multi-byte characters, UTF-8. Compare to getEncoding, which Returns the actual name of the document's encoding.
boolean isSingleChar()
Returns the name of the current document's character encoding scheme, such as ASCII, UTF8, and so on. Compare to isSingleChar which just returns a boolean flag saying whether the current encoding is single or multi-byte.
String getEncoding()
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.
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. Returns error code, 0 for success, non-0 for error.
sword startDocument(void *ctx)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
Called once when document processing is finished. Returns error code, 0 for success, non-0 for error.
sword endDocument(void *ctx)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
Called once for each new document element. Returns error code, 0 for success, non-0 for error.
sword startElement(void *ctx, const oratext *name, struct xmlarray *attrs)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
name |
name of node |
attrs |
array of node's attributes |
Called once when each document element closes. Returns error code, 0 for success, non-0 for error.
sword endElement(void *ctx, const oratext *name)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
name |
name of node |
Called for each piece of literal text. Error code, 0 for success, non-0 for error.
sword characters(void *ctx, const oratext *ch, size_t len)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
ch |
pointer to text |
len |
number of character in text |
Called for each piece of ignorable (non-significant) whitespace. Returns error code, 0 for success, non-0 for error.
sword ignorableWhitespace(void *ctx, const oratext *ch, size_t len)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
ch |
pointer to whitespace text |
len |
number of characters of whitespace |
Called once for each PI (Processing Instruction). Returns error code, 0 for success, non-0 for error.
sword processingInstruction(void *ctx, const oratext *target, const oratext *data)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
target |
PI target |
data |
PI data |
Called once for each NOTATION. Returns error code, 0 for success, non-0 for error.
sword notationDecl(void *ctx, const oratext *name, const oratext *publicId, const oratext *systemId)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
name |
name of notation |
publicId |
Public ID |
systemId |
System ID |
Called once for each unparsed entity declaration. Returns error code, 0 for success, non-0 for error.
sword unparsedEntityDecl( void *ctx, const oratext *name, const oratext *publicId, const oratext *systemId, const oratext *notationName)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
name |
name of entity |
publicId |
Public ID |
systemId |
System ID |
notationName |
notation name |
Namespace variant of startElement: called once for each new document element, when the element uses an explicit namespace. Returns error code, 0 for success, non-0 for error.
sword startElement(void *ctx, const oratext *qname, const oratext *local, const oratext *namespace)
Parameter | Description |
---|---|
ctx |
User-defined context as passed to initialize() |
qname |
qualified namespace |
local |
umm |
namespace |
yes, well |
|
Copyright © 2001, 2003 Oracle Corporation. All Rights Reserved. |
|