@cntwg/xml-lib-js 0.0.31 → 0.0.32
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/CHANGELOG.md +11 -0
- package/LICENSE +1 -1
- package/doc/xmldoc-lib.md +303 -59
- package/lib/file-helper.js +278 -0
- package/lib/xml-helper.js +29 -12
- package/lib/xmldoc-lib.js +272 -325
- package/package.json +5 -4
package/doc/xmldoc-lib.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.37|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2025-02-06|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
7
7
|
This paper describes a constants, functions and an object classes provided by `xmldoc-lib.js` module.
|
|
8
8
|
|
|
9
|
+
### Base type definitions
|
|
10
|
+
|
|
11
|
+
This section contains some definitions for a general types of the objects (e.g. options set) that frequently used in a function or a class method descriptions.
|
|
12
|
+
|
|
13
|
+
<a name="typedef+fsoDescr"></a>
|
|
14
|
+
#### `fsoDescr` - descriptor
|
|
15
|
+
|
|
16
|
+
This descriptor is an `object` that describes a status for an operation with some FS-object (*e.g. object such as a file*).
|
|
17
|
+
|
|
18
|
+
| property name | value type | optional | description |
|
|
19
|
+
|:---|---|---:|:---|
|
|
20
|
+
| `isERR` | `boolean` | no | a flag which indicates whether an error was happen |
|
|
21
|
+
| `errCode` | `number` | yes | an error code |
|
|
22
|
+
| `errEvent` | `string` | no | an error event identifier |
|
|
23
|
+
| `errMsg` | `string` | no | an error message |
|
|
24
|
+
| `source` | `string` | no | path to a file |
|
|
25
|
+
| `content` | `any` | no | content |
|
|
26
|
+
|
|
9
27
|
## Module constants
|
|
10
28
|
|
|
11
29
|
### **XML\_DEF\_PARSE_OPTIONS**
|
|
@@ -51,24 +69,39 @@ This constant defines a default value for naming the language attribute for XML-
|
|
|
51
69
|
|
|
52
70
|
> Note: Purpose of those functions will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
|
|
53
71
|
|
|
72
|
+
<a name="readAsTagName"></a>
|
|
54
73
|
#### **readAsTagName(value)** => `string`
|
|
55
74
|
|
|
56
75
|
> since: \[`v0.0.28`]
|
|
57
76
|
|
|
58
77
|
This function tries to convert a given `value` to the value of type which is suitable for an XML-element's tag name. If failed an empty string is returned.
|
|
59
78
|
|
|
79
|
+
| parameter name | value type | default value | description |
|
|
80
|
+
|:---|---|---:|:---|
|
|
81
|
+
| `value` | `any` | --- | some value to read |
|
|
82
|
+
|
|
83
|
+
<a name="readAsAttrName"></a>
|
|
60
84
|
#### **readAsAttrName(value)** => `string`
|
|
61
85
|
|
|
62
86
|
> since: \[`v0.0.28`]
|
|
63
87
|
|
|
64
88
|
This function tries to convert a given `value` to the value of type which is suitable for an XML-element's attribute name. If failed an empty string is returned.
|
|
65
89
|
|
|
90
|
+
| parameter name | value type | default value | description |
|
|
91
|
+
|:---|---|---:|:---|
|
|
92
|
+
| `value` | `any` | --- | some value to read |
|
|
93
|
+
|
|
94
|
+
<a name="valueToElementID"></a>
|
|
66
95
|
#### **valueToElementID(value)**
|
|
67
96
|
|
|
68
97
|
> since: \[`v0.0.28`]
|
|
69
98
|
|
|
70
99
|
This function tries to convert a given `value` to the value of a valid identifier which is suitable for an XML-element's ID-attribute. If failed an empty string is returned.
|
|
71
100
|
|
|
101
|
+
| parameter name | value type | default value | description |
|
|
102
|
+
|:---|---|---:|:---|
|
|
103
|
+
| `value` | `any` | --- | some value to read |
|
|
104
|
+
|
|
72
105
|
## Module classes
|
|
73
106
|
|
|
74
107
|
### **TXmlContentParseOptions**
|
|
@@ -100,6 +133,7 @@ The table below describes a properties of a `TXmlContentParseOptions` class:
|
|
|
100
133
|
|
|
101
134
|
This method transforms a given object to a set of accepted parser options.
|
|
102
135
|
|
|
136
|
+
<a name="TXmlAttributesMapper"></a>
|
|
103
137
|
### **TXmlAttributesMapper**
|
|
104
138
|
|
|
105
139
|
This class implements a proxy interface for handling attributes of an element.
|
|
@@ -112,18 +146,18 @@ The class constructor creates a new instance of the class.
|
|
|
112
146
|
|
|
113
147
|
The class constructor receives an arguments listed below:
|
|
114
148
|
|
|
115
|
-
|parameter name|value type|default value|description|
|
|
149
|
+
| parameter name | value type | default value | description |
|
|
116
150
|
|:---|---|---:|:---|
|
|
117
|
-
|
|
118
|
-
|
|
151
|
+
| `object` | `object` | --- | a host object that holds an attributes |
|
|
152
|
+
| `options` | `object` | --- | an options settings |
|
|
119
153
|
|
|
120
154
|
###### `options` parameter
|
|
121
155
|
|
|
122
156
|
The `options` structure is listed below:
|
|
123
157
|
|
|
124
|
-
|option name|value type|default value|description|
|
|
158
|
+
| option name | value type | default value | description |
|
|
125
159
|
|:---|---|---:|:---|
|
|
126
|
-
|
|
160
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (*see description for `XML_DEF_PARSE_OPTIONS`*) |
|
|
127
161
|
|
|
128
162
|
##### exceptions
|
|
129
163
|
|
|
@@ -131,39 +165,71 @@ If `object` parameter is not a type of `object` or not given a `TypeError` throw
|
|
|
131
165
|
|
|
132
166
|
#### class properties
|
|
133
167
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
168
|
+
<a name="TXmlAttributesMapper+entries"></a>
|
|
169
|
+
##### **entries**
|
|
170
|
+
|
|
171
|
+
| property type | read only | description |
|
|
172
|
+
|---|---|:---|
|
|
173
|
+
| `array` | yes | contains a list of entries for all existing attributes |
|
|
137
174
|
|
|
138
175
|
|
|
139
176
|
#### class methods
|
|
140
177
|
|
|
178
|
+
<a name="TXmlAttributesMapper+hasAttribute"></a>
|
|
141
179
|
##### **hasAttribute(name)** => `boolean`
|
|
142
180
|
|
|
143
181
|
This method checks whether or not an attribute addressed by a `name` exists. If attribute exists, 'true' is returned.
|
|
144
182
|
|
|
183
|
+
| parameter name | value type | default value | description |
|
|
184
|
+
|:---|---|---:|:---|
|
|
185
|
+
| `name` | `string` | --- | some attribute name |
|
|
186
|
+
|
|
187
|
+
<a name="TXmlAttributesMapper+getAttribute"></a>
|
|
145
188
|
##### **getAttribute(name)** => `string`
|
|
146
189
|
|
|
147
190
|
This method returns an attribute value addressed by a `name`. If attribute is not exists the empty string is returned.
|
|
148
191
|
|
|
192
|
+
| parameter name | value type | default value | description |
|
|
193
|
+
|:---|---|---:|:---|
|
|
194
|
+
| `name` | `string` | --- | some attribute name |
|
|
195
|
+
|
|
196
|
+
<a name="TXmlAttributesMapper+setAttribute"></a>
|
|
149
197
|
##### **setAttribute(name, value)** => `boolean`
|
|
150
198
|
|
|
151
199
|
This method sets an attribute value addressed by a `name` and return `true` if succeed.
|
|
152
200
|
|
|
201
|
+
| parameter name | value type | default value | description |
|
|
202
|
+
|:---|---|---:|:---|
|
|
203
|
+
| `name` | `string` | --- | some attribute name |
|
|
204
|
+
| `value` | `any` | --- | some value |
|
|
205
|
+
|
|
206
|
+
<a name="TXmlAttributesMapper+delAttribute"></a>
|
|
153
207
|
##### **delAttribute(name)** => `boolean`
|
|
154
208
|
|
|
155
209
|
This method clears an attribute value addressed by a `name`.
|
|
156
210
|
|
|
211
|
+
| parameter name | value type | default value | description |
|
|
212
|
+
|:---|---|---:|:---|
|
|
213
|
+
| `name` | `string` | --- | some attribute name |
|
|
214
|
+
|
|
215
|
+
<a name="TXmlAttributesMapper+renameAttribute"></a>
|
|
157
216
|
##### **renameAttribute(name, value)** => `boolean`
|
|
158
217
|
|
|
159
218
|
> since: \[`v0.0.30`]
|
|
160
219
|
|
|
161
220
|
This method renames an attribute addressed by a `name` to its new name given by a `value` parameter.
|
|
162
221
|
|
|
222
|
+
| parameter name | value type | default value | description |
|
|
223
|
+
|:---|---|---:|:---|
|
|
224
|
+
| `name` | `string` | --- | some attribute name |
|
|
225
|
+
| `value` | `string` | --- | new name of the attribute |
|
|
226
|
+
|
|
227
|
+
<a name="TXmlAttributesMapper+clear"></a>
|
|
163
228
|
##### **clear()** => `void`
|
|
164
229
|
|
|
165
230
|
This method clears all attributes.
|
|
166
231
|
|
|
232
|
+
<a name="TXmlElementController"></a>
|
|
167
233
|
### **TXmlElementController**
|
|
168
234
|
|
|
169
235
|
This class implements a proxy interface for an element.
|
|
@@ -176,19 +242,19 @@ The class constructor creates a new instance of the class.
|
|
|
176
242
|
|
|
177
243
|
The class constructor receives an arguments listed below:
|
|
178
244
|
|
|
179
|
-
|parameter name|value type|default value|description|
|
|
245
|
+
| parameter name | value type | default value | description |
|
|
180
246
|
|:---|---|---:|:---|
|
|
181
|
-
|
|
182
|
-
|
|
247
|
+
| `object` | `object` | --- | a host object |
|
|
248
|
+
| `options` | `object` | --- | an options settings |
|
|
183
249
|
|
|
184
250
|
###### `options` parameter
|
|
185
251
|
|
|
186
252
|
The `options` structure is listed below:
|
|
187
253
|
|
|
188
|
-
|option name|value type|default value|description|
|
|
254
|
+
| option name | value type | default value | description |
|
|
189
255
|
|:---|---|---:|:---|
|
|
190
|
-
|
|
191
|
-
|
|
256
|
+
| `proxyModeEnable` | `boolean` | `false` | <*reserved*> |
|
|
257
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
|
|
192
258
|
|
|
193
259
|
##### exceptions
|
|
194
260
|
|
|
@@ -196,40 +262,83 @@ If `object` parameter is not a type of `object` or not given a `TypeError` throw
|
|
|
196
262
|
|
|
197
263
|
#### class properties
|
|
198
264
|
|
|
265
|
+
<a name="TXmlElementController+attributes"></a>
|
|
266
|
+
##### **attributes**
|
|
267
|
+
|
|
268
|
+
| property type | read only | description |
|
|
269
|
+
|---|---|:---|
|
|
270
|
+
| `TXmlAttributesMapper` | yes | returns an attributes of the element |
|
|
271
|
+
|
|
272
|
+
<a name="TXmlElementController+textValue"></a>
|
|
273
|
+
##### **textValue**
|
|
274
|
+
|
|
275
|
+
| property type | read only | description |
|
|
276
|
+
|---|---|:---|
|
|
277
|
+
| `string` | no | represents a value of the element |
|
|
278
|
+
|
|
279
|
+
#### class properties (*others*)
|
|
280
|
+
|
|
199
281
|
|property name|value type|read only|description|
|
|
200
282
|
|:---|---|---|:---|
|
|
201
|
-
|`attributes`|`TXmlAttributesMapper`|yes|returns an attributes of the element|
|
|
202
283
|
|`name`||yes|\<*reserved*>|
|
|
203
|
-
|`textValue`|`string`|no|represents a value of the element|
|
|
204
284
|
|
|
205
285
|
#### class methods
|
|
206
286
|
|
|
287
|
+
<a name="TXmlElementController+hasAttribute"></a>
|
|
207
288
|
##### **hasAttribute(name)** => `boolean`
|
|
208
289
|
|
|
209
290
|
This method checks whether or not an attribute addressed by a `name` exists. If attribute exists, 'true' is returned.
|
|
210
291
|
|
|
292
|
+
| parameter name | value type | default value | description |
|
|
293
|
+
|:---|---|---:|:---|
|
|
294
|
+
| `name` | `string` | --- | some attribute name |
|
|
295
|
+
|
|
296
|
+
<a name="TXmlElementController+getAttribute"></a>
|
|
211
297
|
##### **getAttribute(name)** => `string`
|
|
212
298
|
|
|
213
299
|
This method returns an attribute value addressed by a `name`. If attribute is not exists the empty string is returned.
|
|
214
300
|
|
|
301
|
+
| parameter name | value type | default value | description |
|
|
302
|
+
|:---|---|---:|:---|
|
|
303
|
+
| `name` | `string` | --- | some attribute name |
|
|
304
|
+
|
|
305
|
+
<a name="TXmlElementController+setAttribute"></a>
|
|
215
306
|
##### **setAttribute(name, value)** => `boolean`
|
|
216
307
|
|
|
217
308
|
This method sets an attribute value addressed by a `name` and return `true` if succeed.
|
|
218
309
|
|
|
310
|
+
| parameter name | value type | default value | description |
|
|
311
|
+
|:---|---|---:|:---|
|
|
312
|
+
| `name` | `string` | --- | some attribute name |
|
|
313
|
+
| `value` | `any` | --- | some value |
|
|
314
|
+
|
|
315
|
+
<a name="TXmlElementController+delAttribute"></a>
|
|
219
316
|
##### **delAttribute(name)** => `boolean`
|
|
220
317
|
|
|
221
318
|
This method clears an attribute value addressed by a `name` parameter.
|
|
222
319
|
|
|
320
|
+
| parameter name | value type | default value | description |
|
|
321
|
+
|:---|---|---:|:---|
|
|
322
|
+
| `name` | `string` | --- | some attribute name |
|
|
323
|
+
|
|
324
|
+
<a name="TXmlElementController+renameAttribute"></a>
|
|
223
325
|
##### **renameAttribute(name, value)** => `boolean`
|
|
224
326
|
|
|
225
327
|
> since: \[`v0.0.30`]
|
|
226
328
|
|
|
227
329
|
This method renames an attribute addressed by a `name` to its new name given by a `value` parameter.
|
|
228
330
|
|
|
331
|
+
| parameter name | value type | default value | description |
|
|
332
|
+
|:---|---|---:|:---|
|
|
333
|
+
| `name` | `string` | --- | some attribute name |
|
|
334
|
+
| `value` | `string` | --- | new name of the attribute |
|
|
335
|
+
|
|
336
|
+
<a name="TXmlElementController+getTextValue"></a>
|
|
229
337
|
##### **getTextValue()** => `array`
|
|
230
338
|
|
|
231
339
|
This method returns an array witch contain a value of a `textValue` property and a value of a `lang` attribute in format: `[ <lang>, <textValue> ]`. If element has no `lang` attribute, it replaced by an empty string in the result.
|
|
232
340
|
|
|
341
|
+
<a name="TXmlElementController+setTextValue"></a>
|
|
233
342
|
##### **setTextValue(value)** => `boolean`
|
|
234
343
|
|
|
235
344
|
This method sets the value of a `textValue` property and its `lang` attribute and if succeed returns `true`.
|
|
@@ -240,24 +349,45 @@ The method received value that can be a string or an array. If value is an array
|
|
|
240
349
|
or
|
|
241
350
|
`[ <lang>, <textValue> ]`.
|
|
242
351
|
|
|
352
|
+
<a name="TXmlElementController+hasChild"></a>
|
|
243
353
|
##### **hasChild(name)** => `boolean`
|
|
244
354
|
|
|
245
355
|
This method checks whether or not a child element addressed by `name` is exists.
|
|
246
356
|
|
|
247
|
-
|
|
357
|
+
| parameter name | value type | default value | description |
|
|
358
|
+
|:---|---|---:|:---|
|
|
359
|
+
| `name` | `string` | --- | some child element name |
|
|
360
|
+
|
|
361
|
+
<a name="TXmlElementController+getChild"></a>
|
|
362
|
+
##### **getChild(name)** => `null`\|`TXmlElementController`\|`TXmlElementsListController`
|
|
248
363
|
|
|
249
364
|
This method returns a child element addressed by `name`. If failed `null` is returned.
|
|
250
365
|
|
|
366
|
+
| parameter name | value type | default value | description |
|
|
367
|
+
|:---|---|---:|:---|
|
|
368
|
+
| `name` | `string` | --- | some child element name |
|
|
369
|
+
|
|
370
|
+
<a name="TXmlElementController+addChild"></a>
|
|
251
371
|
##### **addChild(name)** => `?TXmlElementController`
|
|
252
372
|
|
|
253
373
|
This method adds a new element as a child element addressed by a `name` parameter.
|
|
254
374
|
|
|
375
|
+
| parameter name | value type | default value | description |
|
|
376
|
+
|:---|---|---:|:---|
|
|
377
|
+
| `name` | `string` | --- | some child element name |
|
|
378
|
+
|
|
379
|
+
<a name="TXmlElementController+delChild"></a>
|
|
255
380
|
##### **delChild(name)** => `boolean`
|
|
256
381
|
|
|
257
382
|
This method deletes a child element addressed by a `name`.
|
|
258
383
|
|
|
259
384
|
> Warning: A method not fully implemented yet. Not use it for list like elements. If list contains a more than one element, a method will fail.
|
|
260
385
|
|
|
386
|
+
| parameter name | value type | default value | description |
|
|
387
|
+
|:---|---|---:|:---|
|
|
388
|
+
| `name` | `string` | --- | some child element name |
|
|
389
|
+
|
|
390
|
+
<a name="TXmlElementController+clear"></a>
|
|
261
391
|
##### **clear()** => `void`
|
|
262
392
|
|
|
263
393
|
This method clears an element content.
|
|
@@ -266,13 +396,18 @@ This method clears an element content.
|
|
|
266
396
|
|
|
267
397
|
> Note: Purpose of those methods will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
|
|
268
398
|
|
|
399
|
+
<a name="TXmlElementController+loadFromXMLString"></a>
|
|
269
400
|
##### **loadFromXMLString(str)** => `boolean`
|
|
270
401
|
|
|
271
402
|
This method loads an element content from a string given by a `str` parameter.
|
|
272
403
|
|
|
404
|
+
| parameter name | value type | default value | description |
|
|
405
|
+
|:---|---|---:|:---|
|
|
406
|
+
| `str` | `string` | --- | some content |
|
|
407
|
+
|
|
273
408
|
###### *exceptions*
|
|
274
409
|
|
|
275
|
-
This methods
|
|
410
|
+
This methods throws `Error` if something goes wrong through a parsing process of a string.
|
|
276
411
|
|
|
277
412
|
#### class methods (*special*)
|
|
278
413
|
|
|
@@ -322,6 +457,7 @@ This method adds an element addressed by `name` as a child element.
|
|
|
322
457
|
|
|
323
458
|
This method inserts a given object as a child element addressed by `name`.
|
|
324
459
|
|
|
460
|
+
<a name="TXmlElementsListController"></a>
|
|
325
461
|
### **TXmlElementsListController**
|
|
326
462
|
|
|
327
463
|
This class implements a proxy interface for a list of elements.
|
|
@@ -334,20 +470,20 @@ The class constructor creates a new instance of the class.
|
|
|
334
470
|
|
|
335
471
|
The class constructor receives an arguments listed below:
|
|
336
472
|
|
|
337
|
-
|parameter name|value type|default value|description|
|
|
473
|
+
| parameter name | value type | default value | description |
|
|
338
474
|
|:---|---|---:|:---|
|
|
339
|
-
|
|
340
|
-
|
|
475
|
+
| `object` | `object[]` | --- | a host object of an array type |
|
|
476
|
+
| `options` | `object` | --- | an options settings |
|
|
341
477
|
|
|
342
478
|
###### `options` parameter
|
|
343
479
|
|
|
344
480
|
The `options` structure is listed below:
|
|
345
481
|
|
|
346
|
-
|option name|value type|default value|description|
|
|
482
|
+
| option name | value type | default value | description |
|
|
347
483
|
|:---|---|---:|:---|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
484
|
+
| `proxyModeEnable` | `boolean` | `false` | <*reserved*> |
|
|
485
|
+
| `isNullItemsAllowed` | `boolean` | `false` | <*reserved*> |
|
|
486
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
|
|
351
487
|
|
|
352
488
|
##### exceptions
|
|
353
489
|
|
|
@@ -355,64 +491,131 @@ If `object` parameter is not a type of `array` or not given a `TypeError` may be
|
|
|
355
491
|
|
|
356
492
|
#### class properties
|
|
357
493
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
494
|
+
<a name="TXmlElementsListController+count"></a>
|
|
495
|
+
##### **count**
|
|
496
|
+
|
|
497
|
+
| property type | read only | description |
|
|
498
|
+
|---|---|:---|
|
|
499
|
+
| `number` | yes | returns a quantity of the elements |
|
|
500
|
+
|
|
501
|
+
<a name="TXmlElementsListController+size"></a>
|
|
502
|
+
##### **size**
|
|
503
|
+
|
|
504
|
+
| property type | read only | description |
|
|
505
|
+
|---|---|:---|
|
|
506
|
+
| `number` | yes | returns a quantity of the elements |
|
|
507
|
+
|
|
508
|
+
<a name="TXmlElementsListController+maxIndex"></a>
|
|
509
|
+
##### **maxIndex**
|
|
510
|
+
|
|
511
|
+
| property type | read only | description |
|
|
512
|
+
|---|---|:---|
|
|
513
|
+
| `number` | yes | returns a last possible index of the element |
|
|
514
|
+
|
|
515
|
+
<a name="TXmlElementsListController+isNullItemsAllowed"></a>
|
|
516
|
+
##### **isNullItemsAllowed**
|
|
517
|
+
|
|
518
|
+
| property type | read only | description |
|
|
519
|
+
|---|---|:---|
|
|
520
|
+
| `boolean` | yes | indicates whether a list may be filled with the `null`-elements or not |
|
|
364
521
|
|
|
365
522
|
#### class methods
|
|
366
523
|
|
|
524
|
+
<a name="TXmlElementsListController+clear"></a>
|
|
367
525
|
##### **clear()** => `void`
|
|
368
526
|
|
|
369
527
|
This method clears a list.
|
|
370
528
|
|
|
529
|
+
<a name="TXmlElementsListController+isEmpty"></a>
|
|
371
530
|
##### **isEmpty()** => `boolean`
|
|
372
531
|
|
|
373
532
|
This method returns `true` if a list has no elements and `false` otherwise.
|
|
374
533
|
|
|
534
|
+
<a name="TXmlElementsListController+isNotEmpty"></a>
|
|
375
535
|
##### **isNotEmpty()** => `boolean`
|
|
376
536
|
|
|
377
537
|
This method returns `true` if a list contains at least one element and `false` otherwise.
|
|
378
538
|
|
|
379
|
-
|
|
539
|
+
<a name="TXmlElementsListController+chkIndex"></a>
|
|
540
|
+
##### **chkIndex(value)** => `boolean`
|
|
380
541
|
|
|
381
542
|
This method checks if a given index fits a range of elements within the list. If so `true` is returned.
|
|
382
543
|
|
|
544
|
+
| parameter name | value type | default value | description |
|
|
545
|
+
|:---|---|---:|:---|
|
|
546
|
+
| `value` | `number`, `string` | --- | some index value |
|
|
547
|
+
|
|
548
|
+
<a name="TXmlElementsListController+isValidItem"></a>
|
|
383
549
|
##### **isValidItem(obj)** => `boolean`
|
|
384
550
|
|
|
385
551
|
This method checks whether or not a given element is valid.
|
|
386
552
|
|
|
553
|
+
| parameter name | value type | default value | description |
|
|
554
|
+
|:---|---|---:|:---|
|
|
555
|
+
| `obj` | `any` | --- | some element to verify |
|
|
556
|
+
|
|
557
|
+
<a name="TXmlElementsListController+getItem"></a>
|
|
387
558
|
##### **getItem(index)** => `?TXmlElementController`
|
|
388
559
|
|
|
389
560
|
This method returns an element addressed by `index`. If failed `null` is returned.
|
|
390
561
|
|
|
391
|
-
|
|
562
|
+
| parameter name | value type | default value | description |
|
|
563
|
+
|:---|---|---:|:---|
|
|
564
|
+
| `index` | `number`, `string` | --- | element index |
|
|
565
|
+
|
|
566
|
+
<a name="TXmlElementsListController+addItem"></a>
|
|
567
|
+
##### **addItem(obj)** => `number`
|
|
392
568
|
|
|
393
569
|
This method adds an element to a list members. If succeed an index of the element is returned.
|
|
394
570
|
|
|
571
|
+
| parameter name | value type | default value | description |
|
|
572
|
+
|:---|---|---:|:---|
|
|
573
|
+
| `obj` | `any` | --- | some element |
|
|
574
|
+
|
|
575
|
+
<a name="TXmlElementsListController+_setItemRaw"></a>
|
|
395
576
|
##### **setItem(index, obj)** => `boolean`
|
|
396
577
|
|
|
397
578
|
This method replaces an element addressed by `index` with a new element. If succeed `true` is returned.
|
|
398
579
|
|
|
580
|
+
| parameter name | value type | default value | description |
|
|
581
|
+
|:---|---|---:|:---|
|
|
582
|
+
| `index` | `number`, `string` | --- | element index |
|
|
583
|
+
| `obj` | `any` | --- | some element |
|
|
584
|
+
|
|
585
|
+
<a name="TXmlElementsListController+insItem"></a>
|
|
399
586
|
##### **insItem(index, obj)** => `boolean`
|
|
400
587
|
|
|
401
588
|
This method inserts an element in the position addressed by `index`. If succeed `true` is returned.
|
|
402
589
|
|
|
590
|
+
| parameter name | value type | default value | description |
|
|
591
|
+
|:---|---|---:|:---|
|
|
592
|
+
| `index` | `number`, `string` | --- | element index |
|
|
593
|
+
| `obj` | `any` | --- | some element |
|
|
594
|
+
|
|
595
|
+
<a name="TXmlElementsListController+delItem"></a>
|
|
403
596
|
##### **delItem(index)** => `boolean`
|
|
404
597
|
|
|
405
598
|
This method deletes an element addressed by `index`. If succeed `true` is returned.
|
|
406
599
|
|
|
600
|
+
| parameter name | value type | default value | description |
|
|
601
|
+
|:---|---|---:|:---|
|
|
602
|
+
| `index` | `number`, `string` | --- | element index |
|
|
603
|
+
|
|
604
|
+
<a name="TXmlElementsListController+loadItems"></a>
|
|
407
605
|
##### **loadItems(items, options)** => `number`
|
|
408
606
|
|
|
409
607
|
This method loaded a list of elements listed by `items` and returns a quantity of a successfully added elements.
|
|
410
608
|
|
|
609
|
+
| parameter name | value type | default value | description |
|
|
610
|
+
|:---|---|---:|:---|
|
|
611
|
+
| `items` | `object`, `object[]` | --- | element or a list of an elements |
|
|
612
|
+
| `options` | `object` | --- | options |
|
|
613
|
+
|
|
411
614
|
The `options` structure is listed below:
|
|
412
615
|
|
|
413
|
-
|option name|value type|default value|description|
|
|
616
|
+
| option name | value type | default value | description |
|
|
414
617
|
|:---|---|---:|:---|
|
|
415
|
-
|
|
618
|
+
| `useClear` | `boolean` | `true` | if `true` the method deletes all the previous content before load the list |
|
|
416
619
|
|
|
417
620
|
#### class methods (*special*)
|
|
418
621
|
|
|
@@ -432,6 +635,7 @@ This method replaces an element addressed by `index` with a new element which is
|
|
|
432
635
|
|
|
433
636
|
This method inserts an element as a raw object in the position addressed by `index`. If succeed `true` is returned.
|
|
434
637
|
|
|
638
|
+
<a name="TXmlContentDeclaration"></a>
|
|
435
639
|
### **TXmlContentDeclaration**
|
|
436
640
|
|
|
437
641
|
This class implements a proxy interface for a document declaration element.
|
|
@@ -444,18 +648,18 @@ The class constructor creates a new instance of the class.
|
|
|
444
648
|
|
|
445
649
|
The class constructor receives an arguments listed below:
|
|
446
650
|
|
|
447
|
-
|parameter name|value type|default value|description|
|
|
651
|
+
| parameter name | value type | default value | description |
|
|
448
652
|
|:---|---|---:|:---|
|
|
449
|
-
|
|
450
|
-
|
|
653
|
+
| `object` | `object` | --- | a host object for the document content |
|
|
654
|
+
| `options` | `object` | --- | an options settings |
|
|
451
655
|
|
|
452
656
|
###### `options` parameter
|
|
453
657
|
|
|
454
658
|
The `options` structure is listed below:
|
|
455
659
|
|
|
456
|
-
|option name|value type|default value|description|
|
|
660
|
+
| option name | value type | default value | description |
|
|
457
661
|
|:---|---|---:|:---|
|
|
458
|
-
|
|
662
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
|
|
459
663
|
|
|
460
664
|
##### exceptions
|
|
461
665
|
|
|
@@ -463,10 +667,19 @@ If `object` parameter is not a type of `object` or not given a `TypeError` throw
|
|
|
463
667
|
|
|
464
668
|
#### class properties
|
|
465
669
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
670
|
+
<a name="TXmlContentDeclaration+version"></a>
|
|
671
|
+
##### **version**
|
|
672
|
+
|
|
673
|
+
| property type | read only | description |
|
|
674
|
+
|---|---|:---|
|
|
675
|
+
| `string` | no | returns a version of an XML |
|
|
676
|
+
|
|
677
|
+
<a name="TXmlContentDeclaration+encoding"></a>
|
|
678
|
+
##### **encoding**
|
|
679
|
+
|
|
680
|
+
| property type | read only | description |
|
|
681
|
+
|---|---|:---|
|
|
682
|
+
| `string` | no | returns a name of the character set used by the document |
|
|
470
683
|
|
|
471
684
|
#### class methods (*special*)
|
|
472
685
|
|
|
@@ -519,6 +732,7 @@ The `options` parameter, if given, change a behavior for the method. If set to '
|
|
|
519
732
|
|
|
520
733
|
#### class methods (*special*)
|
|
521
734
|
|
|
735
|
+
<a name="TXmlContentContainer"></a>
|
|
522
736
|
### **TXmlContentContainer**
|
|
523
737
|
|
|
524
738
|
This class implements a proxy interface for manipulate a content of a document.
|
|
@@ -535,52 +749,82 @@ The class constructor receives an `options` parameter as its argument.
|
|
|
535
749
|
|
|
536
750
|
The `options` structure is listed below:
|
|
537
751
|
|
|
538
|
-
|option name|value type|default value|description|
|
|
752
|
+
| option name | value type | default value | description |
|
|
539
753
|
|:---|---|---:|:---|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
754
|
+
| `rootETagName` | `string` | `root` | contains a the name of a tag that represents a root element |
|
|
755
|
+
| `autoBindRoot` | `boolean` | `true` | <*reserved*> |
|
|
756
|
+
| `proxyModeEnable` | `boolean` | `false` | <*reserved*> |
|
|
757
|
+
| `isNullItemsAllowed` | `boolean` | `false` | <*reserved*> |
|
|
758
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
|
|
545
759
|
|
|
546
760
|
#### class properties
|
|
547
761
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
762
|
+
<a name="TXmlContentContainer+rootElement"></a>
|
|
763
|
+
##### **rootElement**
|
|
764
|
+
|
|
765
|
+
| property type | read only | description |
|
|
766
|
+
|---|---|:---|
|
|
767
|
+
| `TXmlContentRootElement` | yes | returns a document root element |
|
|
551
768
|
|
|
552
769
|
#### class methods
|
|
553
770
|
|
|
771
|
+
<a name="TXmlContentContainer+clear"></a>
|
|
554
772
|
##### **clear()** => `void`
|
|
555
773
|
|
|
556
774
|
This method clears a document content.
|
|
557
775
|
|
|
776
|
+
<a name="TXmlContentContainer+saveToXMLString"></a>
|
|
558
777
|
##### **saveToXMLString()** => `string`
|
|
559
778
|
|
|
560
779
|
This method returns a document content as a string.
|
|
561
780
|
|
|
562
|
-
|
|
781
|
+
<a name="TXmlContentContainer+saveToFileSync"></a>
|
|
782
|
+
##### **saveToFileSync(src)** => `fsoDescr`
|
|
563
783
|
|
|
564
784
|
This method saves a document content into a file addressed by `src`.
|
|
565
785
|
|
|
786
|
+
| parameter name | value type | default value | description |
|
|
787
|
+
|:---|---|---:|:---|
|
|
788
|
+
| `src` | `string` | --- | path to a file |
|
|
789
|
+
|
|
790
|
+
<a name="TXmlContentContainer+loadFromXMLString"></a>
|
|
566
791
|
##### **loadFromXMLString(str)** => `boolean`
|
|
567
792
|
|
|
568
793
|
This method loads a document content from a string given by `str`.
|
|
569
794
|
|
|
570
|
-
|
|
795
|
+
| parameter name | value type | default value | description |
|
|
796
|
+
|:---|---|---:|:---|
|
|
797
|
+
| `str` | `string` | --- | some content |
|
|
798
|
+
|
|
799
|
+
<a name="TXmlContentContainer+loadFromFileSync"></a>
|
|
800
|
+
##### **loadFromFileSync(src)** => `fsoDescr`
|
|
571
801
|
|
|
572
802
|
This method loads a document content from a file addressed by `src`.
|
|
573
803
|
|
|
804
|
+
| parameter name | value type | default value | description |
|
|
805
|
+
|:---|---|---:|:---|
|
|
806
|
+
| `src` | `string` | --- | path to a file |
|
|
807
|
+
|
|
574
808
|
#### class methods (*async*)
|
|
575
809
|
|
|
576
|
-
|
|
810
|
+
<a name="TXmlContentContainer+saveToFile"></a>
|
|
811
|
+
##### **saveToFile(src)** => `Promise<fsoDescr, Error>`
|
|
577
812
|
|
|
578
813
|
This method saves a document content into a file addressed by `src`.
|
|
579
814
|
|
|
580
|
-
|
|
815
|
+
| parameter name | value type | default value | description |
|
|
816
|
+
|:---|---|---:|:---|
|
|
817
|
+
| `src` | `string` | --- | path to a file |
|
|
818
|
+
|
|
819
|
+
<a name="TXmlContentContainer+loadFromFile"></a>
|
|
820
|
+
##### **loadFromFile(src)** => `Promise<fsoDescr, Error>`
|
|
581
821
|
|
|
582
822
|
This method loads a document content from a file addressed by `src`.
|
|
583
823
|
|
|
824
|
+
| parameter name | value type | default value | description |
|
|
825
|
+
|:---|---|---:|:---|
|
|
826
|
+
| `src` | `string` | --- | path to a file |
|
|
827
|
+
|
|
584
828
|
#### class methods (*special*)
|
|
585
829
|
|
|
586
830
|
##### **asJSON()**
|