xml-twig 1.7.11 → 1.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/doc/twig.md +1647 -1695
- package/package.json +4 -4
- package/twig.js +1303 -1303
package/doc/twig.md
CHANGED
|
@@ -1,1680 +1,1647 @@
|
|
|
1
|
-
## Classes
|
|
2
|
-
|
|
3
|
-
<dl>
|
|
4
|
-
<dt><a href="#Twig">Twig</a></dt>
|
|
5
|
-
<dd></dd>
|
|
6
|
-
<dt><a href="#Twig">Twig</a></dt>
|
|
7
|
-
<dd></dd>
|
|
8
|
-
<dt><a href="#NotImplementedYet">NotImplementedYet</a></dt>
|
|
9
|
-
<dd><p>Generic error for non implemented feature</p>
|
|
10
|
-
</dd>
|
|
11
|
-
<dt><a href="#UnsupportedParser">UnsupportedParser</a></dt>
|
|
12
|
-
<dd><p>Error for unsupported parser</p>
|
|
13
|
-
</dd>
|
|
14
|
-
<dt><a href="#UnsupportedType">UnsupportedType</a></dt>
|
|
15
|
-
<dd><p>Generic error for unsupported data type</p>
|
|
16
|
-
</dd>
|
|
17
|
-
<dt><a href="#UnsupportedCondition">UnsupportedCondition</a></dt>
|
|
18
|
-
<dd><p>Generic error for unsupported condition</p>
|
|
19
|
-
</dd>
|
|
20
|
-
</dl>
|
|
21
|
-
|
|
22
|
-
## Constants
|
|
23
|
-
|
|
24
|
-
<dl>
|
|
25
|
-
<dt><a href="#SAX">SAX</a></dt>
|
|
26
|
-
<dd></dd>
|
|
27
|
-
<dt><a href="#Root">Root</a> : <code>RootHandler</code></dt>
|
|
28
|
-
<dd></dd>
|
|
29
|
-
<dt><a href="#Any">Any</a> : <code>AnyHandler</code></dt>
|
|
30
|
-
<dd></dd>
|
|
31
|
-
</dl>
|
|
32
|
-
|
|
33
|
-
## Functions
|
|
34
|
-
|
|
35
|
-
<dl>
|
|
36
|
-
<dt><a href="#createParser">createParser(handler, [options])</a> ⇒ <code><a href="#Parser">Parser</a></code></dt>
|
|
37
|
-
<dd><p>Create a new Twig parser</p>
|
|
38
|
-
</dd>
|
|
39
|
-
<dt><a href="#onStart">onStart(parser, binds, node, attrs)</a></dt>
|
|
40
|
-
<dd><p>Common Event hanlder for starting tag</p>
|
|
41
|
-
</dd>
|
|
42
|
-
<dt><a href="#onClose">onClose(handler, parser, parser, options, name)</a></dt>
|
|
43
|
-
<dd><p>Common Event hanlder for closing tag. On closed elements it either calls the Handler function or emits the specified event.</p>
|
|
44
|
-
</dd>
|
|
45
|
-
</dl>
|
|
46
|
-
|
|
47
|
-
## Typedefs
|
|
48
|
-
|
|
49
|
-
<dl>
|
|
50
|
-
<dt><a href="#ParserOptions">ParserOptions</a></dt>
|
|
51
|
-
<dd><p>Optional settings for the Twig parser</p>
|
|
52
|
-
</dd>
|
|
53
|
-
<dt><a href="#TwigHandler">TwigHandler</a></dt>
|
|
54
|
-
<dd><p>Reference to handler functions for Twig objects.<br>
|
|
55
|
-
Element can be specified as string, Regular Expression, custom function, <code>Twig.Root</code> or <code>Twig.Any</code><br>
|
|
56
|
-
You can specify a <code>function</code> or a <code>event</code> name</p>
|
|
57
|
-
</dd>
|
|
58
|
-
<dt><a href="#HandlerCondition">HandlerCondition</a> : <code>string</code> | <code>Array.<string></code> | <code>RegExp</code> | <code><a href="#HandlerConditionFilter">HandlerConditionFilter</a></code> | <code><a href="#Root">Root</a></code> | <code><a href="#Any">Any</a></code></dt>
|
|
59
|
-
<dd><p>Condition to specify when handler shall be called<br> </p>
|
|
60
|
-
<ul>
|
|
61
|
-
<li>If <code>string</code> then the element name must be equal to the string</li>
|
|
62
|
-
<li>If <code>string[]</code> then the element name must be included in string array</li>
|
|
63
|
-
<li>If <code>RegExp</code> then the element name must match the Regular Expression</li>
|
|
64
|
-
<li>If <a href="#HandlerConditionFilter">HandlerConditionFilter</a> then function must return <code>true</code></li>
|
|
65
|
-
<li>Use <code>Twig.Root</code> to call the handler on root element, i.e. when the end of document is reached</li>
|
|
66
|
-
<li>Use <code>Twig.Any</code> to call the handler on every element</li>
|
|
67
|
-
</ul>
|
|
68
|
-
</dd>
|
|
69
|
-
<dt><a href="#HandlerFunction">HandlerFunction</a> : <code>function</code></dt>
|
|
70
|
-
<dd><p>Handler function for Twig objects, i.e. the way you like to use the XML element.</p>
|
|
71
|
-
</dd>
|
|
72
|
-
<dt><a href="#HandlerConditionFilter">HandlerConditionFilter</a> ⇒ <code>boolean</code></dt>
|
|
73
|
-
<dd><p>Custom filter function to specify when handler shall be called</p>
|
|
74
|
-
</dd>
|
|
75
|
-
<dt><a href="#ElementCondition">ElementCondition</a> : <code>string</code> | <code>RegExp</code> | <code><a href="#ElementConditionFilter">ElementConditionFilter</a></code> | <code><a href="#Twig">Twig</a></code> | <code>undefined</code></dt>
|
|
76
|
-
<dd><p>Optional condition to get elements<br> </p>
|
|
77
|
-
<ul>
|
|
78
|
-
<li>If <code>undefined</code>, then all elements are returned.<br> </li>
|
|
79
|
-
<li>If <code>string</code> then the element name must be equal to the string</li>
|
|
80
|
-
<li>If <code>RegExp</code> then the element name must match the Regular Expression</li>
|
|
81
|
-
<li>If <a href="#ElementConditionFilter">ElementConditionFilter</a> then function must return <code>true</code></li>
|
|
82
|
-
<li>Use <a href="#Twig">Twig</a> object to find a specific element</li>
|
|
83
|
-
</ul>
|
|
84
|
-
</dd>
|
|
85
|
-
<dt><a href="#ElementConditionFilter">ElementConditionFilter</a> ⇒ <code>boolean</code></dt>
|
|
86
|
-
<dd><p>Custom filter function to select desired elements</p>
|
|
87
|
-
</dd>
|
|
88
|
-
<dt><a href="#Parser">Parser</a> ⇒ <code><a href="https://www.npmjs.com/package/sax">sax</a></code> | <code><a href="https://www.npmjs.com/package/node-expat">node-expat</a></code></dt>
|
|
89
|
-
<dd></dd>
|
|
90
|
-
<dt><a href="#AttributeCondition">AttributeCondition</a> : <code>string</code> | <code>RegExp</code> | <code><a href="#AttributeConditionFilter">AttributeConditionFilter</a></code></dt>
|
|
91
|
-
<dd><p>Optional condition to get attributes<br> </p>
|
|
92
|
-
<ul>
|
|
93
|
-
<li>If <code>undefined</code>, then all attributes are returned.<br> </li>
|
|
94
|
-
<li>If <code>string</code> then the attribute name must be equal to the string</li>
|
|
95
|
-
<li>If <code>RegExp</code> then the attribute name must match the Regular Expression</li>
|
|
96
|
-
<li>If <a href="#AttributeConditionFilter">AttributeConditionFilter</a> then the attribute must filter function</li>
|
|
97
|
-
</ul>
|
|
98
|
-
</dd>
|
|
99
|
-
<dt><a href="#AttributeConditionFilter">AttributeConditionFilter</a> : <code>function</code></dt>
|
|
100
|
-
<dd><p>Custom filter function to get desired attributes</p>
|
|
101
|
-
</dd>
|
|
102
|
-
<dt><a href="#+PI">#PI</a> : <code>object</code></dt>
|
|
103
|
-
<dd><p>XML Processing Instruction object, exist only on root</p>
|
|
104
|
-
</dd>
|
|
105
|
-
<dt><a href="#+declaration">#declaration</a> : <code>object</code></dt>
|
|
106
|
-
<dd><p>XML Declaration object, exist only on root</p>
|
|
107
|
-
</dd>
|
|
108
|
-
<dt><a href="#+namespace">#namespace</a> : <code>object</code></dt>
|
|
109
|
-
<dd><p>XML namespace of element. Exist onl when parsed with <code>xmlns: true</code></p>
|
|
110
|
-
</dd>
|
|
111
|
-
<dt><a href="#+comment">#comment</a> : <code>string</code> | <code>Array.<string></code></dt>
|
|
112
|
-
<dd><p>Comment or array of comments inside the XML Elements</p>
|
|
113
|
-
</dd>
|
|
114
|
-
</dl>
|
|
115
|
-
|
|
116
|
-
<a name="Twig"></a>
|
|
117
|
-
|
|
118
|
-
## Twig
|
|
119
|
-
**Kind**: global class
|
|
120
|
-
|
|
121
|
-
* [Twig](#Twig)
|
|
122
|
-
* [new Twig()](#new_Twig_new)
|
|
123
|
-
* [new Twig(parser, name, [parent], [attributes], [index])](#new_Twig_new)
|
|
124
|
-
* [.attributes](#Twig+attributes) : <code>object</code> ℗
|
|
125
|
-
* [.text](#Twig+text) : <code>string</code> \| <code>number</code> ℗
|
|
126
|
-
* [.name](#Twig+name) : <code>string</code> ℗
|
|
127
|
-
* [.children](#Twig+children) : [<code>Array.<Twig></code>](#Twig) ℗
|
|
128
|
-
* [.parent](#Twig+parent) : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
129
|
-
* [.pinned](#Twig+pinned) : <code>boolean</code> ℗
|
|
130
|
-
* [.purge](#Twig+purge)
|
|
131
|
-
* [.purgeUpTo](#Twig+purgeUpTo)
|
|
132
|
-
* [.escapeEntity](#Twig+escapeEntity)
|
|
133
|
-
* [.isEmpty](#Twig+isEmpty) ⇒ <code>boolean</code>
|
|
134
|
-
* [.level](#Twig+level) ⇒ <code>number</code>
|
|
135
|
-
* [.isRoot](#Twig+isRoot) ⇒ <code>boolean</code>
|
|
136
|
-
* [.hasChildren](#Twig+hasChildren) ⇒ <code>boolean</code>
|
|
137
|
-
* [.index](#Twig+index) ⇒ <code>number</code>
|
|
138
|
-
* [.path](#Twig+path) ⇒ <code>string</code>
|
|
139
|
-
* [.name](#Twig+name) ⇒ <code>string</code>
|
|
140
|
-
* [.tag](#Twig+tag) ⇒ <code>string</code>
|
|
141
|
-
* [.text](#Twig+text) ⇒ <code>string</code>
|
|
142
|
-
* [.text](#Twig+text)
|
|
143
|
-
* [.pin](#Twig+pin)
|
|
144
|
-
* [.pinned](#Twig+pinned) ⇒ <code>boolean</code>
|
|
145
|
-
* [.close](#Twig+close)
|
|
146
|
-
* [.debug](#Twig+debug) ⇒ <code>string</code>
|
|
147
|
-
* [.toString](#Twig+toString) ⇒ <code>string</code>
|
|
148
|
-
* [.addChild](#Twig+addChild) ℗
|
|
149
|
-
* [.writer](#Twig+writer) ⇒ [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer)
|
|
150
|
-
* [.attr](#Twig+attr) ⇒ <code>string</code> \| <code>number</code> \| <code>object</code>
|
|
151
|
-
* [.attributes](#Twig+attributes) ⇒ <code>object</code>
|
|
152
|
-
* [.hasAttribute](#Twig+hasAttribute) ⇒ <code>boolean</code>
|
|
153
|
-
* [.attribute](#Twig+attribute) ⇒ <code>object</code>
|
|
154
|
-
* [.deleteAttribute](#Twig+deleteAttribute)
|
|
155
|
-
* [.root](#Twig+root) ⇒ [<code>Twig</code>](#Twig)
|
|
156
|
-
* [.parent](#Twig+parent) ⇒ [<code>Twig</code>](#Twig)
|
|
157
|
-
* [.self](#Twig+self) ⇒ [<code>Twig</code>](#Twig)
|
|
158
|
-
* [.children](#Twig+children) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
159
|
-
* [.next](#Twig+next) ⇒ [<code>Twig</code>](#Twig)
|
|
160
|
-
* [.previous](#Twig+previous) ⇒ [<code>Twig</code>](#Twig)
|
|
161
|
-
* [.first](#Twig+first) ⇒ [<code>Twig</code>](#Twig)
|
|
162
|
-
* [.last](#Twig+last) ⇒ [<code>Twig</code>](#Twig)
|
|
163
|
-
* [.isFirstChild](#Twig+isFirstChild) ⇒ <code>boolean</code>
|
|
164
|
-
* [.isLastChild](#Twig+isLastChild) ⇒ <code>boolean</code>
|
|
165
|
-
* [.descendant](#Twig+descendant) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
166
|
-
* [.descendantOrSelf](#Twig+descendantOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
167
|
-
* [.ancestor](#Twig+ancestor) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
168
|
-
* [.ancestorOrSelf](#Twig+ancestorOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
169
|
-
* [.sibling](#Twig+sibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
170
|
-
* [.siblingOrSelf](#Twig+siblingOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
171
|
-
* [.followingSibling](#Twig+followingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
172
|
-
* [.precedingSibling](#Twig+precedingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
173
|
-
* [.nextSibling](#Twig+nextSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
174
|
-
* [.prevSibling](#Twig+prevSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
175
|
-
* [.find](#Twig+find) ⇒ [<code>Twig</code>](#Twig)
|
|
176
|
-
* [.addElement](#Twig+addElement) ⇒ [<code>Twig</code>](#Twig)
|
|
177
|
-
* [.delete](#Twig+delete)
|
|
178
|
-
* [.setRoot(name)](#Twig+setRoot) ℗
|
|
179
|
-
* [.filterElements(elements, [condition])](#Twig+filterElements) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
180
|
-
* [.testElement(element, [condition])](#Twig+testElement) ⇒ <code>boolean</code>
|
|
181
|
-
|
|
182
|
-
<a name="new_Twig_new"></a>
|
|
183
|
-
|
|
184
|
-
### new Twig()
|
|
185
|
-
Generic class modeling a XML Node
|
|
186
|
-
|
|
187
|
-
<a name="new_Twig_new"></a>
|
|
188
|
-
|
|
189
|
-
### new Twig(parser, name, [parent], [attributes], [index])
|
|
190
|
-
Create a new Twig object
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
| Param | Type | Description |
|
|
194
|
-
| --- | --- | --- |
|
|
195
|
-
| parser | [<code>Parser</code>](#Parser) | The main parser object |
|
|
196
|
-
| name | <code>string</code> | The name of the XML element |
|
|
197
|
-
| [parent] | [<code>Twig</code>](#Twig) | The parent object |
|
|
198
|
-
| [attributes] | <code>object</code> | Attribute object |
|
|
199
|
-
| [index] | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
|
|
200
|
-
|
|
201
|
-
<a name="Twig+attributes"></a>
|
|
202
|
-
|
|
203
|
-
### twig.attributes : <code>object</code> ℗
|
|
204
|
-
XML attribute `{ <attribute 1>: <value 1>, <attribute 2>: <value 2>, ... }`
|
|
205
|
-
|
|
206
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
207
|
-
**Access**: private
|
|
208
|
-
<a name="Twig+text"></a>
|
|
209
|
-
|
|
210
|
-
### twig.text : <code>string</code> \| <code>number</code> ℗
|
|
211
|
-
Content of XML Element
|
|
212
|
-
|
|
213
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
214
|
-
**Access**: private
|
|
215
|
-
<a name="Twig+name"></a>
|
|
216
|
-
|
|
217
|
-
### twig.name : <code>string</code> ℗
|
|
218
|
-
The XML tag name
|
|
219
|
-
|
|
220
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
221
|
-
**Access**: private
|
|
222
|
-
<a name="Twig+children"></a>
|
|
223
|
-
|
|
224
|
-
### twig.children : [<code>Array.<Twig></code>](#Twig) ℗
|
|
225
|
-
Child XML Elements
|
|
226
|
-
|
|
227
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
228
|
-
**Access**: private
|
|
229
|
-
<a name="Twig+parent"></a>
|
|
230
|
-
|
|
231
|
-
### twig.parent : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
232
|
-
The parent object. Undefined on root element
|
|
233
|
-
|
|
234
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
235
|
-
**Access**: private
|
|
236
|
-
<a name="Twig+pinned"></a>
|
|
237
|
-
|
|
238
|
-
### twig.pinned : <code>boolean</code> ℗
|
|
239
|
-
Determines whether twig is needed in partial load
|
|
240
|
-
|
|
241
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
242
|
-
**Access**: private
|
|
243
|
-
<a name="Twig+purge"></a>
|
|
244
|
-
|
|
245
|
-
### twig.purge
|
|
246
|
-
Purges the current, typically used after element has been processed.<br>The root object cannot be purged.
|
|
247
|
-
|
|
248
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
249
|
-
<a name="Twig+purgeUpTo"></a>
|
|
250
|
-
|
|
251
|
-
### twig.purgeUpTo
|
|
252
|
-
Purges up to the elt element. This allows you to keep part of the tree in memory when you purge.<br>
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
|
258
|
-
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
|
269
|
-
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
Returns
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Returns
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
XML-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
Returns
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
Returns
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
<a name="Twig+
|
|
473
|
-
|
|
474
|
-
### twig.
|
|
475
|
-
Returns the root
|
|
476
|
-
|
|
477
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
478
|
-
**Returns**: [<code>Twig</code>](#Twig) - The
|
|
479
|
-
<a name="Twig+
|
|
480
|
-
|
|
481
|
-
### twig.
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
<
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
<a name="Twig+
|
|
553
|
-
|
|
554
|
-
### twig.
|
|
555
|
-
Check if the element is the
|
|
556
|
-
|
|
557
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
558
|
-
**Returns**: <code>boolean</code> - `true` if the
|
|
559
|
-
<a name="Twig+
|
|
560
|
-
|
|
561
|
-
### twig.
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
565
|
-
**Returns**: <code>
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
**
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
* [
|
|
764
|
-
* [
|
|
765
|
-
* [
|
|
766
|
-
* [.
|
|
767
|
-
* [.
|
|
768
|
-
* [.
|
|
769
|
-
* [.
|
|
770
|
-
* [.
|
|
771
|
-
* [.
|
|
772
|
-
* [.
|
|
773
|
-
* [.
|
|
774
|
-
* [.
|
|
775
|
-
* [.
|
|
776
|
-
* [.
|
|
777
|
-
* [.
|
|
778
|
-
* [.
|
|
779
|
-
* [.
|
|
780
|
-
* [.
|
|
781
|
-
* [.
|
|
782
|
-
* [.
|
|
783
|
-
* [.
|
|
784
|
-
* [.
|
|
785
|
-
* [.
|
|
786
|
-
* [.
|
|
787
|
-
* [.
|
|
788
|
-
* [.
|
|
789
|
-
* [.
|
|
790
|
-
* [.
|
|
791
|
-
* [.
|
|
792
|
-
* [.
|
|
793
|
-
* [.
|
|
794
|
-
* [.
|
|
795
|
-
* [.
|
|
796
|
-
* [.
|
|
797
|
-
* [.
|
|
798
|
-
* [.
|
|
799
|
-
* [.
|
|
800
|
-
* [.
|
|
801
|
-
* [.
|
|
802
|
-
* [.
|
|
803
|
-
* [.
|
|
804
|
-
* [.
|
|
805
|
-
* [.
|
|
806
|
-
* [.
|
|
807
|
-
* [.
|
|
808
|
-
* [.
|
|
809
|
-
* [.
|
|
810
|
-
* [.
|
|
811
|
-
* [.
|
|
812
|
-
* [.
|
|
813
|
-
* [.
|
|
814
|
-
* [.
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
<
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
**
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
**
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
**
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
**
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
|
902
|
-
|
|
903
|
-
<
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
<
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
Returns
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
Returns
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
Returns
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
<
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
<
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
<
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
|
1037
|
-
|
|
|
1038
|
-
|
|
|
1039
|
-
|
|
1040
|
-
<a name="Twig+
|
|
1041
|
-
|
|
1042
|
-
### twig.
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
|
1049
|
-
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1058
|
-
**Returns**: <code>
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
<
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
<a name="Twig+
|
|
1072
|
-
|
|
1073
|
-
### twig.
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1077
|
-
**Returns**: <code>
|
|
1078
|
-
|
|
1079
|
-
| Param | Type | Description |
|
|
1080
|
-
| --- | --- | --- |
|
|
1081
|
-
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
Returns
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
<
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
**
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
<
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
Returns
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
Returns the
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
**
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
Returns
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
Returns
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
Returns
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
Returns
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
Returns
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
Returns
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
Returns
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
Returns
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
Returns
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
Returns
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
|
1337
|
-
|
|
|
1338
|
-
|
|
|
1339
|
-
|
|
1340
|
-
<a name="Twig+
|
|
1341
|
-
|
|
1342
|
-
### twig.
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
<
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
|
1423
|
-
|
|
1424
|
-
<
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
|
1441
|
-
|
|
1442
|
-
<
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
**
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
<a name="
|
|
1462
|
-
|
|
1463
|
-
##
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
**
|
|
1467
|
-
**
|
|
1468
|
-
**
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
**
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
|
1490
|
-
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
|
1502
|
-
|
|
|
1503
|
-
| parser | [<code>
|
|
1504
|
-
|
|
|
1505
|
-
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
**
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
|
1517
|
-
|
|
|
1518
|
-
|
|
|
1519
|
-
|
|
|
1520
|
-
|
|
|
1521
|
-
|
|
|
1522
|
-
|
|
1523
|
-
<
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
|
1538
|
-
|
|
|
1539
|
-
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
<
|
|
1546
|
-
|
|
1547
|
-
## TwigHandler
|
|
1548
|
-
Reference to handler functions for Twig objects.<br>
|
|
1549
|
-
Element can be specified as string, Regular Expression, custom function, `Twig.Root` or `Twig.Any`<br>
|
|
1550
|
-
You can specify a `function` or a `event` name
|
|
1551
|
-
|
|
1552
|
-
**Kind**: global typedef
|
|
1553
|
-
**Properties**
|
|
1554
|
-
|
|
1555
|
-
| Name | Type | Description |
|
|
1556
|
-
| --- | --- | --- |
|
|
1557
|
-
| tag | [<code>HandlerCondition</code>](#HandlerCondition) | Element specification |
|
|
1558
|
-
| [function] | [<code>HandlerFunction</code>](#HandlerFunction) | Definition of handler function, either anonymous or explicit function |
|
|
1559
|
-
| [event] | <code>string</code> | Type of the event to be emitted |
|
|
1560
|
-
|
|
1561
|
-
<a name="HandlerCondition"></a>
|
|
1562
|
-
|
|
1563
|
-
## HandlerCondition : <code>string</code> \| <code>Array.<string></code> \| <code>RegExp</code> \| [<code>HandlerConditionFilter</code>](#HandlerConditionFilter) \| [<code>Root</code>](#Root) \| [<code>Any</code>](#Any)
|
|
1564
|
-
Condition to specify when handler shall be called<br>
|
|
1565
|
-
- If `string` then the element name must be equal to the string
|
|
1566
|
-
- If `string[]` then the element name must be included in string array
|
|
1567
|
-
- If `RegExp` then the element name must match the Regular Expression
|
|
1568
|
-
- If [HandlerConditionFilter](#HandlerConditionFilter) then function must return `true`
|
|
1569
|
-
- Use `Twig.Root` to call the handler on root element, i.e. when the end of document is reached
|
|
1570
|
-
- Use `Twig.Any` to call the handler on every element
|
|
1571
|
-
|
|
1572
|
-
**Kind**: global typedef
|
|
1573
|
-
<a name="HandlerFunction"></a>
|
|
1574
|
-
|
|
1575
|
-
## HandlerFunction : <code>function</code>
|
|
1576
|
-
Handler function for Twig objects, i.e. the way you like to use the XML element.
|
|
1577
|
-
|
|
1578
|
-
**Kind**: global typedef
|
|
1579
|
-
|
|
1580
|
-
| Param | Type | Description |
|
|
1581
|
-
| --- | --- | --- |
|
|
1582
|
-
| elt | [<code>Twig</code>](#Twig) | The current Twig element on which the function was called. |
|
|
1583
|
-
|
|
1584
|
-
<a name="HandlerConditionFilter"></a>
|
|
1585
|
-
|
|
1586
|
-
## HandlerConditionFilter ⇒ <code>boolean</code>
|
|
1587
|
-
Custom filter function to specify when handler shall be called
|
|
1588
|
-
|
|
1589
|
-
**Kind**: global typedef
|
|
1590
|
-
**Returns**: <code>boolean</code> - If the function returns `true`, then it is included in the filter
|
|
1591
|
-
|
|
1592
|
-
| Param | Type | Description |
|
|
1593
|
-
| --- | --- | --- |
|
|
1594
|
-
| name | <code>string</code> | Name of the element |
|
|
1595
|
-
|
|
1596
|
-
<a name="ElementCondition"></a>
|
|
1597
|
-
|
|
1598
|
-
## ElementCondition : <code>string</code> \| <code>RegExp</code> \| [<code>ElementConditionFilter</code>](#ElementConditionFilter) \| [<code>Twig</code>](#Twig) \| <code>undefined</code>
|
|
1599
|
-
Optional condition to get elements<br>
|
|
1600
|
-
- If `undefined`, then all elements are returned.<br>
|
|
1601
|
-
- If `string` then the element name must be equal to the string
|
|
1602
|
-
- If `RegExp` then the element name must match the Regular Expression
|
|
1603
|
-
- If [ElementConditionFilter](#ElementConditionFilter) then function must return `true`
|
|
1604
|
-
- Use [Twig](#Twig) object to find a specific element
|
|
1605
|
-
|
|
1606
|
-
**Kind**: global typedef
|
|
1607
|
-
<a name="ElementConditionFilter"></a>
|
|
1608
|
-
|
|
1609
|
-
## ElementConditionFilter ⇒ <code>boolean</code>
|
|
1610
|
-
Custom filter function to select desired elements
|
|
1611
|
-
|
|
1612
|
-
**Kind**: global typedef
|
|
1613
|
-
**Returns**: <code>boolean</code> - If the function returns `true`, then it is included in the filter
|
|
1614
|
-
|
|
1615
|
-
| Param | Type | Description |
|
|
1616
|
-
| --- | --- | --- |
|
|
1617
|
-
| name | <code>string</code> | Name of the element |
|
|
1618
|
-
| elt | [<code>Twig</code>](#Twig) | The Twig object |
|
|
1619
|
-
|
|
1620
|
-
<a name="Parser"></a>
|
|
1621
|
-
|
|
1622
|
-
## Parser ⇒ [<code>sax</code>](https://www.npmjs.com/package/sax) \| [<code>node-expat</code>](https://www.npmjs.com/package/node-expat)
|
|
1623
|
-
**Kind**: global typedef
|
|
1624
|
-
**Returns**: [<code>sax</code>](https://www.npmjs.com/package/sax) \| [<code>node-expat</code>](https://www.npmjs.com/package/node-expat) - The parser Object
|
|
1625
|
-
**Properties**
|
|
1626
|
-
|
|
1627
|
-
| Name | Type | Description |
|
|
1628
|
-
| --- | --- | --- |
|
|
1629
|
-
| [currentLine] | <code>number</code> | The currently processed line in the XML-File. |
|
|
1630
|
-
| [currentColumn] | <code>number</code> | The currently processed column in the XML-File. |
|
|
1631
|
-
| [file] | <code>string</code> | The name of file to be parsed. Just used for information and logging purpose. |
|
|
1632
|
-
| [twig] | <code>object</code> | Object with XML tree and current XML element |
|
|
1633
|
-
| [method] | <code>string</code> | The underlying parser. Either `'sax'`, `'expat'`. |
|
|
1634
|
-
|
|
1635
|
-
<a name="AttributeCondition"></a>
|
|
1636
|
-
|
|
1637
|
-
## AttributeCondition : <code>string</code> \| <code>RegExp</code> \| [<code>AttributeConditionFilter</code>](#AttributeConditionFilter)
|
|
1638
|
-
Optional condition to get attributes<br>
|
|
1639
|
-
- If `undefined`, then all attributes are returned.<br>
|
|
1640
|
-
- If `string` then the attribute name must be equal to the string
|
|
1641
|
-
- If `RegExp` then the attribute name must match the Regular Expression
|
|
1642
|
-
- If [AttributeConditionFilter](#AttributeConditionFilter) then the attribute must filter function
|
|
1643
|
-
|
|
1644
|
-
**Kind**: global typedef
|
|
1645
|
-
<a name="AttributeConditionFilter"></a>
|
|
1646
|
-
|
|
1647
|
-
## AttributeConditionFilter : <code>function</code>
|
|
1648
|
-
Custom filter function to get desired attributes
|
|
1649
|
-
|
|
1650
|
-
**Kind**: global typedef
|
|
1651
|
-
|
|
1652
|
-
| Param | Type | Description |
|
|
1653
|
-
| --- | --- | --- |
|
|
1654
|
-
| name | <code>string</code> | Name of the attribute |
|
|
1655
|
-
| value | <code>string</code> \| <code>number</code> | Value of the attribute |
|
|
1656
|
-
|
|
1657
|
-
<a name="+PI"></a>
|
|
1658
|
-
|
|
1659
|
-
## #PI : <code>object</code>
|
|
1660
|
-
XML Processing Instruction object, exist only on root
|
|
1661
|
-
|
|
1662
|
-
**Kind**: global typedef
|
|
1663
|
-
<a name="+declaration"></a>
|
|
1664
|
-
|
|
1665
|
-
## #declaration : <code>object</code>
|
|
1666
|
-
XML Declaration object, exist only on root
|
|
1667
|
-
|
|
1668
|
-
**Kind**: global typedef
|
|
1669
|
-
<a name="+namespace"></a>
|
|
1670
|
-
|
|
1671
|
-
## #namespace : <code>object</code>
|
|
1672
|
-
XML namespace of element. Exist onl when parsed with `xmlns: true`
|
|
1673
|
-
|
|
1674
|
-
**Kind**: global typedef
|
|
1675
|
-
<a name="+comment"></a>
|
|
1676
|
-
|
|
1677
|
-
## #comment : <code>string</code> \| <code>Array.<string></code>
|
|
1678
|
-
Comment or array of comments inside the XML Elements
|
|
1679
|
-
|
|
1680
|
-
**Kind**: global typedef
|
|
1
|
+
## Classes
|
|
2
|
+
|
|
3
|
+
<dl>
|
|
4
|
+
<dt><a href="#Twig">Twig</a></dt>
|
|
5
|
+
<dd></dd>
|
|
6
|
+
<dt><a href="#Twig">Twig</a></dt>
|
|
7
|
+
<dd></dd>
|
|
8
|
+
<dt><a href="#NotImplementedYet">NotImplementedYet</a></dt>
|
|
9
|
+
<dd><p>Generic error for non implemented feature</p>
|
|
10
|
+
</dd>
|
|
11
|
+
<dt><a href="#UnsupportedParser">UnsupportedParser</a></dt>
|
|
12
|
+
<dd><p>Error for unsupported parser</p>
|
|
13
|
+
</dd>
|
|
14
|
+
<dt><a href="#UnsupportedType">UnsupportedType</a></dt>
|
|
15
|
+
<dd><p>Generic error for unsupported data type</p>
|
|
16
|
+
</dd>
|
|
17
|
+
<dt><a href="#UnsupportedCondition">UnsupportedCondition</a></dt>
|
|
18
|
+
<dd><p>Generic error for unsupported condition</p>
|
|
19
|
+
</dd>
|
|
20
|
+
</dl>
|
|
21
|
+
|
|
22
|
+
## Constants
|
|
23
|
+
|
|
24
|
+
<dl>
|
|
25
|
+
<dt><a href="#SAX">SAX</a></dt>
|
|
26
|
+
<dd></dd>
|
|
27
|
+
<dt><a href="#Root">Root</a> : <code>RootHandler</code></dt>
|
|
28
|
+
<dd></dd>
|
|
29
|
+
<dt><a href="#Any">Any</a> : <code>AnyHandler</code></dt>
|
|
30
|
+
<dd></dd>
|
|
31
|
+
</dl>
|
|
32
|
+
|
|
33
|
+
## Functions
|
|
34
|
+
|
|
35
|
+
<dl>
|
|
36
|
+
<dt><a href="#createParser">createParser(handler, [options])</a> ⇒ <code><a href="#Parser">Parser</a></code></dt>
|
|
37
|
+
<dd><p>Create a new Twig parser</p>
|
|
38
|
+
</dd>
|
|
39
|
+
<dt><a href="#onStart">onStart(parser, binds, node, attrs)</a></dt>
|
|
40
|
+
<dd><p>Common Event hanlder for starting tag</p>
|
|
41
|
+
</dd>
|
|
42
|
+
<dt><a href="#onClose">onClose(handler, parser, parser, options, name)</a></dt>
|
|
43
|
+
<dd><p>Common Event hanlder for closing tag. On closed elements it either calls the Handler function or emits the specified event.</p>
|
|
44
|
+
</dd>
|
|
45
|
+
</dl>
|
|
46
|
+
|
|
47
|
+
## Typedefs
|
|
48
|
+
|
|
49
|
+
<dl>
|
|
50
|
+
<dt><a href="#ParserOptions">ParserOptions</a></dt>
|
|
51
|
+
<dd><p>Optional settings for the Twig parser</p>
|
|
52
|
+
</dd>
|
|
53
|
+
<dt><a href="#TwigHandler">TwigHandler</a></dt>
|
|
54
|
+
<dd><p>Reference to handler functions for Twig objects.<br>
|
|
55
|
+
Element can be specified as string, Regular Expression, custom function, <code>Twig.Root</code> or <code>Twig.Any</code><br>
|
|
56
|
+
You can specify a <code>function</code> or a <code>event</code> name</p>
|
|
57
|
+
</dd>
|
|
58
|
+
<dt><a href="#HandlerCondition">HandlerCondition</a> : <code>string</code> | <code>Array.<string></code> | <code>RegExp</code> | <code><a href="#HandlerConditionFilter">HandlerConditionFilter</a></code> | <code><a href="#Root">Root</a></code> | <code><a href="#Any">Any</a></code></dt>
|
|
59
|
+
<dd><p>Condition to specify when handler shall be called<br> </p>
|
|
60
|
+
<ul>
|
|
61
|
+
<li>If <code>string</code> then the element name must be equal to the string</li>
|
|
62
|
+
<li>If <code>string[]</code> then the element name must be included in string array</li>
|
|
63
|
+
<li>If <code>RegExp</code> then the element name must match the Regular Expression</li>
|
|
64
|
+
<li>If <a href="#HandlerConditionFilter">HandlerConditionFilter</a> then function must return <code>true</code></li>
|
|
65
|
+
<li>Use <code>Twig.Root</code> to call the handler on root element, i.e. when the end of document is reached</li>
|
|
66
|
+
<li>Use <code>Twig.Any</code> to call the handler on every element</li>
|
|
67
|
+
</ul>
|
|
68
|
+
</dd>
|
|
69
|
+
<dt><a href="#HandlerFunction">HandlerFunction</a> : <code>function</code></dt>
|
|
70
|
+
<dd><p>Handler function for Twig objects, i.e. the way you like to use the XML element.</p>
|
|
71
|
+
</dd>
|
|
72
|
+
<dt><a href="#HandlerConditionFilter">HandlerConditionFilter</a> ⇒ <code>boolean</code></dt>
|
|
73
|
+
<dd><p>Custom filter function to specify when handler shall be called</p>
|
|
74
|
+
</dd>
|
|
75
|
+
<dt><a href="#ElementCondition">ElementCondition</a> : <code>string</code> | <code>RegExp</code> | <code><a href="#ElementConditionFilter">ElementConditionFilter</a></code> | <code><a href="#Twig">Twig</a></code> | <code>undefined</code></dt>
|
|
76
|
+
<dd><p>Optional condition to get elements<br> </p>
|
|
77
|
+
<ul>
|
|
78
|
+
<li>If <code>undefined</code>, then all elements are returned.<br> </li>
|
|
79
|
+
<li>If <code>string</code> then the element name must be equal to the string</li>
|
|
80
|
+
<li>If <code>RegExp</code> then the element name must match the Regular Expression</li>
|
|
81
|
+
<li>If <a href="#ElementConditionFilter">ElementConditionFilter</a> then function must return <code>true</code></li>
|
|
82
|
+
<li>Use <a href="#Twig">Twig</a> object to find a specific element</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</dd>
|
|
85
|
+
<dt><a href="#ElementConditionFilter">ElementConditionFilter</a> ⇒ <code>boolean</code></dt>
|
|
86
|
+
<dd><p>Custom filter function to select desired elements</p>
|
|
87
|
+
</dd>
|
|
88
|
+
<dt><a href="#Parser">Parser</a> ⇒ <code><a href="https://www.npmjs.com/package/sax">sax</a></code> | <code><a href="https://www.npmjs.com/package/node-expat">node-expat</a></code></dt>
|
|
89
|
+
<dd></dd>
|
|
90
|
+
<dt><a href="#AttributeCondition">AttributeCondition</a> : <code>string</code> | <code>RegExp</code> | <code><a href="#AttributeConditionFilter">AttributeConditionFilter</a></code></dt>
|
|
91
|
+
<dd><p>Optional condition to get attributes<br> </p>
|
|
92
|
+
<ul>
|
|
93
|
+
<li>If <code>undefined</code>, then all attributes are returned.<br> </li>
|
|
94
|
+
<li>If <code>string</code> then the attribute name must be equal to the string</li>
|
|
95
|
+
<li>If <code>RegExp</code> then the attribute name must match the Regular Expression</li>
|
|
96
|
+
<li>If <a href="#AttributeConditionFilter">AttributeConditionFilter</a> then the attribute must filter function</li>
|
|
97
|
+
</ul>
|
|
98
|
+
</dd>
|
|
99
|
+
<dt><a href="#AttributeConditionFilter">AttributeConditionFilter</a> : <code>function</code></dt>
|
|
100
|
+
<dd><p>Custom filter function to get desired attributes</p>
|
|
101
|
+
</dd>
|
|
102
|
+
<dt><a href="#+PI">#PI</a> : <code>object</code></dt>
|
|
103
|
+
<dd><p>XML Processing Instruction object, exist only on root</p>
|
|
104
|
+
</dd>
|
|
105
|
+
<dt><a href="#+declaration">#declaration</a> : <code>object</code></dt>
|
|
106
|
+
<dd><p>XML Declaration object, exist only on root</p>
|
|
107
|
+
</dd>
|
|
108
|
+
<dt><a href="#+namespace">#namespace</a> : <code>object</code></dt>
|
|
109
|
+
<dd><p>XML namespace of element. Exist onl when parsed with <code>xmlns: true</code></p>
|
|
110
|
+
</dd>
|
|
111
|
+
<dt><a href="#+comment">#comment</a> : <code>string</code> | <code>Array.<string></code></dt>
|
|
112
|
+
<dd><p>Comment or array of comments inside the XML Elements</p>
|
|
113
|
+
</dd>
|
|
114
|
+
</dl>
|
|
115
|
+
|
|
116
|
+
<a name="Twig"></a>
|
|
117
|
+
|
|
118
|
+
## Twig
|
|
119
|
+
**Kind**: global class
|
|
120
|
+
|
|
121
|
+
* [Twig](#Twig)
|
|
122
|
+
* [new Twig()](#new_Twig_new)
|
|
123
|
+
* [new Twig(parser, name, [parent], [attributes], [index])](#new_Twig_new)
|
|
124
|
+
* [.attributes](#Twig+attributes) : <code>object</code> ℗
|
|
125
|
+
* [.text](#Twig+text) : <code>string</code> \| <code>number</code> ℗
|
|
126
|
+
* [.name](#Twig+name) : <code>string</code> ℗
|
|
127
|
+
* [.children](#Twig+children) : [<code>Array.<Twig></code>](#Twig) ℗
|
|
128
|
+
* [.parent](#Twig+parent) : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
129
|
+
* [.pinned](#Twig+pinned) : <code>boolean</code> ℗
|
|
130
|
+
* [.purge](#Twig+purge)
|
|
131
|
+
* [.purgeUpTo](#Twig+purgeUpTo)
|
|
132
|
+
* [.escapeEntity](#Twig+escapeEntity)
|
|
133
|
+
* [.isEmpty](#Twig+isEmpty) ⇒ <code>boolean</code>
|
|
134
|
+
* [.level](#Twig+level) ⇒ <code>number</code>
|
|
135
|
+
* [.isRoot](#Twig+isRoot) ⇒ <code>boolean</code>
|
|
136
|
+
* [.hasChildren](#Twig+hasChildren) ⇒ <code>boolean</code>
|
|
137
|
+
* [.index](#Twig+index) ⇒ <code>number</code>
|
|
138
|
+
* [.path](#Twig+path) ⇒ <code>string</code>
|
|
139
|
+
* [.name](#Twig+name) ⇒ <code>string</code>
|
|
140
|
+
* [.tag](#Twig+tag) ⇒ <code>string</code>
|
|
141
|
+
* [.text](#Twig+text) ⇒ <code>string</code>
|
|
142
|
+
* [.text](#Twig+text)
|
|
143
|
+
* [.pin](#Twig+pin)
|
|
144
|
+
* [.pinned](#Twig+pinned) ⇒ <code>boolean</code>
|
|
145
|
+
* [.close](#Twig+close)
|
|
146
|
+
* [.debug](#Twig+debug) ⇒ <code>string</code>
|
|
147
|
+
* [.toString](#Twig+toString) ⇒ <code>string</code>
|
|
148
|
+
* [.addChild](#Twig+addChild) ℗
|
|
149
|
+
* [.writer](#Twig+writer) ⇒ [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer)
|
|
150
|
+
* [.attr](#Twig+attr) ⇒ <code>string</code> \| <code>number</code> \| <code>object</code>
|
|
151
|
+
* [.attributes](#Twig+attributes) ⇒ <code>object</code>
|
|
152
|
+
* [.hasAttribute](#Twig+hasAttribute) ⇒ <code>boolean</code>
|
|
153
|
+
* [.attribute](#Twig+attribute) ⇒ <code>object</code>
|
|
154
|
+
* [.deleteAttribute](#Twig+deleteAttribute)
|
|
155
|
+
* [.root](#Twig+root) ⇒ [<code>Twig</code>](#Twig)
|
|
156
|
+
* [.parent](#Twig+parent) ⇒ [<code>Twig</code>](#Twig)
|
|
157
|
+
* [.self](#Twig+self) ⇒ [<code>Twig</code>](#Twig)
|
|
158
|
+
* [.children](#Twig+children) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
159
|
+
* [.next](#Twig+next) ⇒ [<code>Twig</code>](#Twig)
|
|
160
|
+
* [.previous](#Twig+previous) ⇒ [<code>Twig</code>](#Twig)
|
|
161
|
+
* [.first](#Twig+first) ⇒ [<code>Twig</code>](#Twig)
|
|
162
|
+
* [.last](#Twig+last) ⇒ [<code>Twig</code>](#Twig)
|
|
163
|
+
* [.isFirstChild](#Twig+isFirstChild) ⇒ <code>boolean</code>
|
|
164
|
+
* [.isLastChild](#Twig+isLastChild) ⇒ <code>boolean</code>
|
|
165
|
+
* [.descendant](#Twig+descendant) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
166
|
+
* [.descendantOrSelf](#Twig+descendantOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
167
|
+
* [.ancestor](#Twig+ancestor) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
168
|
+
* [.ancestorOrSelf](#Twig+ancestorOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
169
|
+
* [.sibling](#Twig+sibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
170
|
+
* [.siblingOrSelf](#Twig+siblingOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
171
|
+
* [.followingSibling](#Twig+followingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
172
|
+
* [.precedingSibling](#Twig+precedingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
173
|
+
* [.nextSibling](#Twig+nextSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
174
|
+
* [.prevSibling](#Twig+prevSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
175
|
+
* [.find](#Twig+find) ⇒ [<code>Twig</code>](#Twig)
|
|
176
|
+
* [.addElement](#Twig+addElement) ⇒ [<code>Twig</code>](#Twig)
|
|
177
|
+
* [.delete](#Twig+delete)
|
|
178
|
+
* [.setRoot(name)](#Twig+setRoot) ℗
|
|
179
|
+
* [.filterElements(elements, [condition])](#Twig+filterElements) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
180
|
+
* [.testElement(element, [condition])](#Twig+testElement) ⇒ <code>boolean</code>
|
|
181
|
+
|
|
182
|
+
<a name="new_Twig_new"></a>
|
|
183
|
+
|
|
184
|
+
### new Twig()
|
|
185
|
+
Generic class modeling a XML Node
|
|
186
|
+
|
|
187
|
+
<a name="new_Twig_new"></a>
|
|
188
|
+
|
|
189
|
+
### new Twig(parser, name, [parent], [attributes], [index])
|
|
190
|
+
Create a new Twig object
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
| Param | Type | Description |
|
|
194
|
+
| --- | --- | --- |
|
|
195
|
+
| parser | [<code>Parser</code>](#Parser) | The main parser object |
|
|
196
|
+
| name | <code>string</code> | The name of the XML element |
|
|
197
|
+
| [parent] | [<code>Twig</code>](#Twig) | The parent object |
|
|
198
|
+
| [attributes] | <code>object</code> | Attribute object |
|
|
199
|
+
| [index] | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
|
|
200
|
+
|
|
201
|
+
<a name="Twig+attributes"></a>
|
|
202
|
+
|
|
203
|
+
### twig.attributes : <code>object</code> ℗
|
|
204
|
+
XML attribute `{ <attribute 1>: <value 1>, <attribute 2>: <value 2>, ... }`
|
|
205
|
+
|
|
206
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
207
|
+
**Access**: private
|
|
208
|
+
<a name="Twig+text"></a>
|
|
209
|
+
|
|
210
|
+
### twig.text : <code>string</code> \| <code>number</code> ℗
|
|
211
|
+
Content of XML Element
|
|
212
|
+
|
|
213
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
214
|
+
**Access**: private
|
|
215
|
+
<a name="Twig+name"></a>
|
|
216
|
+
|
|
217
|
+
### twig.name : <code>string</code> ℗
|
|
218
|
+
The XML tag name
|
|
219
|
+
|
|
220
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
221
|
+
**Access**: private
|
|
222
|
+
<a name="Twig+children"></a>
|
|
223
|
+
|
|
224
|
+
### twig.children : [<code>Array.<Twig></code>](#Twig) ℗
|
|
225
|
+
Child XML Elements
|
|
226
|
+
|
|
227
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
228
|
+
**Access**: private
|
|
229
|
+
<a name="Twig+parent"></a>
|
|
230
|
+
|
|
231
|
+
### twig.parent : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
232
|
+
The parent object. Undefined on root element
|
|
233
|
+
|
|
234
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
235
|
+
**Access**: private
|
|
236
|
+
<a name="Twig+pinned"></a>
|
|
237
|
+
|
|
238
|
+
### twig.pinned : <code>boolean</code> ℗
|
|
239
|
+
Determines whether twig is needed in partial load
|
|
240
|
+
|
|
241
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
242
|
+
**Access**: private
|
|
243
|
+
<a name="Twig+purge"></a>
|
|
244
|
+
|
|
245
|
+
### twig.purge
|
|
246
|
+
Purges the current, typically used after element has been processed.<br>The root object cannot be purged.
|
|
247
|
+
|
|
248
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
249
|
+
<a name="Twig+purgeUpTo"></a>
|
|
250
|
+
|
|
251
|
+
### twig.purgeUpTo
|
|
252
|
+
Purges up to the elt element. This allows you to keep part of the tree in memory when you purge.<br>
|
|
253
|
+
|
|
254
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
255
|
+
|
|
256
|
+
| Param | Type | Description |
|
|
257
|
+
| --- | --- | --- |
|
|
258
|
+
| [elt] | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
|
|
259
|
+
|
|
260
|
+
<a name="Twig+escapeEntity"></a>
|
|
261
|
+
|
|
262
|
+
### twig.escapeEntity
|
|
263
|
+
Escapes special XML characters. According W3C specification these are only `&, <, >, ", '` - this is a XML parser, not HTML!
|
|
264
|
+
|
|
265
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
266
|
+
|
|
267
|
+
| Param | Type | Description |
|
|
268
|
+
| --- | --- | --- |
|
|
269
|
+
| text | <code>string</code> | Input text to be escaped |
|
|
270
|
+
|
|
271
|
+
<a name="Twig+isEmpty"></a>
|
|
272
|
+
|
|
273
|
+
### twig.isEmpty ⇒ <code>boolean</code>
|
|
274
|
+
Returns `true` if the element is empty, otherwise `false`.
|
|
275
|
+
|
|
276
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
277
|
+
**Returns**: <code>boolean</code> - true if empty element
|
|
278
|
+
<a name="Twig+level"></a>
|
|
279
|
+
|
|
280
|
+
### twig.level ⇒ <code>number</code>
|
|
281
|
+
Returns the level of the element. Root element has 0, children have 1, grand-children 2 and so on
|
|
282
|
+
|
|
283
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
284
|
+
**Returns**: <code>number</code> - The level of the element.
|
|
285
|
+
<a name="Twig+isRoot"></a>
|
|
286
|
+
|
|
287
|
+
### twig.isRoot ⇒ <code>boolean</code>
|
|
288
|
+
Returns `true` if element is the root object
|
|
289
|
+
|
|
290
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
291
|
+
**Returns**: <code>boolean</code> - true if root element
|
|
292
|
+
<a name="Twig+hasChildren"></a>
|
|
293
|
+
|
|
294
|
+
### twig.hasChildren ⇒ <code>boolean</code>
|
|
295
|
+
Returns `true` if element has child elements
|
|
296
|
+
|
|
297
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
298
|
+
**Returns**: <code>boolean</code> - true if has child elements exists
|
|
299
|
+
<a name="Twig+index"></a>
|
|
300
|
+
|
|
301
|
+
### twig.index ⇒ <code>number</code>
|
|
302
|
+
The position in `#children` array. For root object 0
|
|
303
|
+
|
|
304
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
305
|
+
**Returns**: <code>number</code> - Position of element in parent
|
|
306
|
+
<a name="Twig+path"></a>
|
|
307
|
+
|
|
308
|
+
### twig.path ⇒ <code>string</code>
|
|
309
|
+
The X-Path position of the element
|
|
310
|
+
|
|
311
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
312
|
+
**Returns**: <code>string</code> - X-Path
|
|
313
|
+
<a name="Twig+name"></a>
|
|
314
|
+
|
|
315
|
+
### twig.name ⇒ <code>string</code>
|
|
316
|
+
Returns the name of the element.
|
|
317
|
+
|
|
318
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
319
|
+
**Returns**: <code>string</code> - Element name
|
|
320
|
+
<a name="Twig+tag"></a>
|
|
321
|
+
|
|
322
|
+
### twig.tag ⇒ <code>string</code>
|
|
323
|
+
Returns the name of the element. Synonym for `twig.name`
|
|
324
|
+
|
|
325
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
326
|
+
**Returns**: <code>string</code> - Element name
|
|
327
|
+
<a name="Twig+text"></a>
|
|
328
|
+
|
|
329
|
+
### twig.text ⇒ <code>string</code>
|
|
330
|
+
The text of the element. No matter if given as text or CDATA entity
|
|
331
|
+
|
|
332
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
333
|
+
**Returns**: <code>string</code> - Element text or empty string
|
|
334
|
+
<a name="Twig+text"></a>
|
|
335
|
+
|
|
336
|
+
### twig.text
|
|
337
|
+
Update the text of the element
|
|
338
|
+
|
|
339
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
340
|
+
**Throws**:
|
|
341
|
+
|
|
342
|
+
- [<code>UnsupportedType</code>](#UnsupportedType) - If value is not a string, boolean or numeric type
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
| Param | Type | Description |
|
|
346
|
+
| --- | --- | --- |
|
|
347
|
+
| value | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New text of the element |
|
|
348
|
+
|
|
349
|
+
<a name="Twig+pin"></a>
|
|
350
|
+
|
|
351
|
+
### twig.pin
|
|
352
|
+
Pins the current element. Used for partial reading.
|
|
353
|
+
|
|
354
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
355
|
+
<a name="Twig+pinned"></a>
|
|
356
|
+
|
|
357
|
+
### twig.pinned ⇒ <code>boolean</code>
|
|
358
|
+
Checks if element is pinned
|
|
359
|
+
|
|
360
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
361
|
+
**Returns**: <code>boolean</code> - `true` when the element is pinned
|
|
362
|
+
<a name="Twig+close"></a>
|
|
363
|
+
|
|
364
|
+
### twig.close
|
|
365
|
+
Closes the element
|
|
366
|
+
|
|
367
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
368
|
+
<a name="Twig+debug"></a>
|
|
369
|
+
|
|
370
|
+
### twig.debug ⇒ <code>string</code>
|
|
371
|
+
XML-Twig for dummies :-)
|
|
372
|
+
|
|
373
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
374
|
+
**Returns**: <code>string</code> - The XML-Tree which is currently available in RAM - no valid XML Structure
|
|
375
|
+
<a name="Twig+toString"></a>
|
|
376
|
+
|
|
377
|
+
### twig.toString ⇒ <code>string</code>
|
|
378
|
+
Returns XML string of the element
|
|
379
|
+
|
|
380
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
381
|
+
**Returns**: <code>string</code> - The XML-Element as string
|
|
382
|
+
<a name="Twig+addChild"></a>
|
|
383
|
+
|
|
384
|
+
### twig.addChild ℗
|
|
385
|
+
Internal recursive function used by `writer()`
|
|
386
|
+
|
|
387
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
388
|
+
**Access**: private
|
|
389
|
+
|
|
390
|
+
| Param | Type | Description |
|
|
391
|
+
| --- | --- | --- |
|
|
392
|
+
| xw | [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer) | The writer object |
|
|
393
|
+
| childArray | [<code>Array.<Twig></code>](#Twig) | Array of child elements |
|
|
394
|
+
|
|
395
|
+
<a name="Twig+writer"></a>
|
|
396
|
+
|
|
397
|
+
### twig.writer ⇒ [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer)
|
|
398
|
+
Creates xml-writer from current element
|
|
399
|
+
|
|
400
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
401
|
+
|
|
402
|
+
| Param | Type | Description |
|
|
403
|
+
| --- | --- | --- |
|
|
404
|
+
| par | <code>boolean</code> \| <code>string</code> \| [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer) | `true` or intention character or an already created XMLWriter |
|
|
405
|
+
|
|
406
|
+
<a name="Twig+attr"></a>
|
|
407
|
+
|
|
408
|
+
### twig.attr ⇒ <code>string</code> \| <code>number</code> \| <code>object</code>
|
|
409
|
+
Returns attribute value or `null` if not found.<br>
|
|
410
|
+
|
|
411
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
412
|
+
**Returns**: <code>string</code> \| <code>number</code> \| <code>object</code> - - The value of the attribute or `null` if the does not exist
|
|
413
|
+
|
|
414
|
+
| Param | Type | Description |
|
|
415
|
+
| --- | --- | --- |
|
|
416
|
+
| [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
|
|
417
|
+
|
|
418
|
+
<a name="Twig+attributes"></a>
|
|
419
|
+
|
|
420
|
+
### twig.attributes ⇒ <code>object</code>
|
|
421
|
+
Returns all attributes of the element
|
|
422
|
+
|
|
423
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
424
|
+
**Returns**: <code>object</code> - All XML Attributes
|
|
425
|
+
<a name="Twig+hasAttribute"></a>
|
|
426
|
+
|
|
427
|
+
### twig.hasAttribute ⇒ <code>boolean</code>
|
|
428
|
+
Check if the attribute exist or not
|
|
429
|
+
|
|
430
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
431
|
+
**Returns**: <code>boolean</code> - - Returns `true` if the attribute exists, else `false`
|
|
432
|
+
|
|
433
|
+
| Param | Type | Description |
|
|
434
|
+
| --- | --- | --- |
|
|
435
|
+
| name | <code>string</code> | The name of the attribute |
|
|
436
|
+
|
|
437
|
+
<a name="Twig+attribute"></a>
|
|
438
|
+
|
|
439
|
+
### twig.attribute ⇒ <code>object</code>
|
|
440
|
+
Retrieve or update XML attribute. For update, the condition must be a string, i.e. must match to one attribute only.
|
|
441
|
+
|
|
442
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
443
|
+
**Returns**: <code>object</code> - Attributes or `null` if no matching attribute found
|
|
444
|
+
|
|
445
|
+
| Param | Type | Description |
|
|
446
|
+
| --- | --- | --- |
|
|
447
|
+
| [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
|
|
448
|
+
| [value] | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
|
|
449
|
+
|
|
450
|
+
**Example**
|
|
451
|
+
```js
|
|
452
|
+
attribute((name, val) => { return name === 'age' && val > 50})
|
|
453
|
+
```
|
|
454
|
+
<a name="Twig+deleteAttribute"></a>
|
|
455
|
+
|
|
456
|
+
### twig.deleteAttribute
|
|
457
|
+
Delete the attribute
|
|
458
|
+
|
|
459
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
460
|
+
|
|
461
|
+
| Param | Type | Description |
|
|
462
|
+
| --- | --- | --- |
|
|
463
|
+
| name | <code>string</code> | The attribute name |
|
|
464
|
+
|
|
465
|
+
<a name="Twig+root"></a>
|
|
466
|
+
|
|
467
|
+
### twig.root ⇒ [<code>Twig</code>](#Twig)
|
|
468
|
+
Returns the root object
|
|
469
|
+
|
|
470
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
471
|
+
**Returns**: [<code>Twig</code>](#Twig) - The root element of XML tree
|
|
472
|
+
<a name="Twig+parent"></a>
|
|
473
|
+
|
|
474
|
+
### twig.parent ⇒ [<code>Twig</code>](#Twig)
|
|
475
|
+
Returns the parent element or null if root element
|
|
476
|
+
|
|
477
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
478
|
+
**Returns**: [<code>Twig</code>](#Twig) - The parament element
|
|
479
|
+
<a name="Twig+self"></a>
|
|
480
|
+
|
|
481
|
+
### twig.self ⇒ [<code>Twig</code>](#Twig)
|
|
482
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
483
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The current element
|
|
484
|
+
<a name="Twig+children"></a>
|
|
485
|
+
|
|
486
|
+
### twig.children ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
487
|
+
All children, optionally matching `condition` of the current element or empty array
|
|
488
|
+
|
|
489
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
490
|
+
|
|
491
|
+
| Param | Type | Description |
|
|
492
|
+
| --- | --- | --- |
|
|
493
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
494
|
+
|
|
495
|
+
<a name="Twig+next"></a>
|
|
496
|
+
|
|
497
|
+
### twig.next ⇒ [<code>Twig</code>](#Twig)
|
|
498
|
+
Returns the next matching element.
|
|
499
|
+
|
|
500
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
501
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The next element
|
|
502
|
+
**See**: https://www.w3.org/TR/xpath-datamodel-31/#document-order
|
|
503
|
+
|
|
504
|
+
| Param | Type | Description |
|
|
505
|
+
| --- | --- | --- |
|
|
506
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
507
|
+
|
|
508
|
+
<a name="Twig+previous"></a>
|
|
509
|
+
|
|
510
|
+
### twig.previous ⇒ [<code>Twig</code>](#Twig)
|
|
511
|
+
Returns the previous matching element.
|
|
512
|
+
|
|
513
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
514
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The previous element
|
|
515
|
+
**See**: https://www.w3.org/TR/xpath-datamodel-31/#document-order
|
|
516
|
+
|
|
517
|
+
| Param | Type | Description |
|
|
518
|
+
| --- | --- | --- |
|
|
519
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
520
|
+
|
|
521
|
+
<a name="Twig+first"></a>
|
|
522
|
+
|
|
523
|
+
### twig.first ⇒ [<code>Twig</code>](#Twig)
|
|
524
|
+
Returns the first matching element. This is usually the root element
|
|
525
|
+
|
|
526
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
527
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The first element
|
|
528
|
+
|
|
529
|
+
| Param | Type | Description |
|
|
530
|
+
| --- | --- | --- |
|
|
531
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
532
|
+
|
|
533
|
+
<a name="Twig+last"></a>
|
|
534
|
+
|
|
535
|
+
### twig.last ⇒ [<code>Twig</code>](#Twig)
|
|
536
|
+
Returns the last matching element.
|
|
537
|
+
|
|
538
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
539
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The last element
|
|
540
|
+
|
|
541
|
+
| Param | Type | Description |
|
|
542
|
+
| --- | --- | --- |
|
|
543
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
544
|
+
|
|
545
|
+
<a name="Twig+isFirstChild"></a>
|
|
546
|
+
|
|
547
|
+
### twig.isFirstChild ⇒ <code>boolean</code>
|
|
548
|
+
Check if the element is the first child of the parent
|
|
549
|
+
|
|
550
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
551
|
+
**Returns**: <code>boolean</code> - `true` if the first child else `false`
|
|
552
|
+
<a name="Twig+isLastChild"></a>
|
|
553
|
+
|
|
554
|
+
### twig.isLastChild ⇒ <code>boolean</code>
|
|
555
|
+
Check if the element is the last child of the parent
|
|
556
|
+
|
|
557
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
558
|
+
**Returns**: <code>boolean</code> - `true` if the last child else `false`
|
|
559
|
+
<a name="Twig+descendant"></a>
|
|
560
|
+
|
|
561
|
+
### twig.descendant ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
562
|
+
Returns descendants (children, grandchildren, etc.) of the current element
|
|
563
|
+
|
|
564
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
565
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of descendants or empty array
|
|
566
|
+
|
|
567
|
+
| Param | Type | Description |
|
|
568
|
+
| --- | --- | --- |
|
|
569
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
570
|
+
|
|
571
|
+
<a name="Twig+descendantOrSelf"></a>
|
|
572
|
+
|
|
573
|
+
### twig.descendantOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
574
|
+
Returns descendants (children, grandchildren, etc.) of the current element and the current element itself
|
|
575
|
+
|
|
576
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
577
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of descendants or empty array
|
|
578
|
+
|
|
579
|
+
| Param | Type | Description |
|
|
580
|
+
| --- | --- | --- |
|
|
581
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
582
|
+
|
|
583
|
+
<a name="Twig+ancestor"></a>
|
|
584
|
+
|
|
585
|
+
### twig.ancestor ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
586
|
+
Returns ancestors (parent, grandparent, etc.) of the current element
|
|
587
|
+
|
|
588
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
589
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of ancestors or empty array
|
|
590
|
+
|
|
591
|
+
| Param | Type | Description |
|
|
592
|
+
| --- | --- | --- |
|
|
593
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
594
|
+
|
|
595
|
+
<a name="Twig+ancestorOrSelf"></a>
|
|
596
|
+
|
|
597
|
+
### twig.ancestorOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
598
|
+
Returns ancestors (parent, grandparent, etc.) of the current element and the current element itself
|
|
599
|
+
|
|
600
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
601
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of ancestors or empty array
|
|
602
|
+
|
|
603
|
+
| Param | Type | Description |
|
|
604
|
+
| --- | --- | --- |
|
|
605
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
606
|
+
|
|
607
|
+
<a name="Twig+sibling"></a>
|
|
608
|
+
|
|
609
|
+
### twig.sibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
610
|
+
Returns all sibling element of the current element
|
|
611
|
+
|
|
612
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
613
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
614
|
+
|
|
615
|
+
| Param | Type | Description |
|
|
616
|
+
| --- | --- | --- |
|
|
617
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
618
|
+
|
|
619
|
+
<a name="Twig+siblingOrSelf"></a>
|
|
620
|
+
|
|
621
|
+
### twig.siblingOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
622
|
+
Returns all sibling element of the current element and the current element itself
|
|
623
|
+
|
|
624
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
625
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
626
|
+
|
|
627
|
+
| Param | Type | Description |
|
|
628
|
+
| --- | --- | --- |
|
|
629
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
630
|
+
|
|
631
|
+
<a name="Twig+followingSibling"></a>
|
|
632
|
+
|
|
633
|
+
### twig.followingSibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
634
|
+
Returns all following sibling element of the current element
|
|
635
|
+
|
|
636
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
637
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
638
|
+
|
|
639
|
+
| Param | Type | Description |
|
|
640
|
+
| --- | --- | --- |
|
|
641
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
642
|
+
|
|
643
|
+
<a name="Twig+precedingSibling"></a>
|
|
644
|
+
|
|
645
|
+
### twig.precedingSibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
646
|
+
Returns all preceding sibling element of the current element
|
|
647
|
+
|
|
648
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
649
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
650
|
+
|
|
651
|
+
| Param | Type | Description |
|
|
652
|
+
| --- | --- | --- |
|
|
653
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
654
|
+
|
|
655
|
+
<a name="Twig+nextSibling"></a>
|
|
656
|
+
|
|
657
|
+
### twig.nextSibling ⇒ [<code>Twig</code>](#Twig)
|
|
658
|
+
Returns next sibling element of the current element
|
|
659
|
+
|
|
660
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
661
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The next sibling or `null`
|
|
662
|
+
|
|
663
|
+
| Param | Type | Description |
|
|
664
|
+
| --- | --- | --- |
|
|
665
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
666
|
+
|
|
667
|
+
<a name="Twig+prevSibling"></a>
|
|
668
|
+
|
|
669
|
+
### twig.prevSibling ⇒ [<code>Twig</code>](#Twig)
|
|
670
|
+
Returns previous sibling element of the current element
|
|
671
|
+
|
|
672
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
673
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The previous sibling or `null`
|
|
674
|
+
|
|
675
|
+
| Param | Type | Description |
|
|
676
|
+
| --- | --- | --- |
|
|
677
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
678
|
+
|
|
679
|
+
<a name="Twig+find"></a>
|
|
680
|
+
|
|
681
|
+
### twig.find ⇒ [<code>Twig</code>](#Twig)
|
|
682
|
+
Find a specific element within current element. Same as `.descendant(condition)[0]`
|
|
683
|
+
|
|
684
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
685
|
+
**Returns**: [<code>Twig</code>](#Twig) - - First matching element or `null`
|
|
686
|
+
|
|
687
|
+
| Param | Type | Description |
|
|
688
|
+
| --- | --- | --- |
|
|
689
|
+
| condition | [<code>ElementCondition</code>](#ElementCondition) | Find condition |
|
|
690
|
+
|
|
691
|
+
<a name="Twig+addElement"></a>
|
|
692
|
+
|
|
693
|
+
### twig.addElement ⇒ [<code>Twig</code>](#Twig)
|
|
694
|
+
Add a new element in the current element
|
|
695
|
+
|
|
696
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
697
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The appended element
|
|
698
|
+
|
|
699
|
+
| Param | Type | Description |
|
|
700
|
+
| --- | --- | --- |
|
|
701
|
+
| name | <code>string</code> | The tag name |
|
|
702
|
+
| [text] | <code>string</code> | Text of the element |
|
|
703
|
+
| [attributes] | <code>object</code> | Element attributes |
|
|
704
|
+
| [position] | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
|
|
705
|
+
|
|
706
|
+
<a name="Twig+delete"></a>
|
|
707
|
+
|
|
708
|
+
### twig.delete
|
|
709
|
+
Deletes the current element from tree, same as `purge()`. The root object cannot be deleted.
|
|
710
|
+
|
|
711
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
712
|
+
<a name="Twig+setRoot"></a>
|
|
713
|
+
|
|
714
|
+
### twig.setRoot(name) ℗
|
|
715
|
+
Sets the name of root element. In some cases the root is created before the XML-Root element is available<br>
|
|
716
|
+
|
|
717
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
718
|
+
**Access**: private
|
|
719
|
+
|
|
720
|
+
| Param | Type | Description |
|
|
721
|
+
| --- | --- | --- |
|
|
722
|
+
| name | <code>string</code> | The element name |
|
|
723
|
+
|
|
724
|
+
<a name="Twig+filterElements"></a>
|
|
725
|
+
|
|
726
|
+
### twig.filterElements(elements, [condition]) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
727
|
+
Common function to filter Twig elements from array
|
|
728
|
+
|
|
729
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
730
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - List of matching elements or empty array
|
|
731
|
+
|
|
732
|
+
| Param | Type | Description |
|
|
733
|
+
| --- | --- | --- |
|
|
734
|
+
| elements | [<code>Twig</code>](#Twig) \| [<code>Array.<Twig></code>](#Twig) | Array of elements you like to filter or a single element |
|
|
735
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
|
|
736
|
+
|
|
737
|
+
<a name="Twig+testElement"></a>
|
|
738
|
+
|
|
739
|
+
### twig.testElement(element, [condition]) ⇒ <code>boolean</code>
|
|
740
|
+
Common function to filter Twig element
|
|
741
|
+
|
|
742
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
743
|
+
**Returns**: <code>boolean</code> - `true` if the condition matches
|
|
744
|
+
|
|
745
|
+
| Param | Type | Description |
|
|
746
|
+
| --- | --- | --- |
|
|
747
|
+
| element | [<code>Twig</code>](#Twig) | Element you like to filter |
|
|
748
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
|
|
749
|
+
|
|
750
|
+
<a name="Twig"></a>
|
|
751
|
+
|
|
752
|
+
## Twig
|
|
753
|
+
**Kind**: global class
|
|
754
|
+
|
|
755
|
+
* [Twig](#Twig)
|
|
756
|
+
* [new Twig()](#new_Twig_new)
|
|
757
|
+
* [new Twig(parser, name, [parent], [attributes], [index])](#new_Twig_new)
|
|
758
|
+
* [.attributes](#Twig+attributes) : <code>object</code> ℗
|
|
759
|
+
* [.text](#Twig+text) : <code>string</code> \| <code>number</code> ℗
|
|
760
|
+
* [.name](#Twig+name) : <code>string</code> ℗
|
|
761
|
+
* [.children](#Twig+children) : [<code>Array.<Twig></code>](#Twig) ℗
|
|
762
|
+
* [.parent](#Twig+parent) : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
763
|
+
* [.pinned](#Twig+pinned) : <code>boolean</code> ℗
|
|
764
|
+
* [.purge](#Twig+purge)
|
|
765
|
+
* [.purgeUpTo](#Twig+purgeUpTo)
|
|
766
|
+
* [.escapeEntity](#Twig+escapeEntity)
|
|
767
|
+
* [.isEmpty](#Twig+isEmpty) ⇒ <code>boolean</code>
|
|
768
|
+
* [.level](#Twig+level) ⇒ <code>number</code>
|
|
769
|
+
* [.isRoot](#Twig+isRoot) ⇒ <code>boolean</code>
|
|
770
|
+
* [.hasChildren](#Twig+hasChildren) ⇒ <code>boolean</code>
|
|
771
|
+
* [.index](#Twig+index) ⇒ <code>number</code>
|
|
772
|
+
* [.path](#Twig+path) ⇒ <code>string</code>
|
|
773
|
+
* [.name](#Twig+name) ⇒ <code>string</code>
|
|
774
|
+
* [.tag](#Twig+tag) ⇒ <code>string</code>
|
|
775
|
+
* [.text](#Twig+text) ⇒ <code>string</code>
|
|
776
|
+
* [.text](#Twig+text)
|
|
777
|
+
* [.pin](#Twig+pin)
|
|
778
|
+
* [.pinned](#Twig+pinned) ⇒ <code>boolean</code>
|
|
779
|
+
* [.close](#Twig+close)
|
|
780
|
+
* [.debug](#Twig+debug) ⇒ <code>string</code>
|
|
781
|
+
* [.toString](#Twig+toString) ⇒ <code>string</code>
|
|
782
|
+
* [.addChild](#Twig+addChild) ℗
|
|
783
|
+
* [.writer](#Twig+writer) ⇒ [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer)
|
|
784
|
+
* [.attr](#Twig+attr) ⇒ <code>string</code> \| <code>number</code> \| <code>object</code>
|
|
785
|
+
* [.attributes](#Twig+attributes) ⇒ <code>object</code>
|
|
786
|
+
* [.hasAttribute](#Twig+hasAttribute) ⇒ <code>boolean</code>
|
|
787
|
+
* [.attribute](#Twig+attribute) ⇒ <code>object</code>
|
|
788
|
+
* [.deleteAttribute](#Twig+deleteAttribute)
|
|
789
|
+
* [.root](#Twig+root) ⇒ [<code>Twig</code>](#Twig)
|
|
790
|
+
* [.parent](#Twig+parent) ⇒ [<code>Twig</code>](#Twig)
|
|
791
|
+
* [.self](#Twig+self) ⇒ [<code>Twig</code>](#Twig)
|
|
792
|
+
* [.children](#Twig+children) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
793
|
+
* [.next](#Twig+next) ⇒ [<code>Twig</code>](#Twig)
|
|
794
|
+
* [.previous](#Twig+previous) ⇒ [<code>Twig</code>](#Twig)
|
|
795
|
+
* [.first](#Twig+first) ⇒ [<code>Twig</code>](#Twig)
|
|
796
|
+
* [.last](#Twig+last) ⇒ [<code>Twig</code>](#Twig)
|
|
797
|
+
* [.isFirstChild](#Twig+isFirstChild) ⇒ <code>boolean</code>
|
|
798
|
+
* [.isLastChild](#Twig+isLastChild) ⇒ <code>boolean</code>
|
|
799
|
+
* [.descendant](#Twig+descendant) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
800
|
+
* [.descendantOrSelf](#Twig+descendantOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
801
|
+
* [.ancestor](#Twig+ancestor) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
802
|
+
* [.ancestorOrSelf](#Twig+ancestorOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
803
|
+
* [.sibling](#Twig+sibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
804
|
+
* [.siblingOrSelf](#Twig+siblingOrSelf) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
805
|
+
* [.followingSibling](#Twig+followingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
806
|
+
* [.precedingSibling](#Twig+precedingSibling) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
807
|
+
* [.nextSibling](#Twig+nextSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
808
|
+
* [.prevSibling](#Twig+prevSibling) ⇒ [<code>Twig</code>](#Twig)
|
|
809
|
+
* [.find](#Twig+find) ⇒ [<code>Twig</code>](#Twig)
|
|
810
|
+
* [.addElement](#Twig+addElement) ⇒ [<code>Twig</code>](#Twig)
|
|
811
|
+
* [.delete](#Twig+delete)
|
|
812
|
+
* [.setRoot(name)](#Twig+setRoot) ℗
|
|
813
|
+
* [.filterElements(elements, [condition])](#Twig+filterElements) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
814
|
+
* [.testElement(element, [condition])](#Twig+testElement) ⇒ <code>boolean</code>
|
|
815
|
+
|
|
816
|
+
<a name="new_Twig_new"></a>
|
|
817
|
+
|
|
818
|
+
### new Twig()
|
|
819
|
+
Generic class modeling a XML Node
|
|
820
|
+
|
|
821
|
+
<a name="new_Twig_new"></a>
|
|
822
|
+
|
|
823
|
+
### new Twig(parser, name, [parent], [attributes], [index])
|
|
824
|
+
Create a new Twig object
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
| Param | Type | Description |
|
|
828
|
+
| --- | --- | --- |
|
|
829
|
+
| parser | [<code>Parser</code>](#Parser) | The main parser object |
|
|
830
|
+
| name | <code>string</code> | The name of the XML element |
|
|
831
|
+
| [parent] | [<code>Twig</code>](#Twig) | The parent object |
|
|
832
|
+
| [attributes] | <code>object</code> | Attribute object |
|
|
833
|
+
| [index] | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
|
|
834
|
+
|
|
835
|
+
<a name="Twig+attributes"></a>
|
|
836
|
+
|
|
837
|
+
### twig.attributes : <code>object</code> ℗
|
|
838
|
+
XML attribute `{ <attribute 1>: <value 1>, <attribute 2>: <value 2>, ... }`
|
|
839
|
+
|
|
840
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
841
|
+
**Access**: private
|
|
842
|
+
<a name="Twig+text"></a>
|
|
843
|
+
|
|
844
|
+
### twig.text : <code>string</code> \| <code>number</code> ℗
|
|
845
|
+
Content of XML Element
|
|
846
|
+
|
|
847
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
848
|
+
**Access**: private
|
|
849
|
+
<a name="Twig+name"></a>
|
|
850
|
+
|
|
851
|
+
### twig.name : <code>string</code> ℗
|
|
852
|
+
The XML tag name
|
|
853
|
+
|
|
854
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
855
|
+
**Access**: private
|
|
856
|
+
<a name="Twig+children"></a>
|
|
857
|
+
|
|
858
|
+
### twig.children : [<code>Array.<Twig></code>](#Twig) ℗
|
|
859
|
+
Child XML Elements
|
|
860
|
+
|
|
861
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
862
|
+
**Access**: private
|
|
863
|
+
<a name="Twig+parent"></a>
|
|
864
|
+
|
|
865
|
+
### twig.parent : [<code>Twig</code>](#Twig) \| <code>undefined</code> ℗
|
|
866
|
+
The parent object. Undefined on root element
|
|
867
|
+
|
|
868
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
869
|
+
**Access**: private
|
|
870
|
+
<a name="Twig+pinned"></a>
|
|
871
|
+
|
|
872
|
+
### twig.pinned : <code>boolean</code> ℗
|
|
873
|
+
Determines whether twig is needed in partial load
|
|
874
|
+
|
|
875
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
876
|
+
**Access**: private
|
|
877
|
+
<a name="Twig+purge"></a>
|
|
878
|
+
|
|
879
|
+
### twig.purge
|
|
880
|
+
Purges the current, typically used after element has been processed.<br>The root object cannot be purged.
|
|
881
|
+
|
|
882
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
883
|
+
<a name="Twig+purgeUpTo"></a>
|
|
884
|
+
|
|
885
|
+
### twig.purgeUpTo
|
|
886
|
+
Purges up to the elt element. This allows you to keep part of the tree in memory when you purge.<br>
|
|
887
|
+
|
|
888
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
889
|
+
|
|
890
|
+
| Param | Type | Description |
|
|
891
|
+
| --- | --- | --- |
|
|
892
|
+
| [elt] | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
|
|
893
|
+
|
|
894
|
+
<a name="Twig+escapeEntity"></a>
|
|
895
|
+
|
|
896
|
+
### twig.escapeEntity
|
|
897
|
+
Escapes special XML characters. According W3C specification these are only `&, <, >, ", '` - this is a XML parser, not HTML!
|
|
898
|
+
|
|
899
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
900
|
+
|
|
901
|
+
| Param | Type | Description |
|
|
902
|
+
| --- | --- | --- |
|
|
903
|
+
| text | <code>string</code> | Input text to be escaped |
|
|
904
|
+
|
|
905
|
+
<a name="Twig+isEmpty"></a>
|
|
906
|
+
|
|
907
|
+
### twig.isEmpty ⇒ <code>boolean</code>
|
|
908
|
+
Returns `true` if the element is empty, otherwise `false`.
|
|
909
|
+
|
|
910
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
911
|
+
**Returns**: <code>boolean</code> - true if empty element
|
|
912
|
+
<a name="Twig+level"></a>
|
|
913
|
+
|
|
914
|
+
### twig.level ⇒ <code>number</code>
|
|
915
|
+
Returns the level of the element. Root element has 0, children have 1, grand-children 2 and so on
|
|
916
|
+
|
|
917
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
918
|
+
**Returns**: <code>number</code> - The level of the element.
|
|
919
|
+
<a name="Twig+isRoot"></a>
|
|
920
|
+
|
|
921
|
+
### twig.isRoot ⇒ <code>boolean</code>
|
|
922
|
+
Returns `true` if element is the root object
|
|
923
|
+
|
|
924
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
925
|
+
**Returns**: <code>boolean</code> - true if root element
|
|
926
|
+
<a name="Twig+hasChildren"></a>
|
|
927
|
+
|
|
928
|
+
### twig.hasChildren ⇒ <code>boolean</code>
|
|
929
|
+
Returns `true` if element has child elements
|
|
930
|
+
|
|
931
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
932
|
+
**Returns**: <code>boolean</code> - true if has child elements exists
|
|
933
|
+
<a name="Twig+index"></a>
|
|
934
|
+
|
|
935
|
+
### twig.index ⇒ <code>number</code>
|
|
936
|
+
The position in `#children` array. For root object 0
|
|
937
|
+
|
|
938
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
939
|
+
**Returns**: <code>number</code> - Position of element in parent
|
|
940
|
+
<a name="Twig+path"></a>
|
|
941
|
+
|
|
942
|
+
### twig.path ⇒ <code>string</code>
|
|
943
|
+
The X-Path position of the element
|
|
944
|
+
|
|
945
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
946
|
+
**Returns**: <code>string</code> - X-Path
|
|
947
|
+
<a name="Twig+name"></a>
|
|
948
|
+
|
|
949
|
+
### twig.name ⇒ <code>string</code>
|
|
950
|
+
Returns the name of the element.
|
|
951
|
+
|
|
952
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
953
|
+
**Returns**: <code>string</code> - Element name
|
|
954
|
+
<a name="Twig+tag"></a>
|
|
955
|
+
|
|
956
|
+
### twig.tag ⇒ <code>string</code>
|
|
957
|
+
Returns the name of the element. Synonym for `twig.name`
|
|
958
|
+
|
|
959
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
960
|
+
**Returns**: <code>string</code> - Element name
|
|
961
|
+
<a name="Twig+text"></a>
|
|
962
|
+
|
|
963
|
+
### twig.text ⇒ <code>string</code>
|
|
964
|
+
The text of the element. No matter if given as text or CDATA entity
|
|
965
|
+
|
|
966
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
967
|
+
**Returns**: <code>string</code> - Element text or empty string
|
|
968
|
+
<a name="Twig+text"></a>
|
|
969
|
+
|
|
970
|
+
### twig.text
|
|
971
|
+
Update the text of the element
|
|
972
|
+
|
|
973
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
974
|
+
**Throws**:
|
|
975
|
+
|
|
976
|
+
- [<code>UnsupportedType</code>](#UnsupportedType) - If value is not a string, boolean or numeric type
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
| Param | Type | Description |
|
|
980
|
+
| --- | --- | --- |
|
|
981
|
+
| value | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New text of the element |
|
|
982
|
+
|
|
983
|
+
<a name="Twig+pin"></a>
|
|
984
|
+
|
|
985
|
+
### twig.pin
|
|
986
|
+
Pins the current element. Used for partial reading.
|
|
987
|
+
|
|
988
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
989
|
+
<a name="Twig+pinned"></a>
|
|
990
|
+
|
|
991
|
+
### twig.pinned ⇒ <code>boolean</code>
|
|
992
|
+
Checks if element is pinned
|
|
993
|
+
|
|
994
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
995
|
+
**Returns**: <code>boolean</code> - `true` when the element is pinned
|
|
996
|
+
<a name="Twig+close"></a>
|
|
997
|
+
|
|
998
|
+
### twig.close
|
|
999
|
+
Closes the element
|
|
1000
|
+
|
|
1001
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1002
|
+
<a name="Twig+debug"></a>
|
|
1003
|
+
|
|
1004
|
+
### twig.debug ⇒ <code>string</code>
|
|
1005
|
+
XML-Twig for dummies :-)
|
|
1006
|
+
|
|
1007
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1008
|
+
**Returns**: <code>string</code> - The XML-Tree which is currently available in RAM - no valid XML Structure
|
|
1009
|
+
<a name="Twig+toString"></a>
|
|
1010
|
+
|
|
1011
|
+
### twig.toString ⇒ <code>string</code>
|
|
1012
|
+
Returns XML string of the element
|
|
1013
|
+
|
|
1014
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1015
|
+
**Returns**: <code>string</code> - The XML-Element as string
|
|
1016
|
+
<a name="Twig+addChild"></a>
|
|
1017
|
+
|
|
1018
|
+
### twig.addChild ℗
|
|
1019
|
+
Internal recursive function used by `writer()`
|
|
1020
|
+
|
|
1021
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1022
|
+
**Access**: private
|
|
1023
|
+
|
|
1024
|
+
| Param | Type | Description |
|
|
1025
|
+
| --- | --- | --- |
|
|
1026
|
+
| xw | [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer) | The writer object |
|
|
1027
|
+
| childArray | [<code>Array.<Twig></code>](#Twig) | Array of child elements |
|
|
1028
|
+
|
|
1029
|
+
<a name="Twig+writer"></a>
|
|
1030
|
+
|
|
1031
|
+
### twig.writer ⇒ [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer)
|
|
1032
|
+
Creates xml-writer from current element
|
|
1033
|
+
|
|
1034
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1035
|
+
|
|
1036
|
+
| Param | Type | Description |
|
|
1037
|
+
| --- | --- | --- |
|
|
1038
|
+
| par | <code>boolean</code> \| <code>string</code> \| [<code>XMLWriter</code>](https://www.npmjs.com/package/xml-writer) | `true` or intention character or an already created XMLWriter |
|
|
1039
|
+
|
|
1040
|
+
<a name="Twig+attr"></a>
|
|
1041
|
+
|
|
1042
|
+
### twig.attr ⇒ <code>string</code> \| <code>number</code> \| <code>object</code>
|
|
1043
|
+
Returns attribute value or `null` if not found.<br>
|
|
1044
|
+
|
|
1045
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1046
|
+
**Returns**: <code>string</code> \| <code>number</code> \| <code>object</code> - - The value of the attribute or `null` if the does not exist
|
|
1047
|
+
|
|
1048
|
+
| Param | Type | Description |
|
|
1049
|
+
| --- | --- | --- |
|
|
1050
|
+
| [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
|
|
1051
|
+
|
|
1052
|
+
<a name="Twig+attributes"></a>
|
|
1053
|
+
|
|
1054
|
+
### twig.attributes ⇒ <code>object</code>
|
|
1055
|
+
Returns all attributes of the element
|
|
1056
|
+
|
|
1057
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1058
|
+
**Returns**: <code>object</code> - All XML Attributes
|
|
1059
|
+
<a name="Twig+hasAttribute"></a>
|
|
1060
|
+
|
|
1061
|
+
### twig.hasAttribute ⇒ <code>boolean</code>
|
|
1062
|
+
Check if the attribute exist or not
|
|
1063
|
+
|
|
1064
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1065
|
+
**Returns**: <code>boolean</code> - - Returns `true` if the attribute exists, else `false`
|
|
1066
|
+
|
|
1067
|
+
| Param | Type | Description |
|
|
1068
|
+
| --- | --- | --- |
|
|
1069
|
+
| name | <code>string</code> | The name of the attribute |
|
|
1070
|
+
|
|
1071
|
+
<a name="Twig+attribute"></a>
|
|
1072
|
+
|
|
1073
|
+
### twig.attribute ⇒ <code>object</code>
|
|
1074
|
+
Retrieve or update XML attribute. For update, the condition must be a string, i.e. must match to one attribute only.
|
|
1075
|
+
|
|
1076
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1077
|
+
**Returns**: <code>object</code> - Attributes or `null` if no matching attribute found
|
|
1078
|
+
|
|
1079
|
+
| Param | Type | Description |
|
|
1080
|
+
| --- | --- | --- |
|
|
1081
|
+
| [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
|
|
1082
|
+
| [value] | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
|
|
1083
|
+
|
|
1084
|
+
**Example**
|
|
1085
|
+
```js
|
|
1086
|
+
attribute((name, val) => { return name === 'age' && val > 50})
|
|
1087
|
+
```
|
|
1088
|
+
<a name="Twig+deleteAttribute"></a>
|
|
1089
|
+
|
|
1090
|
+
### twig.deleteAttribute
|
|
1091
|
+
Delete the attribute
|
|
1092
|
+
|
|
1093
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1094
|
+
|
|
1095
|
+
| Param | Type | Description |
|
|
1096
|
+
| --- | --- | --- |
|
|
1097
|
+
| name | <code>string</code> | The attribute name |
|
|
1098
|
+
|
|
1099
|
+
<a name="Twig+root"></a>
|
|
1100
|
+
|
|
1101
|
+
### twig.root ⇒ [<code>Twig</code>](#Twig)
|
|
1102
|
+
Returns the root object
|
|
1103
|
+
|
|
1104
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1105
|
+
**Returns**: [<code>Twig</code>](#Twig) - The root element of XML tree
|
|
1106
|
+
<a name="Twig+parent"></a>
|
|
1107
|
+
|
|
1108
|
+
### twig.parent ⇒ [<code>Twig</code>](#Twig)
|
|
1109
|
+
Returns the parent element or null if root element
|
|
1110
|
+
|
|
1111
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1112
|
+
**Returns**: [<code>Twig</code>](#Twig) - The parament element
|
|
1113
|
+
<a name="Twig+self"></a>
|
|
1114
|
+
|
|
1115
|
+
### twig.self ⇒ [<code>Twig</code>](#Twig)
|
|
1116
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1117
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The current element
|
|
1118
|
+
<a name="Twig+children"></a>
|
|
1119
|
+
|
|
1120
|
+
### twig.children ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1121
|
+
All children, optionally matching `condition` of the current element or empty array
|
|
1122
|
+
|
|
1123
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1124
|
+
|
|
1125
|
+
| Param | Type | Description |
|
|
1126
|
+
| --- | --- | --- |
|
|
1127
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1128
|
+
|
|
1129
|
+
<a name="Twig+next"></a>
|
|
1130
|
+
|
|
1131
|
+
### twig.next ⇒ [<code>Twig</code>](#Twig)
|
|
1132
|
+
Returns the next matching element.
|
|
1133
|
+
|
|
1134
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1135
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The next element
|
|
1136
|
+
**See**: https://www.w3.org/TR/xpath-datamodel-31/#document-order
|
|
1137
|
+
|
|
1138
|
+
| Param | Type | Description |
|
|
1139
|
+
| --- | --- | --- |
|
|
1140
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1141
|
+
|
|
1142
|
+
<a name="Twig+previous"></a>
|
|
1143
|
+
|
|
1144
|
+
### twig.previous ⇒ [<code>Twig</code>](#Twig)
|
|
1145
|
+
Returns the previous matching element.
|
|
1146
|
+
|
|
1147
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1148
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The previous element
|
|
1149
|
+
**See**: https://www.w3.org/TR/xpath-datamodel-31/#document-order
|
|
1150
|
+
|
|
1151
|
+
| Param | Type | Description |
|
|
1152
|
+
| --- | --- | --- |
|
|
1153
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1154
|
+
|
|
1155
|
+
<a name="Twig+first"></a>
|
|
1156
|
+
|
|
1157
|
+
### twig.first ⇒ [<code>Twig</code>](#Twig)
|
|
1158
|
+
Returns the first matching element. This is usually the root element
|
|
1159
|
+
|
|
1160
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1161
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The first element
|
|
1162
|
+
|
|
1163
|
+
| Param | Type | Description |
|
|
1164
|
+
| --- | --- | --- |
|
|
1165
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1166
|
+
|
|
1167
|
+
<a name="Twig+last"></a>
|
|
1168
|
+
|
|
1169
|
+
### twig.last ⇒ [<code>Twig</code>](#Twig)
|
|
1170
|
+
Returns the last matching element.
|
|
1171
|
+
|
|
1172
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1173
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The last element
|
|
1174
|
+
|
|
1175
|
+
| Param | Type | Description |
|
|
1176
|
+
| --- | --- | --- |
|
|
1177
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1178
|
+
|
|
1179
|
+
<a name="Twig+isFirstChild"></a>
|
|
1180
|
+
|
|
1181
|
+
### twig.isFirstChild ⇒ <code>boolean</code>
|
|
1182
|
+
Check if the element is the first child of the parent
|
|
1183
|
+
|
|
1184
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1185
|
+
**Returns**: <code>boolean</code> - `true` if the first child else `false`
|
|
1186
|
+
<a name="Twig+isLastChild"></a>
|
|
1187
|
+
|
|
1188
|
+
### twig.isLastChild ⇒ <code>boolean</code>
|
|
1189
|
+
Check if the element is the last child of the parent
|
|
1190
|
+
|
|
1191
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1192
|
+
**Returns**: <code>boolean</code> - `true` if the last child else `false`
|
|
1193
|
+
<a name="Twig+descendant"></a>
|
|
1194
|
+
|
|
1195
|
+
### twig.descendant ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1196
|
+
Returns descendants (children, grandchildren, etc.) of the current element
|
|
1197
|
+
|
|
1198
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1199
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of descendants or empty array
|
|
1200
|
+
|
|
1201
|
+
| Param | Type | Description |
|
|
1202
|
+
| --- | --- | --- |
|
|
1203
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1204
|
+
|
|
1205
|
+
<a name="Twig+descendantOrSelf"></a>
|
|
1206
|
+
|
|
1207
|
+
### twig.descendantOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1208
|
+
Returns descendants (children, grandchildren, etc.) of the current element and the current element itself
|
|
1209
|
+
|
|
1210
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1211
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of descendants or empty array
|
|
1212
|
+
|
|
1213
|
+
| Param | Type | Description |
|
|
1214
|
+
| --- | --- | --- |
|
|
1215
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1216
|
+
|
|
1217
|
+
<a name="Twig+ancestor"></a>
|
|
1218
|
+
|
|
1219
|
+
### twig.ancestor ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1220
|
+
Returns ancestors (parent, grandparent, etc.) of the current element
|
|
1221
|
+
|
|
1222
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1223
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of ancestors or empty array
|
|
1224
|
+
|
|
1225
|
+
| Param | Type | Description |
|
|
1226
|
+
| --- | --- | --- |
|
|
1227
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1228
|
+
|
|
1229
|
+
<a name="Twig+ancestorOrSelf"></a>
|
|
1230
|
+
|
|
1231
|
+
### twig.ancestorOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1232
|
+
Returns ancestors (parent, grandparent, etc.) of the current element and the current element itself
|
|
1233
|
+
|
|
1234
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1235
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of ancestors or empty array
|
|
1236
|
+
|
|
1237
|
+
| Param | Type | Description |
|
|
1238
|
+
| --- | --- | --- |
|
|
1239
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1240
|
+
|
|
1241
|
+
<a name="Twig+sibling"></a>
|
|
1242
|
+
|
|
1243
|
+
### twig.sibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1244
|
+
Returns all sibling element of the current element
|
|
1245
|
+
|
|
1246
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1247
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
1248
|
+
|
|
1249
|
+
| Param | Type | Description |
|
|
1250
|
+
| --- | --- | --- |
|
|
1251
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1252
|
+
|
|
1253
|
+
<a name="Twig+siblingOrSelf"></a>
|
|
1254
|
+
|
|
1255
|
+
### twig.siblingOrSelf ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1256
|
+
Returns all sibling element of the current element and the current element itself
|
|
1257
|
+
|
|
1258
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1259
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
1260
|
+
|
|
1261
|
+
| Param | Type | Description |
|
|
1262
|
+
| --- | --- | --- |
|
|
1263
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1264
|
+
|
|
1265
|
+
<a name="Twig+followingSibling"></a>
|
|
1266
|
+
|
|
1267
|
+
### twig.followingSibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1268
|
+
Returns all following sibling element of the current element
|
|
1269
|
+
|
|
1270
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1271
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
1272
|
+
|
|
1273
|
+
| Param | Type | Description |
|
|
1274
|
+
| --- | --- | --- |
|
|
1275
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1276
|
+
|
|
1277
|
+
<a name="Twig+precedingSibling"></a>
|
|
1278
|
+
|
|
1279
|
+
### twig.precedingSibling ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1280
|
+
Returns all preceding sibling element of the current element
|
|
1281
|
+
|
|
1282
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1283
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - - Array of sibling or empty array
|
|
1284
|
+
|
|
1285
|
+
| Param | Type | Description |
|
|
1286
|
+
| --- | --- | --- |
|
|
1287
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1288
|
+
|
|
1289
|
+
<a name="Twig+nextSibling"></a>
|
|
1290
|
+
|
|
1291
|
+
### twig.nextSibling ⇒ [<code>Twig</code>](#Twig)
|
|
1292
|
+
Returns next sibling element of the current element
|
|
1293
|
+
|
|
1294
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1295
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The next sibling or `null`
|
|
1296
|
+
|
|
1297
|
+
| Param | Type | Description |
|
|
1298
|
+
| --- | --- | --- |
|
|
1299
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1300
|
+
|
|
1301
|
+
<a name="Twig+prevSibling"></a>
|
|
1302
|
+
|
|
1303
|
+
### twig.prevSibling ⇒ [<code>Twig</code>](#Twig)
|
|
1304
|
+
Returns previous sibling element of the current element
|
|
1305
|
+
|
|
1306
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1307
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The previous sibling or `null`
|
|
1308
|
+
|
|
1309
|
+
| Param | Type | Description |
|
|
1310
|
+
| --- | --- | --- |
|
|
1311
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
|
|
1312
|
+
|
|
1313
|
+
<a name="Twig+find"></a>
|
|
1314
|
+
|
|
1315
|
+
### twig.find ⇒ [<code>Twig</code>](#Twig)
|
|
1316
|
+
Find a specific element within current element. Same as `.descendant(condition)[0]`
|
|
1317
|
+
|
|
1318
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1319
|
+
**Returns**: [<code>Twig</code>](#Twig) - - First matching element or `null`
|
|
1320
|
+
|
|
1321
|
+
| Param | Type | Description |
|
|
1322
|
+
| --- | --- | --- |
|
|
1323
|
+
| condition | [<code>ElementCondition</code>](#ElementCondition) | Find condition |
|
|
1324
|
+
|
|
1325
|
+
<a name="Twig+addElement"></a>
|
|
1326
|
+
|
|
1327
|
+
### twig.addElement ⇒ [<code>Twig</code>](#Twig)
|
|
1328
|
+
Add a new element in the current element
|
|
1329
|
+
|
|
1330
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1331
|
+
**Returns**: [<code>Twig</code>](#Twig) - - The appended element
|
|
1332
|
+
|
|
1333
|
+
| Param | Type | Description |
|
|
1334
|
+
| --- | --- | --- |
|
|
1335
|
+
| name | <code>string</code> | The tag name |
|
|
1336
|
+
| [text] | <code>string</code> | Text of the element |
|
|
1337
|
+
| [attributes] | <code>object</code> | Element attributes |
|
|
1338
|
+
| [position] | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
|
|
1339
|
+
|
|
1340
|
+
<a name="Twig+delete"></a>
|
|
1341
|
+
|
|
1342
|
+
### twig.delete
|
|
1343
|
+
Deletes the current element from tree, same as `purge()`. The root object cannot be deleted.
|
|
1344
|
+
|
|
1345
|
+
**Kind**: instance property of [<code>Twig</code>](#Twig)
|
|
1346
|
+
<a name="Twig+setRoot"></a>
|
|
1347
|
+
|
|
1348
|
+
### twig.setRoot(name) ℗
|
|
1349
|
+
Sets the name of root element. In some cases the root is created before the XML-Root element is available<br>
|
|
1350
|
+
|
|
1351
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
1352
|
+
**Access**: private
|
|
1353
|
+
|
|
1354
|
+
| Param | Type | Description |
|
|
1355
|
+
| --- | --- | --- |
|
|
1356
|
+
| name | <code>string</code> | The element name |
|
|
1357
|
+
|
|
1358
|
+
<a name="Twig+filterElements"></a>
|
|
1359
|
+
|
|
1360
|
+
### twig.filterElements(elements, [condition]) ⇒ [<code>Array.<Twig></code>](#Twig)
|
|
1361
|
+
Common function to filter Twig elements from array
|
|
1362
|
+
|
|
1363
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
1364
|
+
**Returns**: [<code>Array.<Twig></code>](#Twig) - List of matching elements or empty array
|
|
1365
|
+
|
|
1366
|
+
| Param | Type | Description |
|
|
1367
|
+
| --- | --- | --- |
|
|
1368
|
+
| elements | [<code>Twig</code>](#Twig) \| [<code>Array.<Twig></code>](#Twig) | Array of elements you like to filter or a single element |
|
|
1369
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
|
|
1370
|
+
|
|
1371
|
+
<a name="Twig+testElement"></a>
|
|
1372
|
+
|
|
1373
|
+
### twig.testElement(element, [condition]) ⇒ <code>boolean</code>
|
|
1374
|
+
Common function to filter Twig element
|
|
1375
|
+
|
|
1376
|
+
**Kind**: instance method of [<code>Twig</code>](#Twig)
|
|
1377
|
+
**Returns**: <code>boolean</code> - `true` if the condition matches
|
|
1378
|
+
|
|
1379
|
+
| Param | Type | Description |
|
|
1380
|
+
| --- | --- | --- |
|
|
1381
|
+
| element | [<code>Twig</code>](#Twig) | Element you like to filter |
|
|
1382
|
+
| [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
|
|
1383
|
+
|
|
1384
|
+
<a name="NotImplementedYet"></a>
|
|
1385
|
+
|
|
1386
|
+
## NotImplementedYet
|
|
1387
|
+
Generic error for non implemented feature
|
|
1388
|
+
|
|
1389
|
+
**Kind**: global class
|
|
1390
|
+
<a name="UnsupportedParser"></a>
|
|
1391
|
+
|
|
1392
|
+
## UnsupportedParser
|
|
1393
|
+
Error for unsupported parser
|
|
1394
|
+
|
|
1395
|
+
**Kind**: global class
|
|
1396
|
+
<a name="new_UnsupportedParser_new"></a>
|
|
1397
|
+
|
|
1398
|
+
### new UnsupportedParser(t)
|
|
1399
|
+
**Throws**:
|
|
1400
|
+
|
|
1401
|
+
- UnsupportedParser
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
| Param | Type | Description |
|
|
1405
|
+
| --- | --- | --- |
|
|
1406
|
+
| t | <code>string</code> | Parser type |
|
|
1407
|
+
|
|
1408
|
+
<a name="UnsupportedType"></a>
|
|
1409
|
+
|
|
1410
|
+
## UnsupportedType
|
|
1411
|
+
Generic error for unsupported data type
|
|
1412
|
+
|
|
1413
|
+
**Kind**: global class
|
|
1414
|
+
<a name="new_UnsupportedType_new"></a>
|
|
1415
|
+
|
|
1416
|
+
### new UnsupportedType(t)
|
|
1417
|
+
**Throws**:
|
|
1418
|
+
|
|
1419
|
+
- UnsupportedType
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
| Param | Type | Description |
|
|
1423
|
+
| --- | --- | --- |
|
|
1424
|
+
| t | <code>\*</code> | Parameter which was used |
|
|
1425
|
+
|
|
1426
|
+
<a name="UnsupportedCondition"></a>
|
|
1427
|
+
|
|
1428
|
+
## UnsupportedCondition
|
|
1429
|
+
Generic error for unsupported condition
|
|
1430
|
+
|
|
1431
|
+
**Kind**: global class
|
|
1432
|
+
<a name="new_UnsupportedCondition_new"></a>
|
|
1433
|
+
|
|
1434
|
+
### new UnsupportedCondition(condition, t)
|
|
1435
|
+
**Throws**:
|
|
1436
|
+
|
|
1437
|
+
- UnsupportedCondition
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
| Param | Type | Description |
|
|
1441
|
+
| --- | --- | --- |
|
|
1442
|
+
| condition | <code>\*</code> | The condition value |
|
|
1443
|
+
| t | <code>Array.<string></code> | List of supported data types |
|
|
1444
|
+
|
|
1445
|
+
<a name="SAX"></a>
|
|
1446
|
+
|
|
1447
|
+
## SAX
|
|
1448
|
+
**Kind**: global constant
|
|
1449
|
+
**Version:**: 1.7.11
|
|
1450
|
+
**Author:**: Wernfried Domscheit
|
|
1451
|
+
**Copyright:**: Copyright (c) 2025 Wernfried Domscheit. All rights reserved.
|
|
1452
|
+
**Website:**: https://www.npmjs.com/package/xml-twig
|
|
1453
|
+
<a name="Root"></a>
|
|
1454
|
+
|
|
1455
|
+
## Root : <code>RootHandler</code>
|
|
1456
|
+
**Kind**: global constant
|
|
1457
|
+
<a name="Any"></a>
|
|
1458
|
+
|
|
1459
|
+
## Any : <code>AnyHandler</code>
|
|
1460
|
+
**Kind**: global constant
|
|
1461
|
+
<a name="createParser"></a>
|
|
1462
|
+
|
|
1463
|
+
## createParser(handler, [options]) ⇒ [<code>Parser</code>](#Parser)
|
|
1464
|
+
Create a new Twig parser
|
|
1465
|
+
|
|
1466
|
+
**Kind**: global function
|
|
1467
|
+
**Returns**: [<code>Parser</code>](#Parser) - The parser Object
|
|
1468
|
+
**Throws**:
|
|
1469
|
+
|
|
1470
|
+
- [<code>UnsupportedParser</code>](#UnsupportedParser) - For an unsupported parser. Currently `expat` and `sax` (default) are supported.
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
| Param | Type | Description |
|
|
1474
|
+
| --- | --- | --- |
|
|
1475
|
+
| handler | [<code>TwigHandler</code>](#TwigHandler) \| [<code>Array.<TwigHandler></code>](#TwigHandler) | Object or array of element specification and function to handle elements |
|
|
1476
|
+
| [options] | [<code>ParserOptions</code>](#ParserOptions) | Object of optional options |
|
|
1477
|
+
|
|
1478
|
+
<a name="onStart"></a>
|
|
1479
|
+
|
|
1480
|
+
## onStart(parser, binds, node, attrs)
|
|
1481
|
+
Common Event hanlder for starting tag
|
|
1482
|
+
|
|
1483
|
+
**Kind**: global function
|
|
1484
|
+
|
|
1485
|
+
| Param | Type | Description |
|
|
1486
|
+
| --- | --- | --- |
|
|
1487
|
+
| parser | [<code>Parser</code>](#Parser) | The main parser object |
|
|
1488
|
+
| binds | <code>object</code> | Additional parameter object |
|
|
1489
|
+
| node | <code>object</code> \| <code>string</code> | Node or Node name |
|
|
1490
|
+
| attrs | <code>object</code> | Node Attributes |
|
|
1491
|
+
|
|
1492
|
+
<a name="onClose"></a>
|
|
1493
|
+
|
|
1494
|
+
## onClose(handler, parser, parser, options, name)
|
|
1495
|
+
Common Event hanlder for closing tag. On closed elements it either calls the Handler function or emits the specified event.
|
|
1496
|
+
|
|
1497
|
+
**Kind**: global function
|
|
1498
|
+
|
|
1499
|
+
| Param | Type | Description |
|
|
1500
|
+
| --- | --- | --- |
|
|
1501
|
+
| handler | [<code>TwigHandler</code>](#TwigHandler) \| [<code>Array.<TwigHandler></code>](#TwigHandler) | Object or array of element specification and function to handle elements |
|
|
1502
|
+
| parser | [<code>Parser</code>](#Parser) | The main parser object |
|
|
1503
|
+
| parser | [<code>sax</code>](https://www.npmjs.com/package/sax) \| [<code>node-expat</code>](https://www.npmjs.com/package/node-expat) | SAXStream or node-expat Stream object |
|
|
1504
|
+
| options | [<code>ParserOptions</code>](#ParserOptions) | Object of optional options |
|
|
1505
|
+
| name | <code>string</code> | Event handler parameter |
|
|
1506
|
+
|
|
1507
|
+
<a name="ParserOptions"></a>
|
|
1508
|
+
|
|
1509
|
+
## ParserOptions
|
|
1510
|
+
Optional settings for the Twig parser
|
|
1511
|
+
|
|
1512
|
+
**Kind**: global typedef
|
|
1513
|
+
**Default**: <code>{ method: 'sax', xmlns: false, trim: true, resumeAfterError: false, partial: false }</code>
|
|
1514
|
+
**Properties**
|
|
1515
|
+
|
|
1516
|
+
| Name | Type | Description |
|
|
1517
|
+
| --- | --- | --- |
|
|
1518
|
+
| [method] | <code>'sax'</code> \| <code>'expat'</code> | The underlying parser. Either `'sax'`, `'expat'`. |
|
|
1519
|
+
| [xmlns] | <code>boolean</code> | If `true`, then namespaces are accessible by `namespace` property. |
|
|
1520
|
+
| [trim] | <code>boolean</code> | If `true`, then turn any whitespace into a single space. Text and comments are trimmed. |
|
|
1521
|
+
| [resumeAfterError] | <code>boolean</code> | If `true` then parser continues reading after an error. Otherwise it throws exception. |
|
|
1522
|
+
| [partial] | <code>boolean</code> | If `true` then unhandled elements are purged. |
|
|
1523
|
+
| [file] | <code>string</code> | Optional. The name of file to be parsed. Just used for information and logging purpose. |
|
|
1524
|
+
|
|
1525
|
+
**Example**
|
|
1526
|
+
```js
|
|
1527
|
+
{ method: 'expat', xmlns: true }
|
|
1528
|
+
```
|
|
1529
|
+
<a name="TwigHandler"></a>
|
|
1530
|
+
|
|
1531
|
+
## TwigHandler
|
|
1532
|
+
Reference to handler functions for Twig objects.<br>
|
|
1533
|
+
|
|
1534
|
+
**Kind**: global typedef
|
|
1535
|
+
**Properties**
|
|
1536
|
+
|
|
1537
|
+
| Name | Type | Description |
|
|
1538
|
+
| --- | --- | --- |
|
|
1539
|
+
| tag | [<code>HandlerCondition</code>](#HandlerCondition) | Element specification |
|
|
1540
|
+
| [function] | [<code>HandlerFunction</code>](#HandlerFunction) | Definition of handler function, either anonymous or explicit function |
|
|
1541
|
+
| [event] | <code>string</code> | Type of the event to be emitted |
|
|
1542
|
+
|
|
1543
|
+
<a name="HandlerCondition"></a>
|
|
1544
|
+
|
|
1545
|
+
## HandlerCondition : <code>string</code> \| <code>Array.<string></code> \| <code>RegExp</code> \| [<code>HandlerConditionFilter</code>](#HandlerConditionFilter) \| [<code>Root</code>](#Root) \| [<code>Any</code>](#Any)
|
|
1546
|
+
Condition to specify when handler shall be called<br>
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1547
|
+
|
|
1548
|
+
**Kind**: global typedef
|
|
1549
|
+
<a name="HandlerFunction"></a>
|
|
1550
|
+
|
|
1551
|
+
## HandlerFunction : <code>function</code>
|
|
1552
|
+
Handler function for Twig objects, i.e. the way you like to use the XML element.
|
|
1553
|
+
|
|
1554
|
+
**Kind**: global typedef
|
|
1555
|
+
|
|
1556
|
+
| Param | Type | Description |
|
|
1557
|
+
| --- | --- | --- |
|
|
1558
|
+
| elt | [<code>Twig</code>](#Twig) | The current Twig element on which the function was called. |
|
|
1559
|
+
|
|
1560
|
+
<a name="HandlerConditionFilter"></a>
|
|
1561
|
+
|
|
1562
|
+
## HandlerConditionFilter ⇒ <code>boolean</code>
|
|
1563
|
+
Custom filter function to specify when handler shall be called
|
|
1564
|
+
|
|
1565
|
+
**Kind**: global typedef
|
|
1566
|
+
**Returns**: <code>boolean</code> - If the function returns `true`, then it is included in the filter
|
|
1567
|
+
|
|
1568
|
+
| Param | Type | Description |
|
|
1569
|
+
| --- | --- | --- |
|
|
1570
|
+
| name | <code>string</code> | Name of the element |
|
|
1571
|
+
|
|
1572
|
+
<a name="ElementCondition"></a>
|
|
1573
|
+
|
|
1574
|
+
## ElementCondition : <code>string</code> \| <code>RegExp</code> \| [<code>ElementConditionFilter</code>](#ElementConditionFilter) \| [<code>Twig</code>](#Twig) \| <code>undefined</code>
|
|
1575
|
+
Optional condition to get elements<br>
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1576
|
+
|
|
1577
|
+
**Kind**: global typedef
|
|
1578
|
+
<a name="ElementConditionFilter"></a>
|
|
1579
|
+
|
|
1580
|
+
## ElementConditionFilter ⇒ <code>boolean</code>
|
|
1581
|
+
Custom filter function to select desired elements
|
|
1582
|
+
|
|
1583
|
+
**Kind**: global typedef
|
|
1584
|
+
**Returns**: <code>boolean</code> - If the function returns `true`, then it is included in the filter
|
|
1585
|
+
|
|
1586
|
+
| Param | Type | Description |
|
|
1587
|
+
| --- | --- | --- |
|
|
1588
|
+
| name | <code>string</code> | Name of the element |
|
|
1589
|
+
| elt | [<code>Twig</code>](#Twig) | The Twig object |
|
|
1590
|
+
|
|
1591
|
+
<a name="Parser"></a>
|
|
1592
|
+
|
|
1593
|
+
## Parser ⇒ [<code>sax</code>](https://www.npmjs.com/package/sax) \| [<code>node-expat</code>](https://www.npmjs.com/package/node-expat)
|
|
1594
|
+
**Kind**: global typedef
|
|
1595
|
+
**Returns**: [<code>sax</code>](https://www.npmjs.com/package/sax) \| [<code>node-expat</code>](https://www.npmjs.com/package/node-expat) - The parser Object
|
|
1596
|
+
**Properties**
|
|
1597
|
+
|
|
1598
|
+
| Name | Type | Description |
|
|
1599
|
+
| --- | --- | --- |
|
|
1600
|
+
| [currentLine] | <code>number</code> | The currently processed line in the XML-File. |
|
|
1601
|
+
| [currentColumn] | <code>number</code> | The currently processed column in the XML-File. |
|
|
1602
|
+
| [file] | <code>string</code> | The name of file to be parsed. Just used for information and logging purpose. |
|
|
1603
|
+
| [twig] | <code>object</code> | Object with XML tree and current XML element |
|
|
1604
|
+
| [method] | <code>string</code> | The underlying parser. Either `'sax'`, `'expat'`. |
|
|
1605
|
+
|
|
1606
|
+
<a name="AttributeCondition"></a>
|
|
1607
|
+
|
|
1608
|
+
## AttributeCondition : <code>string</code> \| <code>RegExp</code> \| [<code>AttributeConditionFilter</code>](#AttributeConditionFilter)
|
|
1609
|
+
Optional condition to get attributes<br>
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1610
|
+
|
|
1611
|
+
**Kind**: global typedef
|
|
1612
|
+
<a name="AttributeConditionFilter"></a>
|
|
1613
|
+
|
|
1614
|
+
## AttributeConditionFilter : <code>function</code>
|
|
1615
|
+
Custom filter function to get desired attributes
|
|
1616
|
+
|
|
1617
|
+
**Kind**: global typedef
|
|
1618
|
+
|
|
1619
|
+
| Param | Type | Description |
|
|
1620
|
+
| --- | --- | --- |
|
|
1621
|
+
| name | <code>string</code> | Name of the attribute |
|
|
1622
|
+
| value | <code>string</code> \| <code>number</code> | Value of the attribute |
|
|
1623
|
+
|
|
1624
|
+
<a name="+PI"></a>
|
|
1625
|
+
|
|
1626
|
+
## #PI : <code>object</code>
|
|
1627
|
+
XML Processing Instruction object, exist only on root
|
|
1628
|
+
|
|
1629
|
+
**Kind**: global typedef
|
|
1630
|
+
<a name="+declaration"></a>
|
|
1631
|
+
|
|
1632
|
+
## #declaration : <code>object</code>
|
|
1633
|
+
XML Declaration object, exist only on root
|
|
1634
|
+
|
|
1635
|
+
**Kind**: global typedef
|
|
1636
|
+
<a name="+namespace"></a>
|
|
1637
|
+
|
|
1638
|
+
## #namespace : <code>object</code>
|
|
1639
|
+
XML namespace of element. Exist onl when parsed with `xmlns: true`
|
|
1640
|
+
|
|
1641
|
+
**Kind**: global typedef
|
|
1642
|
+
<a name="+comment"></a>
|
|
1643
|
+
|
|
1644
|
+
## #comment : <code>string</code> \| <code>Array.<string></code>
|
|
1645
|
+
Comment or array of comments inside the XML Elements
|
|
1646
|
+
|
|
1647
|
+
**Kind**: global typedef
|