xmlsig 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.rdoc +0 -0
  2. data/ext/xmlsig/BioWrap.h +98 -0
  3. data/ext/xmlsig/DSig.cpp +109 -0
  4. data/ext/xmlsig/DSig.h +81 -0
  5. data/ext/xmlsig/DSigCtx.h +72 -0
  6. data/ext/xmlsig/Exceptions.cpp +151 -0
  7. data/ext/xmlsig/Exceptions.h +214 -0
  8. data/ext/xmlsig/Key.cpp +582 -0
  9. data/ext/xmlsig/Key.h +338 -0
  10. data/ext/xmlsig/KeyInfoCtx.h +67 -0
  11. data/ext/xmlsig/KeyStore.cpp +180 -0
  12. data/ext/xmlsig/KeyStore.h +157 -0
  13. data/ext/xmlsig/KeysMngrWrap.h +62 -0
  14. data/ext/xmlsig/NodeSet.h +60 -0
  15. data/ext/xmlsig/Signer.cpp +691 -0
  16. data/ext/xmlsig/Signer.h +373 -0
  17. data/ext/xmlsig/TrustVerifier.cpp +145 -0
  18. data/ext/xmlsig/TrustVerifier.h +174 -0
  19. data/ext/xmlsig/Verifier.cpp +677 -0
  20. data/ext/xmlsig/Verifier.h +313 -0
  21. data/ext/xmlsig/X509Certificate.cpp +362 -0
  22. data/ext/xmlsig/X509Certificate.h +146 -0
  23. data/ext/xmlsig/XPath.cpp +173 -0
  24. data/ext/xmlsig/XPath.h +156 -0
  25. data/ext/xmlsig/XPathCtx.h +68 -0
  26. data/ext/xmlsig/XmlCharBuf.h +60 -0
  27. data/ext/xmlsig/XmlDoc.cpp +278 -0
  28. data/ext/xmlsig/XmlDoc.h +157 -0
  29. data/ext/xmlsig/XmlElement.cpp +151 -0
  30. data/ext/xmlsig/XmlElement.h +134 -0
  31. data/ext/xmlsig/countptr.h +260 -0
  32. data/ext/xmlsig/extconf.rb +58 -0
  33. data/ext/xmlsig/runtests.rb +23 -0
  34. data/ext/xmlsig/swig/countptr.i +27 -0
  35. data/ext/xmlsig/swig/exceptions.i +79 -0
  36. data/ext/xmlsig/swig/ruby.i +17 -0
  37. data/ext/xmlsig/swig/xmlsig.i +405 -0
  38. data/ext/xmlsig/t/tc_cert.rb +34 -0
  39. data/ext/xmlsig/t/tc_interface.rb +158 -0
  40. data/ext/xmlsig/t/tc_signer.rb +501 -0
  41. data/ext/xmlsig/t/tc_tsik.rb +490 -0
  42. data/ext/xmlsig/t/tc_verifier.rb +151 -0
  43. data/ext/xmlsig/t/tsik_interop/sign.rb +48 -0
  44. data/ext/xmlsig/t/tsik_interop/verify.rb +31 -0
  45. data/ext/xmlsig/t/tsik_interop/verify_own.rb +46 -0
  46. data/ext/xmlsig/xmlsig.cpp +13363 -0
  47. data/lib/xmlsig.rb +1 -0
  48. metadata +113 -0
@@ -0,0 +1,278 @@
1
+ /*
2
+ * (C) Copyright 2006 VeriSign, Inc.
3
+ * Developed by Sxip Identity
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #include <iostream>
18
+ #include <string>
19
+ #include <vector>
20
+ #include <libxml/tree.h>
21
+ #include <libxml/parser.h>
22
+ #include <stdio.h>
23
+ #include <errno.h>
24
+ #include <assert.h>
25
+ #include <xmlsec/xmltree.h>
26
+ #include "XmlDoc.h"
27
+ #include "XmlCharBuf.h"
28
+ using namespace std;
29
+
30
+
31
+ XmlDoc::XmlDoc ()
32
+ : doc (0)
33
+ {}
34
+
35
+
36
+ XmlDoc::XmlDoc (const XmlDoc& xmlDoc)
37
+ : doc (0)
38
+ {
39
+ this->operator=(xmlDoc);
40
+ }
41
+
42
+
43
+ XmlDoc::~XmlDoc ()
44
+ {
45
+ freeDoc();
46
+ }
47
+
48
+
49
+ const XmlDoc& XmlDoc::operator= (const XmlDoc& xmlDoc)
50
+ {
51
+ if (this != &xmlDoc)
52
+ {
53
+ freeDoc();
54
+ if (xmlDoc.doc)
55
+ {
56
+ // recursive copy of original doc
57
+ doc = xmlCopyDoc(xmlDoc.doc, 1);
58
+ // copy over ID attributes too
59
+ if (doc)
60
+ {
61
+ idAttrs = xmlDoc.idAttrs;
62
+ for (unsigned i = 0; i < xmlDoc.idAttrs.size(); i += 3)
63
+ {
64
+ addIdAttr(xmlDoc.idAttrs[i],
65
+ xmlDoc.idAttrs[i + 1],
66
+ xmlDoc.idAttrs[i + 2]);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ return *this;
72
+ }
73
+
74
+
75
+ void XmlDoc::freeDoc ()
76
+ {
77
+ if (doc)
78
+ {
79
+ xmlFreeDoc(doc);
80
+ doc = NULL;
81
+ idAttrs.clear();
82
+ }
83
+ }
84
+
85
+
86
+ xmlDocPtr XmlDoc::getDoc ()
87
+ {
88
+ return doc;
89
+ }
90
+
91
+
92
+ int XmlDoc::loadFromXmlDocPtr (xmlDocPtr newdoc)
93
+ {
94
+ if (!newdoc)
95
+ {
96
+ THROW(ValueError, "Invalid document to copy", -1);
97
+ }
98
+ freeDoc();
99
+ doc = xmlCopyDoc(newdoc, 1);
100
+ if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL))
101
+ {
102
+ THROW(LibError, "Error parsing XML document", -1);
103
+ }
104
+ return 0;
105
+ }
106
+
107
+
108
+ int XmlDoc::loadFromString (string xmlData)
109
+ {
110
+ freeDoc();
111
+ doc = xmlReadDoc((xmlChar*) xmlData.c_str(), "", NULL, 0);
112
+ if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL))
113
+ {
114
+ THROW(LibError, "Error parsing XML document", -1);
115
+ }
116
+ return 0;
117
+ }
118
+
119
+
120
+ int XmlDoc::loadFromFile (string fileName)
121
+ {
122
+ freeDoc();
123
+ doc = xmlReadFile(fileName.c_str(), NULL, 0);
124
+ if (doc == NULL)
125
+ {
126
+ THROW(IOError, "Failure loading XML document", -1);
127
+ }
128
+ if (xmlDocGetRootElement(doc) == NULL)
129
+ {
130
+ THROW(LibError, "Error parsing XML document", -1);
131
+ }
132
+ return 0;
133
+ }
134
+
135
+
136
+ void XmlDoc::dump ()
137
+ {
138
+ if (doc)
139
+ {
140
+ xmlDocDump(stdout, doc);
141
+ }
142
+ }
143
+
144
+
145
+ string XmlDoc::toString ()
146
+ {
147
+ string str = "";
148
+ if (doc)
149
+ {
150
+ XmlCharBuf buf;
151
+ int len = 0;
152
+ xmlDocDumpMemory(doc, (xmlChar**)buf, &len);
153
+ str = string((const char*)buf, len);
154
+ }
155
+ return str;
156
+ }
157
+
158
+
159
+ int XmlDoc::toFile (string fileName)
160
+ {
161
+ if (doc)
162
+ {
163
+ int res = xmlSaveFile(fileName.c_str(), doc);
164
+ if (res < 0)
165
+ {
166
+ THROW(LibError, "Document dump failure", res);
167
+ }
168
+ }
169
+ return 0;
170
+ }
171
+
172
+
173
+ int XmlDoc::addIdAttr (string attrName, string nodeName, string nsHref)
174
+ {
175
+ assert(doc);
176
+ assert(attrName.length());
177
+ assert(nodeName.length());
178
+ const char* nsHrefChr = NULL;
179
+ int added = 0;
180
+ if (nsHref.length())
181
+ {
182
+ nsHrefChr = nsHref.c_str();
183
+ }
184
+ xmlNodePtr cur = xmlSecGetNextElementNode(doc->children);
185
+ while (cur != NULL)
186
+ {
187
+ if (addIdAttrToNode(cur,
188
+ (xmlChar*)attrName.c_str(),
189
+ (xmlChar*)nodeName.c_str(),
190
+ (xmlChar*)nsHrefChr) < 0)
191
+ {
192
+ return -1;
193
+ }
194
+ cur = xmlSecGetNextElementNode(cur->next);
195
+ added++;
196
+ }
197
+ if (added)
198
+ {
199
+ idAttrs.push_back(attrName);
200
+ idAttrs.push_back(nodeName);
201
+ idAttrs.push_back(nsHref);
202
+ }
203
+ return 0;
204
+ }
205
+
206
+
207
+ int XmlDoc::addIdAttrToNode (xmlNodePtr node,
208
+ const xmlChar* attrName,
209
+ const xmlChar* nodeName,
210
+ const xmlChar* nsHref)
211
+ {
212
+ xmlAttrPtr attr, tmpAttr;
213
+ xmlNodePtr cur;
214
+
215
+ if ((node == NULL) || (attrName == NULL) || (nodeName == NULL))
216
+ {
217
+ THROW(ValueError, "Bad parameters", -1);
218
+ }
219
+
220
+ /* process children first because it does not matter much but does simplify code */
221
+ cur = xmlSecGetNextElementNode(node->children);
222
+ while (cur != NULL)
223
+ {
224
+ int ret = addIdAttrToNode(cur, attrName, nodeName, nsHref);
225
+ if (ret < 0)
226
+ {
227
+ return (ret);
228
+ }
229
+ cur = xmlSecGetNextElementNode(cur->next);
230
+ }
231
+
232
+
233
+ /* node name must match */
234
+ if (!xmlStrEqual(node->name, nodeName))
235
+ {
236
+ return (0);
237
+ }
238
+
239
+ /* if nsHref is set then it also should match */
240
+ if ((nsHref != NULL) && (node->ns != NULL) &&
241
+ (!xmlStrEqual(nsHref, node->ns->href)))
242
+ {
243
+ return (0);
244
+ }
245
+
246
+ /* the attribute with name equal to attrName should exist */
247
+ for (attr = node->properties; attr != NULL; attr = attr->next)
248
+ {
249
+ if (xmlStrEqual(attr->name, attrName))
250
+ {
251
+ break;
252
+ }
253
+ }
254
+ if (attr == NULL)
255
+ {
256
+ return (0);
257
+ }
258
+
259
+ /* and this attr should have a value */
260
+ XmlCharBuf id (xmlNodeListGetString(node->doc, attr->children, 1));
261
+ if (!(int)id)
262
+ {
263
+ return (0);
264
+ }
265
+
266
+ /* check that we don't have same ID already */
267
+ tmpAttr = xmlGetID(node->doc, id);
268
+ if (tmpAttr == NULL)
269
+ {
270
+ xmlAddID(NULL, node->doc, id, attr);
271
+ }
272
+ else if (tmpAttr != attr)
273
+ {
274
+ THROW(XMLError, "Duplicate ID attribute", -1);
275
+ }
276
+ return (0);
277
+ }
278
+
@@ -0,0 +1,157 @@
1
+ /*
2
+ * (C) Copyright 2006 VeriSign, Inc.
3
+ * Developed by Sxip Identity
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #ifndef _XMLDOC_H
18
+ #define _XMLDOC_H
19
+ #include <string>
20
+ #include <vector>
21
+ #include <libxml/parser.h>
22
+ #include "Exceptions.h"
23
+ using namespace std;
24
+
25
+ /**
26
+ * An XML document.
27
+ * Encapsulates a LibXML2 XML Document object. Provides methods
28
+ * to load and save to other formats. For now it just loads/saves the
29
+ * document to a file or a string, but more methods could be added to load/save
30
+ * to/from other XML representations/objects.
31
+ */
32
+ class XmlDoc
33
+ {
34
+ public:
35
+ /**
36
+ * Construct an empty document.
37
+ */
38
+ XmlDoc();
39
+ /**
40
+ * Destroy document object.
41
+ * Frees document object if one was created.
42
+ */
43
+ ~XmlDoc();
44
+
45
+ /**
46
+ * Load directly from an LibXML2 xmlDocPtr.
47
+ * @return 0 on success, -1 on error
48
+ */
49
+ int loadFromXmlDocPtr(xmlDocPtr newdoc);
50
+ /**
51
+ * Get the internal representation of the XML document.
52
+ * @return Pointer to the XML document structure
53
+ */
54
+ xmlDocPtr getDoc();
55
+ /**
56
+ * Load an XML document from a string.
57
+ * @param xmlData A string containing an XML document
58
+ * @return 0 on success, -1 on error
59
+ */
60
+ int loadFromString(string xmlData);
61
+ /**
62
+ * Load an XML document from a file.
63
+ * @param fileName The filename
64
+ * @return 0 on success, -1 on error
65
+ */
66
+ int loadFromFile(string fileName);
67
+ /**
68
+ * Emits the XML document as a string.
69
+ * Caller is responsible for freeing/deleting the string.
70
+ * @return The XML Document as a string. If none was loaded, returns empty string.
71
+ */
72
+ string toString();
73
+ /**
74
+ * Emits the XML document to a file.
75
+ * @param fileName The filename
76
+ * @return 0 on success, -1 on error
77
+ */
78
+ int toFile(string fileName);
79
+ /**
80
+ * @internal
81
+ * Dump the XML document to stdout.
82
+ * Handy when debugging.
83
+ */
84
+ void dump();
85
+ /**
86
+ * Declare an ID attribute for nodes of a given name
87
+ * of why this may be necessary.
88
+ * @param attrName The attribute name
89
+ * @param nodeName The node name
90
+ * @param nsHref The namespace href (optional)
91
+ * @return 0 on success, -1 on error
92
+ */
93
+ int addIdAttr(string attrName, string nodeName, string nsHref);
94
+
95
+ /// @cond NO_INTERFACE
96
+ /**
97
+ * Copy an existing document object.
98
+ * @param doc XmlDoc class to be copied
99
+ */
100
+ XmlDoc(const XmlDoc& doc);
101
+ /**
102
+ * Assignment operator creates duplicate document.
103
+ * @param doc XmlDoc class to be copied
104
+ * @return Copied document
105
+ */
106
+ const XmlDoc& operator= (const XmlDoc& doc);
107
+ /**
108
+ * @return true if valid, false if no document
109
+ */
110
+ operator int ()
111
+ {
112
+ return doc != NULL;
113
+ }
114
+ /**
115
+ * @return false if valid, true if no document
116
+ */
117
+ int operator! ()
118
+ {
119
+ return doc == NULL;
120
+ }
121
+ /**
122
+ * Cast the document object to the xmlDocPtr.
123
+ * @return Pointer to the XML document structure
124
+ */
125
+ operator xmlDocPtr ()
126
+ {
127
+ return getDoc();
128
+ }
129
+ /**
130
+ * List of ID attributes that have been added to the document.
131
+ * Required by copy constructor, since these don't move with the
132
+ * document normally.
133
+ */
134
+ vector<string> idAttrs;
135
+
136
+ protected:
137
+ /**
138
+ * The internal representation of the XML document.
139
+ */
140
+ xmlDocPtr doc;
141
+
142
+ /**
143
+ * Free the internal representation of the XML document.
144
+ */
145
+ void freeDoc();
146
+
147
+ /**
148
+ * Add an ID attribute to a node
149
+ */
150
+ static int addIdAttrToNode(xmlNodePtr node, const xmlChar* attrName, const xmlChar* nodeName, const xmlChar* nsHref);
151
+ /// @endcond
152
+ };
153
+
154
+ #include "countptr.h"
155
+ typedef CountPtrTo<XmlDoc> XmlDocClassPtr;
156
+
157
+ #endif
@@ -0,0 +1,151 @@
1
+ /*
2
+ * (C) Copyright 2006 VeriSign, Inc.
3
+ * Developed by Sxip Identity
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #include <iostream>
18
+ #include <string>
19
+ #include <vector>
20
+ #include <libxml/tree.h>
21
+ #include <libxml/parser.h>
22
+ #include <stdio.h>
23
+ #include <errno.h>
24
+ #include <assert.h>
25
+ #include <xmlsec/xmltree.h>
26
+ #include "XmlElement.h"
27
+ #include "XmlCharBuf.h"
28
+ using namespace std;
29
+
30
+
31
+ XmlElement::XmlElement ()
32
+ : node (0)
33
+ {}
34
+
35
+
36
+ XmlElement::XmlElement (xmlNodePtr copyNode)
37
+ : node (0)
38
+ {
39
+ assert(copyNode);
40
+ if (!copyNode)
41
+ {
42
+ THROW_NORET(MemoryError, "Bad pointer passed to XmlElement");
43
+ }
44
+ if (copyNode->type != XML_ELEMENT_NODE)
45
+ {
46
+ THROW_NORET(XMLError, "Not an element node");
47
+ }
48
+ // recursive copy of original node
49
+ node = xmlCopyNode(copyNode,
50
+ 2); // 2=copy attr but no children
51
+ if (!node)
52
+ {
53
+ THROW_NORET(LibError, "Failed to copy node");
54
+ }
55
+ }
56
+
57
+
58
+ XmlElement::XmlElement (const XmlElement& xmlNode)
59
+ : node (0)
60
+ {
61
+ this->operator=(xmlNode);
62
+ }
63
+
64
+
65
+ XmlElement::~XmlElement ()
66
+ {
67
+ freeNode();
68
+ }
69
+
70
+
71
+ const XmlElement& XmlElement::operator= (const XmlElement& xmlNode)
72
+ {
73
+ if (this != &xmlNode)
74
+ {
75
+ freeNode();
76
+ if (xmlNode.node)
77
+ {
78
+ // recursive copy of original node
79
+ node = xmlCopyNode(xmlNode.node,
80
+ 2); // 2=copy attr but no children
81
+ if (!node)
82
+ {
83
+ THROW(LibError, "Failed to copy node", *this);
84
+ }
85
+ }
86
+ }
87
+ return *this;
88
+ }
89
+
90
+
91
+ void XmlElement::freeNode ()
92
+ {
93
+ if (node)
94
+ {
95
+ xmlFreeNode(node);
96
+ node = NULL;
97
+ }
98
+ }
99
+
100
+
101
+ xmlNodePtr XmlElement::getNode ()
102
+ {
103
+ return node;
104
+ }
105
+
106
+
107
+ string XmlElement::getTagName ()
108
+ {
109
+ if (!*this)
110
+ {
111
+ THROW(XMLError, "Invalid element node", "");
112
+ }
113
+ if (!node->name)
114
+ {
115
+ return "";
116
+ }
117
+ return string((const char*)node->name);
118
+ }
119
+
120
+
121
+ string XmlElement::getAttribute (string name)
122
+ {
123
+ if (!*this)
124
+ {
125
+ THROW(XMLError, "Invalid element node", "");
126
+ }
127
+ XmlCharBuf buf(xmlGetProp(node, BAD_CAST name.c_str()));
128
+ return string(buf);
129
+ }
130
+
131
+
132
+ string XmlElement::getAttribute (string name, string nameSpace)
133
+ {
134
+ if (!*this)
135
+ {
136
+ THROW(XMLError, "Invalid element node", "");
137
+ }
138
+ XmlCharBuf buf(xmlGetNsProp(node, BAD_CAST name.c_str(), BAD_CAST nameSpace.c_str()));
139
+ return string(buf);
140
+ }
141
+
142
+
143
+ string XmlElement::getNodePath ()
144
+ {
145
+ if (!*this)
146
+ {
147
+ THROW(XMLError, "Invalid element node", "");
148
+ }
149
+ XmlCharBuf buf(xmlGetNodePath(node));
150
+ return string(buf);
151
+ }
@@ -0,0 +1,134 @@
1
+ /*
2
+ * (C) Copyright 2006 VeriSign, Inc.
3
+ * Developed by Sxip Identity
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #ifndef _XMLELEMENT_H
18
+ #define _XMLELEMENT_H
19
+ #include <string>
20
+ #include <vector>
21
+ #include <libxml/parser.h>
22
+ #include "Exceptions.h"
23
+ using namespace std;
24
+
25
+ /**
26
+ * An XML element.
27
+ * Encapsulates a LibXML2 XML node object.
28
+ */
29
+ class XmlElement
30
+ {
31
+ public:
32
+ /**
33
+ * Construct an empty element object.
34
+ */
35
+ XmlElement ();
36
+ /**
37
+ * Copy an existing raw element.
38
+ */
39
+ XmlElement (xmlNodePtr copyNode);
40
+ /**
41
+ * Destroy element object.
42
+ * Frees element object if one was created.
43
+ */
44
+ ~XmlElement ();
45
+
46
+ /**
47
+ * Get the internal representation of the XML element.
48
+ * @return Pointer to the XML node structure
49
+ */
50
+ xmlNodePtr getNode ();
51
+ /**
52
+ * Get the name of the element.
53
+ * @return the name of the element node
54
+ * @throws XMLError if the node is invalid
55
+ */
56
+ string getTagName ();
57
+ /**
58
+ * Search and get the value of an attribute associated to a node.
59
+ * This does the entity substitution.
60
+ * @param name the attribute name
61
+ * @return the attribute value or null if not found
62
+ * @throws XMLError if the node is invalid
63
+ */
64
+ string getAttribute (string name);
65
+ /**
66
+ * Search and get the value of an attribute associated to a node.
67
+ * This attribute has to be anchored in the namespace
68
+ * specified. This does the entity substitution.
69
+ * @param name the attribute name
70
+ * @param nameSpace the URI of the namespace
71
+ * @return the attribute value or null if not found
72
+ * @throws XMLError if the node is invalid
73
+ */
74
+ string getAttribute (string name, string nameSpace);
75
+ /**
76
+ * Build a structure based Path for the node.
77
+ * @return a path in string form
78
+ * @throws XMLError if the node is invalid
79
+ */
80
+ string getNodePath ();
81
+
82
+ /// @cond NO_INTERFACE
83
+ /**
84
+ * Copy an existing element object.
85
+ * @param element XmlElement class to be copied
86
+ */
87
+ XmlElement(const XmlElement& element);
88
+ /**
89
+ * Assignment operator creates duplicate element.
90
+ * @param element XmlElement class to be copied
91
+ * @return Copied element
92
+ */
93
+ const XmlElement& operator= (const XmlElement& element);
94
+ /**
95
+ * @return true if valid, false if no element
96
+ */
97
+ operator int ()
98
+ {
99
+ return (node != NULL) && (node->type == XML_ELEMENT_NODE);
100
+ }
101
+ /**
102
+ * @return false if valid, true if no element
103
+ */
104
+ int operator! ()
105
+ {
106
+ return (node == NULL) || (node->type != XML_ELEMENT_NODE);
107
+ }
108
+ /**
109
+ * Cast the element object to the xmlNodePtr.
110
+ * @return Pointer to the XML element structure
111
+ */
112
+ operator xmlNodePtr ()
113
+ {
114
+ return getNode();
115
+ }
116
+
117
+ protected:
118
+ /**
119
+ * The internal representation of the XML node.
120
+ */
121
+ xmlNodePtr node;
122
+
123
+ /**
124
+ * Free the internal representation of the XML node.
125
+ */
126
+ void freeNode();
127
+
128
+ /// @endcond
129
+ };
130
+
131
+ #include "countptr.h"
132
+ typedef CountPtrTo<XmlElement> XmlElementPtr;
133
+
134
+ #endif