1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2 /* gdome-xml-notation.c
3  *
4  * Copyright (C) 1999 Raph Levien <raph@acm.org>
5  * Copyright (C) 2000 Mathieu Lacage <mathieu@gnu.org>
6  * Copyright (C) 2001 Paolo Casarini <paolo@casarini.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 
23 #include <stdlib.h>
24 #include <string.h>
25 #include <glib.h>
26 #include "gdome.h"
27 #include <libxml/tree.h>
28 #include <libxml/parser.h>
29 #include <libxml/xmlmemory.h>
30 #include <libxml/hash.h>
31 #include "gdome-xml-util.h"
32 #include "gdome-xml-xmldtdutil.h"
33 #include "gdome-xml-str.h"
34 #include "gdome-xml-node.h"
35 #include "gdome-xml-notation.h"
36 
37 const GdomeNotationVtab gdome_xml_not_vtab = {
38   {
39 		gdome_xml_n_ref,
40 		gdome_xml_n_unref,
41 		gdome_xml_not_query_interface,
42 		gdome_xml_n_nodeName,
43 		gdome_xml_n_nodeValue,
44 		gdome_xml_n_set_nodeValue,
45 		gdome_xml_n_nodeType,
46 		gdome_xml_n_parentNode,
47 		gdome_xml_n_childNodes,
48 		gdome_xml_n_firstChild,
49 		gdome_xml_n_lastChild,
50 		gdome_xml_n_previousSibling,
51 		gdome_xml_n_nextSibling,
52 		gdome_xml_n_attributes,
53 		gdome_xml_n_ownerDocument,
54 		gdome_xml_n_insertBefore,
55 		gdome_xml_n_replaceChild,
56 		gdome_xml_n_removeChild,
57 		gdome_xml_n_appendChild,
58 		gdome_xml_n_hasChildNodes,
59 		gdome_xml_n_cloneNode,
60 		gdome_xml_n_normalize,
61 		gdome_xml_n_isSupported,
62 		gdome_xml_n_namespaceURI,
63 		gdome_xml_n_prefix,
64 		gdome_xml_n_set_prefix,
65 		gdome_xml_n_localName,
66     gdome_xml_n_hasAttributes,
67 		gdome_xml_n_addEventListener,
68 		gdome_xml_n_removeEventListener,
69 		gdome_xml_n_dispatchEvent,
70     gdome_xml_n_subTreeDispatchEvent
71   },
72   gdome_xml_not_publicId,
73   gdome_xml_not_systemId
74 };
75 
76 /**
77  * gdome_xml_not_query_interface:
78  * @self:  Node Object ref
79  * @interface:  interface needed
80  * @exc:  Exception Object ref
81  *
82  * Returns: a reference to this object that implements the @interface needed,
83  *          or %NULL if the @interface is not supported by this Object.
84  */
85 gpointer
gdome_xml_not_query_interface(GdomeNode * self,const char * interface,GdomeException * exc)86 gdome_xml_not_query_interface (GdomeNode *self, const char *interface, GdomeException *exc)
87 {
88 	Gdome_xml_Notation *priv = (Gdome_xml_Notation *)self;
89 
90   g_return_val_if_fail (priv != NULL, NULL);
91   g_return_val_if_fail (GDOME_XML_IS_NOT (priv), NULL);
92   g_return_val_if_fail (interface != NULL, NULL);
93   g_return_val_if_fail (exc != NULL, NULL);
94 
95   if (!strcmp (interface, "Node") ||
96       !strcmp (interface, "Notation") ||
97       !strcmp (interface, "EventTarget")) {
98     priv->refcnt++;
99     return self;
100   }
101   else
102     return NULL;
103 }
104 
105 /**
106  * gdome_xml_not_publicId:
107  * @self:  Notations Object ref
108  * @exc:   Exception Object ref
109  *
110  * Returns: the public identifier of this notation. If the public identifier
111  * was not specified, this is NULL.
112  */
113 GdomeDOMString *
gdome_xml_not_publicId(GdomeNotation * self,GdomeException * exc)114 gdome_xml_not_publicId (GdomeNotation *self, GdomeException *exc)
115 {
116   Gdome_xml_Notation *priv = (Gdome_xml_Notation *)self;
117   gdome_xmlNotation *not;
118 
119   g_return_val_if_fail (priv != NULL, NULL);
120   g_return_val_if_fail (GDOME_XML_IS_NOT(priv), NULL);
121   g_return_val_if_fail (exc != NULL, NULL);
122 
123   not = priv->n;
124   return gdome_xml_str_mkref_dup (not->PublicID);
125 }
126 
127 /**
128  * gdome_xml_not_systemId:
129  * @self:  Notations Object ref
130  * @exc:   Exception Object ref
131  *
132  * Returns: the system identifier of this notation. If the system identifier
133  * was not specified, this is NULL.
134  */
135 GdomeDOMString *
gdome_xml_not_systemId(GdomeNotation * self,GdomeException * exc)136 gdome_xml_not_systemId (GdomeNotation *self, GdomeException *exc)
137 {
138   Gdome_xml_Notation *priv = (Gdome_xml_Notation *)self;
139   gdome_xmlNotation *not;
140 
141   g_return_val_if_fail (priv != NULL, NULL);
142   g_return_val_if_fail (GDOME_XML_IS_NOT(priv), NULL);
143   g_return_val_if_fail (exc != NULL, NULL);
144 
145   not = priv->n;
146   return gdome_xml_str_mkref_dup (not->SystemID);
147 }
148