pocjenkixx 0.30.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pocjenkixx might be problematic. Click here for more details.

Files changed (160) hide show
  1. package/LICENSE +19 -0
  2. package/Makefile +18 -0
  3. package/README.md +52 -0
  4. package/binding.gyp +81 -0
  5. package/index.d.ts +273 -0
  6. package/index.js +45 -0
  7. package/lib/bindings.js +1 -0
  8. package/lib/document.js +122 -0
  9. package/lib/element.js +82 -0
  10. package/lib/sax_parser.js +38 -0
  11. package/package.json +70 -0
  12. package/src/html_document.cc +7 -0
  13. package/src/html_document.h +18 -0
  14. package/src/libxmljs.cc +252 -0
  15. package/src/libxmljs.h +53 -0
  16. package/src/xml_attribute.cc +173 -0
  17. package/src/xml_attribute.h +40 -0
  18. package/src/xml_comment.cc +117 -0
  19. package/src/xml_comment.h +30 -0
  20. package/src/xml_document.cc +810 -0
  21. package/src/xml_document.h +67 -0
  22. package/src/xml_element.cc +565 -0
  23. package/src/xml_element.h +61 -0
  24. package/src/xml_namespace.cc +158 -0
  25. package/src/xml_namespace.h +39 -0
  26. package/src/xml_node.cc +761 -0
  27. package/src/xml_node.h +73 -0
  28. package/src/xml_pi.cc +161 -0
  29. package/src/xml_pi.h +34 -0
  30. package/src/xml_sax_parser.cc +424 -0
  31. package/src/xml_sax_parser.h +73 -0
  32. package/src/xml_syntax_error.cc +66 -0
  33. package/src/xml_syntax_error.h +25 -0
  34. package/src/xml_text.cc +320 -0
  35. package/src/xml_text.h +48 -0
  36. package/src/xml_textwriter.cc +315 -0
  37. package/src/xml_textwriter.h +62 -0
  38. package/src/xml_xpath_context.cc +70 -0
  39. package/src/xml_xpath_context.h +23 -0
  40. package/vendor/libxml/Copyright +23 -0
  41. package/vendor/libxml/DOCBparser.c +305 -0
  42. package/vendor/libxml/HTMLparser.c +7287 -0
  43. package/vendor/libxml/HTMLtree.c +1200 -0
  44. package/vendor/libxml/Makefile +2983 -0
  45. package/vendor/libxml/SAX.c +180 -0
  46. package/vendor/libxml/SAX2.c +3036 -0
  47. package/vendor/libxml/buf.c +1351 -0
  48. package/vendor/libxml/buf.h +72 -0
  49. package/vendor/libxml/c14n.c +2234 -0
  50. package/vendor/libxml/catalog.c +3828 -0
  51. package/vendor/libxml/chvalid.c +336 -0
  52. package/vendor/libxml/config.h +294 -0
  53. package/vendor/libxml/config.h.gch +0 -0
  54. package/vendor/libxml/debugXML.c +3423 -0
  55. package/vendor/libxml/dict.c +1298 -0
  56. package/vendor/libxml/elfgcchack.h +17818 -0
  57. package/vendor/libxml/enc.h +32 -0
  58. package/vendor/libxml/encoding.c +3975 -0
  59. package/vendor/libxml/entities.c +1163 -0
  60. package/vendor/libxml/error.c +998 -0
  61. package/vendor/libxml/globals.c +1126 -0
  62. package/vendor/libxml/hash.c +1146 -0
  63. package/vendor/libxml/include/libxml/DOCBparser.h +96 -0
  64. package/vendor/libxml/include/libxml/HTMLparser.h +306 -0
  65. package/vendor/libxml/include/libxml/HTMLtree.h +147 -0
  66. package/vendor/libxml/include/libxml/Makefile +725 -0
  67. package/vendor/libxml/include/libxml/Makefile.am +54 -0
  68. package/vendor/libxml/include/libxml/Makefile.in +725 -0
  69. package/vendor/libxml/include/libxml/SAX.h +173 -0
  70. package/vendor/libxml/include/libxml/SAX2.h +178 -0
  71. package/vendor/libxml/include/libxml/c14n.h +128 -0
  72. package/vendor/libxml/include/libxml/catalog.h +182 -0
  73. package/vendor/libxml/include/libxml/chvalid.h +230 -0
  74. package/vendor/libxml/include/libxml/debugXML.h +217 -0
  75. package/vendor/libxml/include/libxml/dict.h +79 -0
  76. package/vendor/libxml/include/libxml/encoding.h +245 -0
  77. package/vendor/libxml/include/libxml/entities.h +151 -0
  78. package/vendor/libxml/include/libxml/globals.h +508 -0
  79. package/vendor/libxml/include/libxml/hash.h +236 -0
  80. package/vendor/libxml/include/libxml/list.h +137 -0
  81. package/vendor/libxml/include/libxml/nanoftp.h +163 -0
  82. package/vendor/libxml/include/libxml/nanohttp.h +81 -0
  83. package/vendor/libxml/include/libxml/parser.h +1243 -0
  84. package/vendor/libxml/include/libxml/parserInternals.h +644 -0
  85. package/vendor/libxml/include/libxml/pattern.h +100 -0
  86. package/vendor/libxml/include/libxml/relaxng.h +217 -0
  87. package/vendor/libxml/include/libxml/schemasInternals.h +958 -0
  88. package/vendor/libxml/include/libxml/schematron.h +142 -0
  89. package/vendor/libxml/include/libxml/threads.h +89 -0
  90. package/vendor/libxml/include/libxml/tree.h +1311 -0
  91. package/vendor/libxml/include/libxml/uri.h +94 -0
  92. package/vendor/libxml/include/libxml/valid.h +458 -0
  93. package/vendor/libxml/include/libxml/xinclude.h +129 -0
  94. package/vendor/libxml/include/libxml/xlink.h +189 -0
  95. package/vendor/libxml/include/libxml/xmlIO.h +368 -0
  96. package/vendor/libxml/include/libxml/xmlautomata.h +146 -0
  97. package/vendor/libxml/include/libxml/xmlerror.h +945 -0
  98. package/vendor/libxml/include/libxml/xmlexports.h +77 -0
  99. package/vendor/libxml/include/libxml/xmlmemory.h +224 -0
  100. package/vendor/libxml/include/libxml/xmlmodule.h +57 -0
  101. package/vendor/libxml/include/libxml/xmlreader.h +428 -0
  102. package/vendor/libxml/include/libxml/xmlregexp.h +222 -0
  103. package/vendor/libxml/include/libxml/xmlsave.h +88 -0
  104. package/vendor/libxml/include/libxml/xmlschemas.h +246 -0
  105. package/vendor/libxml/include/libxml/xmlschemastypes.h +151 -0
  106. package/vendor/libxml/include/libxml/xmlstring.h +140 -0
  107. package/vendor/libxml/include/libxml/xmlunicode.h +202 -0
  108. package/vendor/libxml/include/libxml/xmlversion.h +484 -0
  109. package/vendor/libxml/include/libxml/xmlwin32version.h +239 -0
  110. package/vendor/libxml/include/libxml/xmlwriter.h +488 -0
  111. package/vendor/libxml/include/libxml/xpath.h +564 -0
  112. package/vendor/libxml/include/libxml/xpathInternals.h +632 -0
  113. package/vendor/libxml/include/libxml/xpointer.h +114 -0
  114. package/vendor/libxml/include/win32config.h +122 -0
  115. package/vendor/libxml/include/wsockcompat.h +54 -0
  116. package/vendor/libxml/legacy.c +1343 -0
  117. package/vendor/libxml/libxml.h +134 -0
  118. package/vendor/libxml/list.c +779 -0
  119. package/vendor/libxml/nanoftp.c +2118 -0
  120. package/vendor/libxml/nanohttp.c +1899 -0
  121. package/vendor/libxml/parser.c +15553 -0
  122. package/vendor/libxml/parserInternals.c +2164 -0
  123. package/vendor/libxml/pattern.c +2621 -0
  124. package/vendor/libxml/relaxng.c +11101 -0
  125. package/vendor/libxml/rngparser.c +1595 -0
  126. package/vendor/libxml/runsuite.c +1157 -0
  127. package/vendor/libxml/save.h +36 -0
  128. package/vendor/libxml/schematron.c +1787 -0
  129. package/vendor/libxml/threads.c +1049 -0
  130. package/vendor/libxml/timsort.h +601 -0
  131. package/vendor/libxml/tree.c +10183 -0
  132. package/vendor/libxml/trio.c +6895 -0
  133. package/vendor/libxml/trio.h +230 -0
  134. package/vendor/libxml/triodef.h +228 -0
  135. package/vendor/libxml/trionan.c +914 -0
  136. package/vendor/libxml/trionan.h +84 -0
  137. package/vendor/libxml/triop.h +150 -0
  138. package/vendor/libxml/triostr.c +2112 -0
  139. package/vendor/libxml/triostr.h +144 -0
  140. package/vendor/libxml/uri.c +2561 -0
  141. package/vendor/libxml/valid.c +7138 -0
  142. package/vendor/libxml/xinclude.c +2657 -0
  143. package/vendor/libxml/xlink.c +183 -0
  144. package/vendor/libxml/xmlIO.c +4135 -0
  145. package/vendor/libxml/xmlcatalog.c +624 -0
  146. package/vendor/libxml/xmllint.c +3796 -0
  147. package/vendor/libxml/xmlmemory.c +1163 -0
  148. package/vendor/libxml/xmlmodule.c +468 -0
  149. package/vendor/libxml/xmlreader.c +6033 -0
  150. package/vendor/libxml/xmlregexp.c +8271 -0
  151. package/vendor/libxml/xmlsave.c +2735 -0
  152. package/vendor/libxml/xmlschemas.c +29173 -0
  153. package/vendor/libxml/xmlschemastypes.c +6276 -0
  154. package/vendor/libxml/xmlstring.c +1050 -0
  155. package/vendor/libxml/xmlunicode.c +3179 -0
  156. package/vendor/libxml/xmlwriter.c +4738 -0
  157. package/vendor/libxml/xpath.c +14734 -0
  158. package/vendor/libxml/xpointer.c +2969 -0
  159. package/vendor/libxml/xzlib.c +815 -0
  160. package/vendor/libxml/xzlib.h +19 -0
@@ -0,0 +1,315 @@
1
+ // Copyright 2011, Squish Tech, LLC.
2
+
3
+ #include "xml_textwriter.h"
4
+ #include "libxmljs.h"
5
+
6
+ using namespace v8;
7
+ namespace libxmljs {
8
+
9
+ #define THROW_ON_ERROR(text) \
10
+ if (result == -1) { \
11
+ Nan::ThrowError(text); \
12
+ return; \
13
+ }
14
+
15
+ XmlTextWriter::XmlTextWriter() {
16
+ textWriter = NULL;
17
+ writerBuffer = NULL;
18
+ }
19
+
20
+ XmlTextWriter::~XmlTextWriter() {
21
+ if (textWriter) {
22
+ xmlFreeTextWriter(textWriter);
23
+ }
24
+ if (writerBuffer) {
25
+ xmlBufferFree(writerBuffer);
26
+ }
27
+ }
28
+
29
+ NAN_METHOD(XmlTextWriter::NewTextWriter) {
30
+ Nan::HandleScope scope;
31
+ XmlTextWriter *writer = new XmlTextWriter();
32
+ writer->Wrap(info.Holder());
33
+ writer->OpenMemory(info);
34
+
35
+ return info.GetReturnValue().Set(info.Holder());
36
+ }
37
+
38
+ NAN_METHOD(XmlTextWriter::OpenMemory) {
39
+ Nan::HandleScope scope;
40
+
41
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
42
+
43
+ writer->writerBuffer = xmlBufferCreate();
44
+ if (!writer->writerBuffer) {
45
+ return Nan::ThrowError("Failed to create memory buffer");
46
+ }
47
+
48
+ writer->textWriter = xmlNewTextWriterMemory(writer->writerBuffer, 0);
49
+ if (!writer->textWriter) {
50
+ xmlBufferFree(writer->writerBuffer);
51
+ return Nan::ThrowError("Failed to create buffer writer");
52
+ }
53
+
54
+ return info.GetReturnValue().Set(Nan::Undefined());
55
+ }
56
+
57
+ NAN_METHOD(XmlTextWriter::BufferContent) {
58
+ Nan::HandleScope scope;
59
+
60
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
61
+
62
+ // Flush the output buffer of the libxml writer instance in order to push all
63
+ // the content to our writerBuffer.
64
+ xmlTextWriterFlush(writer->textWriter);
65
+
66
+ // Receive bytes from the writerBuffer
67
+ const xmlChar *buf = xmlBufferContent(writer->writerBuffer);
68
+
69
+ return info.GetReturnValue().Set(
70
+ Nan::New<String>((const char *)buf, xmlBufferLength(writer->writerBuffer))
71
+ .ToLocalChecked());
72
+ }
73
+
74
+ void XmlTextWriter::clearBuffer() {
75
+ // Flush the output buffer of the libxml writer instance in order to push all
76
+ // the content to our writerBuffer.
77
+ xmlTextWriterFlush(textWriter);
78
+ // Clear the memory buffer
79
+ xmlBufferEmpty(writerBuffer);
80
+ }
81
+
82
+ NAN_METHOD(XmlTextWriter::BufferEmpty) {
83
+ Nan::HandleScope scope;
84
+
85
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
86
+
87
+ writer->clearBuffer();
88
+
89
+ return info.GetReturnValue().Set(Nan::Undefined());
90
+ }
91
+
92
+ NAN_METHOD(XmlTextWriter::StartDocument) {
93
+ Nan::HandleScope scope;
94
+
95
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
96
+
97
+ Nan::Utf8String version(info[0]);
98
+ Nan::Utf8String encoding(info[1]);
99
+ const char *standalone = NULL;
100
+
101
+ if (info[2]->IsBoolean()) {
102
+ const char *wordBool =
103
+ Nan::To<bool>(info[2]).FromMaybe(false) ? "yes" : "no";
104
+ standalone = *Nan::Utf8String(Nan::New<String>(wordBool).ToLocalChecked());
105
+ } else if (info[2]->IsString()) {
106
+ standalone = *Nan::Utf8String(info[2]);
107
+ }
108
+
109
+ int result = xmlTextWriterStartDocument(
110
+ writer->textWriter, info[0]->IsUndefined() ? NULL : *version,
111
+ info[1]->IsUndefined() ? NULL : *encoding, standalone);
112
+
113
+ THROW_ON_ERROR("Failed to start document");
114
+
115
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
116
+ }
117
+
118
+ NAN_METHOD(XmlTextWriter::EndDocument) {
119
+ Nan::HandleScope scope;
120
+
121
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
122
+
123
+ int result = xmlTextWriterEndDocument(writer->textWriter);
124
+
125
+ THROW_ON_ERROR("Failed to end document");
126
+
127
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
128
+ }
129
+
130
+ NAN_METHOD(XmlTextWriter::StartElementNS) {
131
+ Nan::HandleScope scope;
132
+
133
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
134
+
135
+ Nan::Utf8String prefix(info[0]);
136
+ Nan::Utf8String name(info[1]);
137
+ Nan::Utf8String namespaceURI(info[2]);
138
+
139
+ int result = xmlTextWriterStartElementNS(
140
+ writer->textWriter,
141
+ info[0]->IsUndefined() ? NULL : (const xmlChar *)*prefix,
142
+ info[1]->IsUndefined() ? NULL : (const xmlChar *)*name,
143
+ info[2]->IsUndefined() ? NULL : (const xmlChar *)*namespaceURI);
144
+
145
+ THROW_ON_ERROR("Failed to start element");
146
+
147
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
148
+ }
149
+
150
+ NAN_METHOD(XmlTextWriter::EndElement) {
151
+ Nan::HandleScope scope;
152
+
153
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
154
+
155
+ int result = xmlTextWriterEndElement(writer->textWriter);
156
+
157
+ THROW_ON_ERROR("Failed to end element");
158
+
159
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
160
+ }
161
+
162
+ NAN_METHOD(XmlTextWriter::StartAttributeNS) {
163
+ Nan::HandleScope scope;
164
+
165
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
166
+
167
+ Nan::Utf8String prefix(info[0]);
168
+ Nan::Utf8String name(info[1]);
169
+ Nan::Utf8String namespaceURI(info[2]);
170
+
171
+ int result = xmlTextWriterStartAttributeNS(
172
+ writer->textWriter,
173
+ info[0]->IsUndefined() ? NULL : (const xmlChar *)*prefix,
174
+ info[1]->IsUndefined() ? NULL : (const xmlChar *)*name,
175
+ info[2]->IsUndefined() ? NULL : (const xmlChar *)*namespaceURI);
176
+
177
+ THROW_ON_ERROR("Failed to start attribute");
178
+
179
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
180
+ }
181
+
182
+ NAN_METHOD(XmlTextWriter::EndAttribute) {
183
+ Nan::HandleScope scope;
184
+
185
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
186
+
187
+ int result = xmlTextWriterEndAttribute(writer->textWriter);
188
+
189
+ THROW_ON_ERROR("Failed to end attribute");
190
+
191
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
192
+ }
193
+
194
+ NAN_METHOD(XmlTextWriter::StartCdata) {
195
+ Nan::HandleScope scope;
196
+
197
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
198
+
199
+ int result = xmlTextWriterStartCDATA(writer->textWriter);
200
+
201
+ THROW_ON_ERROR("Failed to start CDATA section");
202
+
203
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
204
+ }
205
+
206
+ NAN_METHOD(XmlTextWriter::EndCdata) {
207
+ Nan::HandleScope scope;
208
+
209
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
210
+
211
+ int result = xmlTextWriterEndCDATA(writer->textWriter);
212
+
213
+ THROW_ON_ERROR("Failed to end CDATA section");
214
+
215
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
216
+ }
217
+
218
+ NAN_METHOD(XmlTextWriter::StartComment) {
219
+ Nan::HandleScope scope;
220
+
221
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
222
+
223
+ int result = xmlTextWriterStartComment(writer->textWriter);
224
+
225
+ THROW_ON_ERROR("Failed to start Comment section");
226
+
227
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
228
+ }
229
+
230
+ NAN_METHOD(XmlTextWriter::EndComment) {
231
+ Nan::HandleScope scope;
232
+
233
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
234
+
235
+ int result = xmlTextWriterEndComment(writer->textWriter);
236
+
237
+ THROW_ON_ERROR("Failed to end Comment section");
238
+
239
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
240
+ }
241
+
242
+ NAN_METHOD(XmlTextWriter::WriteString) {
243
+ Nan::HandleScope scope;
244
+
245
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
246
+
247
+ Nan::Utf8String string(info[0]);
248
+
249
+ int result =
250
+ xmlTextWriterWriteString(writer->textWriter, (const xmlChar *)*string);
251
+
252
+ THROW_ON_ERROR("Failed to write string");
253
+
254
+ return info.GetReturnValue().Set(Nan::New<Number>((double)result));
255
+ }
256
+
257
+ NAN_METHOD(XmlTextWriter::OutputMemory) {
258
+ bool clear = info.Length() == 0 || Nan::To<bool>(info[0]).FromMaybe(true);
259
+ XmlTextWriter *writer = Nan::ObjectWrap::Unwrap<XmlTextWriter>(info.Holder());
260
+
261
+ BufferContent(info);
262
+
263
+ if (clear) {
264
+ writer->clearBuffer();
265
+ }
266
+ }
267
+
268
+ void XmlTextWriter::Initialize(Local<Object> target) {
269
+ Nan::HandleScope scope;
270
+
271
+ Local<FunctionTemplate> writer_t = Nan::New<FunctionTemplate>(NewTextWriter);
272
+
273
+ Nan::Persistent<FunctionTemplate> xml_writer_template;
274
+ xml_writer_template.Reset(writer_t);
275
+
276
+ writer_t->InstanceTemplate()->SetInternalFieldCount(1);
277
+
278
+ Nan::SetPrototypeMethod(writer_t, "toString", XmlTextWriter::BufferContent);
279
+
280
+ Nan::SetPrototypeMethod(writer_t, "outputMemory",
281
+ XmlTextWriter::OutputMemory);
282
+
283
+ Nan::SetPrototypeMethod(writer_t, "clear", XmlTextWriter::BufferEmpty);
284
+
285
+ Nan::SetPrototypeMethod(writer_t, "startDocument",
286
+ XmlTextWriter::StartDocument);
287
+
288
+ Nan::SetPrototypeMethod(writer_t, "endDocument", XmlTextWriter::EndDocument);
289
+
290
+ Nan::SetPrototypeMethod(writer_t, "startElementNS",
291
+ XmlTextWriter::StartElementNS);
292
+
293
+ Nan::SetPrototypeMethod(writer_t, "endElement", XmlTextWriter::EndElement);
294
+
295
+ Nan::SetPrototypeMethod(writer_t, "startAttributeNS",
296
+ XmlTextWriter::StartAttributeNS);
297
+
298
+ Nan::SetPrototypeMethod(writer_t, "endAttribute",
299
+ XmlTextWriter::EndAttribute);
300
+
301
+ Nan::SetPrototypeMethod(writer_t, "startCdata", XmlTextWriter::StartCdata);
302
+
303
+ Nan::SetPrototypeMethod(writer_t, "endCdata", XmlTextWriter::EndCdata);
304
+
305
+ Nan::SetPrototypeMethod(writer_t, "startComment",
306
+ XmlTextWriter::StartComment);
307
+
308
+ Nan::SetPrototypeMethod(writer_t, "endComment", XmlTextWriter::EndComment);
309
+
310
+ Nan::SetPrototypeMethod(writer_t, "writeString", XmlTextWriter::WriteString);
311
+
312
+ Nan::Set(target, Nan::New<String>("TextWriter").ToLocalChecked(),
313
+ Nan::GetFunction(writer_t).ToLocalChecked());
314
+ }
315
+ } // namespace libxmljs
@@ -0,0 +1,62 @@
1
+ // Copyright 2009, Squish Tech, LLC.
2
+ #ifndef SRC_XML_TEXTWRITER_H_
3
+ #define SRC_XML_TEXTWRITER_H_
4
+
5
+ #include "libxmljs.h"
6
+ #include <libxml/xmlwriter.h>
7
+ #include <node.h>
8
+
9
+ namespace libxmljs {
10
+
11
+ class XmlTextWriter : public Nan::ObjectWrap {
12
+ public:
13
+ XmlTextWriter();
14
+ virtual ~XmlTextWriter();
15
+
16
+ static void Initialize(v8::Local<v8::Object> target);
17
+
18
+ static NAN_METHOD(NewTextWriter);
19
+
20
+ static NAN_METHOD(OpenMemory);
21
+
22
+ static NAN_METHOD(BufferContent);
23
+
24
+ static NAN_METHOD(BufferEmpty);
25
+
26
+ static NAN_METHOD(StartDocument);
27
+
28
+ static NAN_METHOD(EndDocument);
29
+
30
+ static NAN_METHOD(StartElementNS);
31
+
32
+ static NAN_METHOD(EndElement);
33
+
34
+ static NAN_METHOD(StartAttributeNS);
35
+
36
+ static NAN_METHOD(EndAttribute);
37
+
38
+ static NAN_METHOD(StartCdata);
39
+
40
+ static NAN_METHOD(EndCdata);
41
+
42
+ static NAN_METHOD(StartComment);
43
+
44
+ static NAN_METHOD(EndComment);
45
+
46
+ static NAN_METHOD(WriteString);
47
+
48
+ static NAN_METHOD(OutputMemory);
49
+
50
+ private:
51
+ xmlTextWriterPtr textWriter;
52
+ xmlBufferPtr writerBuffer;
53
+
54
+ void clearBuffer();
55
+
56
+ bool is_open();
57
+
58
+ bool is_inmemory();
59
+ };
60
+ } // namespace libxmljs
61
+
62
+ #endif // SRC_XML_TEXTWRITER_H_
@@ -0,0 +1,70 @@
1
+ // Copyright 2009, Squish Tech, LLC.
2
+
3
+ #include <libxml/xpath.h>
4
+ #include <libxml/xpathInternals.h>
5
+
6
+ #include "xml_element.h"
7
+ #include "xml_xpath_context.h"
8
+
9
+ using namespace v8;
10
+
11
+ namespace libxmljs {
12
+
13
+ XmlXpathContext::XmlXpathContext(xmlNode *node) {
14
+ ctxt = xmlXPathNewContext(node->doc);
15
+ ctxt->node = node;
16
+ }
17
+
18
+ XmlXpathContext::~XmlXpathContext() { xmlXPathFreeContext(ctxt); }
19
+
20
+ void XmlXpathContext::register_ns(const xmlChar *prefix, const xmlChar *uri) {
21
+ xmlXPathRegisterNs(ctxt, prefix, uri);
22
+ }
23
+
24
+ Local<Value> XmlXpathContext::evaluate(const xmlChar *xpath) {
25
+ Nan::EscapableHandleScope scope;
26
+ xmlXPathObject *xpathobj = xmlXPathEval(xpath, ctxt);
27
+ Local<Value> res;
28
+
29
+ if (xpathobj) {
30
+ switch (xpathobj->type) {
31
+ case XPATH_NODESET: {
32
+ if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) {
33
+ res = Nan::New<Array>(0);
34
+ break;
35
+ }
36
+
37
+ Local<Array> nodes = Nan::New<Array>(xpathobj->nodesetval->nodeNr);
38
+ for (int i = 0; i != xpathobj->nodesetval->nodeNr; ++i) {
39
+ Nan::Set(nodes, i, XmlNode::New(xpathobj->nodesetval->nodeTab[i]));
40
+ }
41
+
42
+ res = nodes;
43
+ break;
44
+ }
45
+
46
+ case XPATH_BOOLEAN:
47
+ res = Nan::New<Boolean>(xpathobj->boolval);
48
+ break;
49
+
50
+ case XPATH_NUMBER:
51
+ res = Nan::New<Number>(xpathobj->floatval);
52
+ break;
53
+
54
+ case XPATH_STRING:
55
+ res = Nan::New<String>((const char *)xpathobj->stringval,
56
+ xmlStrlen(xpathobj->stringval))
57
+ .ToLocalChecked();
58
+ break;
59
+
60
+ default:
61
+ res = Nan::Null();
62
+ break;
63
+ }
64
+ }
65
+
66
+ xmlXPathFreeObject(xpathobj);
67
+ return scope.Escape(res);
68
+ }
69
+
70
+ } // namespace libxmljs
@@ -0,0 +1,23 @@
1
+ // Copyright 2009, Squish Tech, LLC.
2
+ #ifndef SRC_XML_XPATH_CONTEXT_H_
3
+ #define SRC_XML_XPATH_CONTEXT_H_
4
+
5
+ #include <libxml/xpath.h>
6
+
7
+ #include "libxmljs.h"
8
+
9
+ namespace libxmljs {
10
+
11
+ class XmlXpathContext {
12
+ public:
13
+ explicit XmlXpathContext(xmlNode *node);
14
+ ~XmlXpathContext();
15
+
16
+ void register_ns(const xmlChar *prefix, const xmlChar *uri);
17
+ v8::Local<v8::Value> evaluate(const xmlChar *xpath);
18
+
19
+ xmlXPathContext *ctxt;
20
+ };
21
+ } // namespace libxmljs
22
+
23
+ #endif // SRC_XML_XPATH_CONTEXT_H_
@@ -0,0 +1,23 @@
1
+ Except where otherwise noted in the source code (e.g. the files hash.c,
2
+ list.c and the trio files, which are covered by a similar licence but
3
+ with different Copyright notices) all the files are:
4
+
5
+ Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is fur-
12
+ nished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
19
+ NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.