Debian Codegraph @

libgdome/gdomecore/gdome-xml-xpns.c

raw
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2 /* gdome-xml-xpns.c
3 *
4 * CopyRight (C) 2002 T.J. Mather <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24 #include <stdlib.h>
25 #include <string.h>
26 #include "gdome.h"
27 #include <libxml/tree.h>
28 #include "gdome-xml-node.h"
29 #include "gdome.h"
30 #include "gdome-xml-xpns.h"
31 #include "gdome-xml-util.h"
32 #include "gdome-xml-xmlutil.h"
33 #include "gdome-treegc.h"
34
35 const GdomeXPathNamespaceVtab gdome_xml_xpns_vtab =
36 {
37 {
38 gdome_xml_n_ref,
39 gdome_xml_n_unref,
40 gdome_xml_n_query_interface,
41 gdome_xml_n_nodeName,
42 gdome_xml_n_nodeValue,
43 gdome_xml_n_set_nodeValue,
44 gdome_xml_n_nodeType,
45 gdome_xml_n_parentNode,
46 gdome_xml_n_childNodes,
47 gdome_xml_n_firstChild,
48 gdome_xml_n_lastChild,
49 gdome_xml_n_previousSibling,
50 gdome_xml_n_nextSibling,
51 gdome_xml_n_attributes,
52 gdome_xml_n_ownerDocument,
53 gdome_xml_n_insertBefore,
54 gdome_xml_n_replaceChild,
55 gdome_xml_n_removeChild,
56 gdome_xml_n_appendChild,
57 gdome_xml_n_hasChildNodes,
58 gdome_xml_n_cloneNode,
59 gdome_xml_n_normalize,
60 gdome_xml_n_isSupported,
61 gdome_xml_n_namespaceURI,
62 gdome_xml_n_prefix,
63 gdome_xml_n_set_prefix,
64 gdome_xml_n_localName,
65 gdome_xml_n_hasAttributes,
66 gdome_xml_n_addEventListener,
67 gdome_xml_n_removeEventListener,
68 gdome_xml_n_dispatchEvent,
69 gdome_xml_n_subTreeDispatchEvent
70 },
71 gdome_xml_xpns_ownerElement
72 };
73
74 GdomeXPathNamespace *
75 gdome_xml_xpns_mkref (xmlNs *ns){
76 Gdome_xml_XPathNamespace *result = NULL;
77 xmlNodePtr n;
78
79 if (ns == NULL)
80 return NULL;
81 if (ns->type == XML_NAMESPACE_DECL) {
82 n = xmlNewNode(ns, "");
83 n->type = XML_NAMESPACE_DECL;
84 result = g_new (Gdome_xml_XPathNamespace, 1);
85 result->refcnt = 1;
86 result->vtab = &gdome_xml_xpns_vtab;
87 result->super.user_data = NULL;
88 result->n = n;
89 result->accessType = GDOME_READONLY_NODE;
90 } else {
91 g_warning ("gdome_xml_xpns_mkref: invalid node type");
92 result = NULL;
93 }
94
95 return (GdomeXPathNamespace *)result;
96 }
97
98 /**
99 * gdome_xml_xpns_unref:
100 * @self: XPathNamespace Object ref
101 * @exc: Exception Object ref
102 *
103 * Decrease the reference count of the specified Node. Free the Node structure
104 * if the Node will have zero reference
105 */
106 void
107 gdome_xml_xpns_unref (GdomeNode *self, GdomeException *exc) {
108 Gdome_xml_XPathNamespace *priv = (Gdome_xml_XPathNamespace *)self;
109
110 g_return_if_fail (priv != NULL);
111 g_return_if_fail (GDOME_XML_IS_NS (priv));
112 g_return_if_fail (exc != NULL);
113
114 if (priv->refcnt > 0)
115 priv->refcnt--;
116
117 if (priv->refcnt == 0) {
118 g_free (self);
119 }
120 }
121
122 /**
123 * gdome_xml_xpns_ownerElement:
124 * @self: XPathNamespace Object ref
125 * @exc: Exception Object ref
126 *
127 * NOT IMPLEMENTED
128 * Returns: %NULL
129 */
130 GdomeElement *
131 gdome_xml_xpns_ownerElement (GdomeXPathNamespace *self, GdomeException *exc) {
132 /* FIXME libxml's xpath function will have to return node information
133 with namespaces ? */
134 return NULL;
135 }