2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is the Sablotron XSLT Processor.
14 * The Initial Developer of the Original Code is Ginger Alliance Ltd.
15 * Portions created by Ginger Alliance are Copyright (C) 2000-2002
16 * Ginger Alliance Ltd. All Rights Reserved.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU General Public License Version 2 or later (the
22 * "GPL"), in which case the provisions of the GPL are applicable
23 * instead of those above. If you wish to allow use of your
24 * version of this file only under the terms of the GPL and not to
25 * allow others to use your version of this file under the MPL,
26 * indicate your decision by deleting the provisions above and
27 * replace them with the notice and other provisions required by
28 * the GPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under either the MPL or the
38 //used for DISABLE_DOM only anything else is DANGEROUS
53 typedef void* SDOM_Node;
54 typedef void* SDOM_NodeList;
55 /* typedef void* SDOM_Document; */
59 SDOM_ELEMENT_NODE = 1,
60 SDOM_ATTRIBUTE_NODE = 2,
62 SDOM_CDATA_SECTION_NODE = 4,
63 SDOM_ENTITY_REFERENCE_NODE = 5,
65 SDOM_PROCESSING_INSTRUCTION_NODE = 7,
66 SDOM_COMMENT_NODE = 8,
67 SDOM_DOCUMENT_NODE = 9,
68 SDOM_DOCUMENT_TYPE_NODE = 10,
69 SDOM_DOCUMENT_FRAGMENT_NODE = 11,
70 SDOM_NOTATION_NODE = 12,
71 SDOM_OTHER_NODE /* not in spec */
76 * we define DOM_char as char, although the spec says strings should be
77 * UTF_16. Needs check.
79 typedef char SDOM_char;
84 * will be an enum of all the values given in the spec.
90 HIERARCHY_REQUEST_ERR, 3
92 INVALID_CHARACTER_ERR, 5
93 NO_DATA_ALLOWED_ERR, 6
94 NO_MODIFICATION_ALLOWED_ERR, 7
97 INUSE_ATTRIBUTE_ERR, 10
100 INVALID_MODIFICATION_ERR, 13
102 INVALID_ACCESS_ERR, 15
108 SDOM_INDEX_SIZE_ERR = 1,
109 SDOM_DOMSTRING_SIZE_ERR = 2,
110 SDOM_HIERARCHY_REQUEST_ERR = 3,
111 SDOM_WRONG_DOCUMENT_ERR = 4,
112 SDOM_INVALID_CHARACTER_ERR = 5,
113 SDOM_NO_DATA_ALLOWED_ERR = 6,
114 SDOM_NO_MODIFICATION_ALLOWED_ERR = 7,
115 SDOM_NOT_FOUND_ERR = 8,
116 SDOM_NOT_SUPPORTED_ERR = 9,
117 SDOM_INUSE_ATTRIBUTE_ERR = 10,
118 SDOM_INVALID_STATE_ERR = 11,
119 SDOM_SYNTAX_ERR = 12,
120 SDOM_INVALID_MODIFICATION_ERR = 13,
121 SDOM_NAMESPACE_ERR = 14,
122 SDOM_INVALID_ACCESS_ERR = 15,
123 /* not in spec below this point: */
124 SDOM_INVALID_NODE_TYPE, /* eg passing a non-element for an element */
125 SDOM_QUERY_PARSE_ERR,
126 SDOM_QUERY_EXECUTION_ERR,
133 ** n is always the node the function is to operate on (kind of 'this')
139 Creates a new element Node with NULL parent and specified owner,
140 and returns it in *pn.
144 SDOM_Exception SDOM_createElement(
148 const SDOM_char *tagName);
154 Creates a new element Node with NULL parent and specified owner,
155 and returns it in *pn.
157 SDOM_NAMESPACE_ERR or SDOM_INVALID_CHARACTER_ERR when qName or uri malformed
160 SDOM_Exception SDOM_createElementNS(
164 const SDOM_char *uri,
165 const SDOM_char *qName);
171 Creates a new attribute Node and returns it in *pn.
177 SDOM_Exception SDOM_createAttribute(
181 const SDOM_char *name);
187 Creates a new attribute Node and returns it in *pn.
189 SDOM_NAMESPACE_ERR or SDOM_INVALID_CHARACTER_ERR when qName or uri malformed
192 SDOM_Exception SDOM_createAttributeNS(
196 const SDOM_char *uri,
197 const SDOM_char *qName);
209 SDOM_Exception SDOM_createTextNode(
213 const SDOM_char *data);
218 Creates a new attribute Node and returns it in *pn.
224 SDOM_Exception SDOM_createCDATASection(
228 const SDOM_char *data);
238 SDOM_Exception SDOM_createComment(
242 const SDOM_char *data);
246 createProcessingInstruction
252 SDOM_Exception SDOM_createProcessingInstruction(
256 const SDOM_char *target,
257 const SDOM_char *data);
262 Frees all memory used by the node.
264 !SPEC: Not in the spec.
269 SDOM_Exception SDOM_disposeNode(
277 Returns the node type in *pType.
283 SDOM_Exception SDOM_getNodeType(
286 SDOM_NodeType *pType);
292 Returns the pointer to the name of the node in *pName.
297 SDOM_Exception SDOM_getNodeName(
305 SDOM_Exception SDOM_getNodeNSUri(
313 SDOM_Exception SDOM_getNodePrefix(
321 SDOM_Exception SDOM_getNodeLocalName(
332 SDOM_Exception SDOM_setNodeName(
335 const SDOM_char *name);
340 Returns in *pValue the string value of the node.
343 SDOM_Exception SDOM_getNodeValue(
354 SDOM_Exception SDOM_setNodeValue(
357 const SDOM_char *value);
362 Returns the parent in *pParent.
365 SDOM_Exception SDOM_getParentNode(
373 Returns the first child in *pFirstChild.
376 SDOM_Exception SDOM_getFirstChild(
379 SDOM_Node *pFirstChild);
384 Returns the last child in *pLastChild.
387 SDOM_Exception SDOM_getLastChild(
390 SDOM_Node *pLastChild);
395 Returns the previous sibling in *pPreviousSibling.
398 SDOM_Exception SDOM_getPreviousSibling(
401 SDOM_Node *pPreviousSibling);
406 Returns the next sibling in *pNextSibling.
409 SDOM_Exception SDOM_getNextSibling(
412 SDOM_Node *pNextSibling);
417 Returns the child node in specified index or NULL.
420 SDOM_Exception SDOM_getChildNodeIndex(
424 SDOM_Node *pChildNode);
429 Returns the count of child nodes.
432 SDOM_Exception SDOM_getChildNodeCount(
440 Returns, in *pOwnerDocument, the Document owning the node.
441 !SPEC: If the node is standalone, returns NULL.
444 SDOM_Exception SDOM_getOwnerDocument(
447 SDOM_Document *pOwnerDocument);
452 Inserts newChild as n's child, just before refChild.
455 SDOM_Exception SDOM_insertBefore(
464 Removes oldChild (a child of n) without deallocating it.
468 SDOM_Exception SDOM_removeChild(
476 Replaces oldChild (a child of n) by newChild.
479 SDOM_Exception SDOM_replaceChild(
488 Appends newChild as the last of n's children.
491 SDOM_Exception SDOM_appendChild(
499 Duplicates the node, returning the result in *clone.
500 If deep is nonzero, the cloning process will be recursive.
504 SDOM_Exception SDOM_cloneNode(
513 Duplicates a node from a different doc, returning the result in *clone.
514 If deep is nonzero, the cloning process will be recursive.
515 As opposed to cloneNode, represents a Document method
519 SDOM_Exception SDOM_cloneForeignNode(
529 Returns, in *pValue, the contents of the attribute (of n) named 'name'.
532 SDOM_Exception SDOM_getAttribute(
535 const SDOM_char *name,
541 Returns, in *pValue, the contents of the attribute (of n) with 'uri' and 'local'.
544 SDOM_Exception SDOM_getAttributeNS(
554 Returns, in *attr, the attribute named 'name'.
557 SDOM_Exception SDOM_getAttributeNode(
560 const SDOM_char *name,
566 Returns, in *attr, the n's attribute with uri and local.
569 SDOM_Exception SDOM_getAttributeNodeNS(
579 getAttributeNodeIndex
580 Returns, in *attr, the index'th attribute, namespaces precede other atts.
583 SDOM_Exception SDOM_getAttributeNodeIndex(
591 getAttributeNodeCount
592 Returns, in *count, the count of atts, including namespaces in scope.
595 SDOM_Exception SDOM_getAttributeNodeCount(
604 Assigns the given value to n's attribute named 'name'.
607 SDOM_Exception SDOM_setAttribute(
610 const SDOM_char *name,
611 const SDOM_char *value);
616 Assigns the given value to n's attribute with 'uri' and qualified name 'qName'.
619 SDOM_Exception SDOM_setAttributeNS(
622 const SDOM_char *uri,
623 const SDOM_char *qName,
624 const SDOM_char *value);
629 Assigns the given attnode as n's attribute.
630 Returns replaced, if was replaced some node with the same nodeName.
633 SDOM_Exception SDOM_setAttributeNode(
637 SDOM_Node *replaced);
642 Assigns the given attnode to n's attribute with attnode.uri and attnode.localname.
643 Returns replaced, if was replaced some node.
646 SDOM_Exception SDOM_setAttributeNodeNS(
650 SDOM_Node *replaced);
655 Removes the given attribute of n.
658 SDOM_Exception SDOM_removeAttribute(
661 const SDOM_char *name);
666 Removes the given attribute of n.
669 SDOM_Exception SDOM_removeAttributeNode(
677 returns owner element of attribute specified
680 SDOM_Exception SDOM_getAttributeElement(
688 Returns, in *pAttrList, the list of all attributes of the element n.
692 SDOM_Exception SDOM_getAttributeList(
695 SDOM_NodeList *pAttrList);
704 ** Functions related to Document
710 Serializes the document, returning the resulting string in
711 *pSerialized, which is a Sablotron-allocated buffer.
715 SDOM_Exception SDOM_docToString(
718 SDOM_char **pSerialized);
722 SDOM_Exception SDOM_nodeToString(
726 SDOM_char **pSerialized);
730 ** END Document functions
736 ** An ordered collection of nodes, returned by xql.
742 Returns, in *pLength, the number of nodes in the list l.
746 SDOM_Exception SDOM_getNodeListLength(
754 Returns, in *pItem, the index'th member of the node list l.
758 SDOM_Exception SDOM_getNodeListItem(
767 Destroys the node list l. The nodes themselves are NOT disposed.
771 SDOM_Exception SDOM_disposeNodeList(
787 Returns, in *pResult, the list of all nodes satisfying the XPath
788 query given as a string in 'query'. For the evaluation of the query, the
789 current node will be set to currentNode.
790 Note that the query is necessarily rather restricted.
791 After the contents of *pResult have been retrieved, the list should
792 be freed using disposeNodeList.
796 SDOM_Exception SDOM_xql(
798 const SDOM_char *query,
799 SDOM_Node currentNode,
800 SDOM_NodeList *pResult);
804 SDOM_Exception SDOM_xql_ns(
806 const SDOM_char *query,
807 SDOM_Node currentNode,
809 SDOM_NodeList *pResult);
817 ** Exception retrieval
822 returns the code of the pending exception
827 int SDOM_getExceptionCode(SablotSituation s);
832 returns the message for the pending exception
837 char* SDOM_getExceptionMessage(SablotSituation s);
842 returns extra information for the pending exception
843 - on the code and message of the primary error
844 - on the document and file line where the primary error occured
849 void SDOM_getExceptionDetails(
858 ** END Exception retrieval
861 ** Internal functions
866 saves a pointer in a node instance
870 void SDOM_setNodeInstanceData(SDOM_Node n, void *data);
875 retrieves the saved pointer
878 void* SDOM_getNodeInstanceData(SDOM_Node n);
881 setDisposeNodeCallback
882 sets callback to be called on every node disposal
885 typedef void SDOM_NodeCallback(SDOM_Node n);
889 void SDOM_setDisposeCallback(SDOM_NodeCallback *f);
894 SDOM_NodeCallback* SDOM_getDisposeCallback();
898 ** FOR IMPLEMENTATION IN PERL
899 ** None of these fuctions appear in the spec.
904 ArrayRef getChildNodes(Node n)
905 Returns the array of n's children.
906 Implement using getFirstChild and getNextSibling.
909 HashRef getAttributes(Node n)
910 Returns the hash of n's attributes.
911 Implement using getAttributeList, getNodeListLength,
912 getNodeListItem, getNodeName and getNodeValue.
915 setAttributes(Node n, HashRef atts)
916 Sets n's attributes to atts, keeping the old ones alive but making
918 Implement using getAttributeList, getNodeListLength, removeAttribute
919 and setAttribute (not too efficient perhaps).
925 void SDOM_tmpListDump(SDOM_Document doc, int p);
930 SDOM_Exception SDOM_compareNodes(
937 #endif /* DISABLE_DOM */
939 #endif /* SDomHIncl */