@cntwg/xml-lib-js 0.0.28 → 0.0.30
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 +18 -0
- package/doc/xmldoc-lib.md +86 -48
- package/lib/xmldoc-lib.js +343 -207
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
#### *v0.0.30*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - `xmldoc-lib.md` updated;
|
|
6
|
+
> - updated dependency on `@ygracs/xobj-lib-js` module to v0.2.0;
|
|
7
|
+
> - (`TXmlAttributesMapper`) add method: `renameAttribute`;
|
|
8
|
+
> - (`TXmlElementController`) add method: `renameAttribute`;
|
|
9
|
+
> - (`TXmlElementController`) add method: `loadFromXMLString`;
|
|
10
|
+
> - (`TXmlElementController`) add method: `create` (static);
|
|
11
|
+
> - (`TXmlElementController`) change class constructor behavior (*see docs for details*).
|
|
12
|
+
|
|
13
|
+
#### *v0.0.29*
|
|
14
|
+
|
|
15
|
+
Pre-release version.
|
|
16
|
+
|
|
17
|
+
> - updated dependency on `@ygracs/xml-js6` module to v0.0.4-b.
|
|
18
|
+
|
|
1
19
|
#### *v0.0.28*
|
|
2
20
|
|
|
3
21
|
Pre-release version.
|
package/doc/xmldoc-lib.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.30|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|2024-
|
|
3
|
+
>|date:|2024-09-23|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -51,13 +51,13 @@ This constant defines a default value for naming the language attribute for XML-
|
|
|
51
51
|
|
|
52
52
|
> 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
53
|
|
|
54
|
-
#### **readAsTagName(value)**
|
|
54
|
+
#### **readAsTagName(value)** => `string`
|
|
55
55
|
|
|
56
56
|
> since: `v0.0.28`
|
|
57
57
|
|
|
58
58
|
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
59
|
|
|
60
|
-
#### **readAsAttrName(value)**
|
|
60
|
+
#### **readAsAttrName(value)** => `string`
|
|
61
61
|
|
|
62
62
|
> since: `v0.0.28`
|
|
63
63
|
|
|
@@ -117,9 +117,7 @@ The class constructor receives an arguments listed below:
|
|
|
117
117
|
|`object`|---|---|a host object that holds an attributes|
|
|
118
118
|
|`options`|`object`|---|an options settings|
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
##### `options` parameter
|
|
120
|
+
###### `options` parameter
|
|
123
121
|
|
|
124
122
|
The `options` structure is listed below:
|
|
125
123
|
|
|
@@ -127,6 +125,10 @@ The `options` structure is listed below:
|
|
|
127
125
|
|:---|---|---:|:---|
|
|
128
126
|
|`parseOptions`|`object`|`EMPTY_OBJECT`|contains a XML-parse options (*see description for `XML_DEF_PARSE_OPTIONS`*)|
|
|
129
127
|
|
|
128
|
+
##### exceptions
|
|
129
|
+
|
|
130
|
+
If `object` parameter is not a type of `object` or not given a `TypeError` thrown.
|
|
131
|
+
|
|
130
132
|
#### class properties
|
|
131
133
|
|
|
132
134
|
|property name|value type|read only|description|
|
|
@@ -136,23 +138,29 @@ The `options` structure is listed below:
|
|
|
136
138
|
|
|
137
139
|
#### class methods
|
|
138
140
|
|
|
139
|
-
##### **hasAttribute(name)**
|
|
141
|
+
##### **hasAttribute(name)** => `boolean`
|
|
140
142
|
|
|
141
143
|
This method checks whether or not an attribute addressed by a `name` exists. If attribute exists, 'true' is returned.
|
|
142
144
|
|
|
143
|
-
##### **getAttribute(name)**
|
|
145
|
+
##### **getAttribute(name)** => `string`
|
|
144
146
|
|
|
145
147
|
This method returns an attribute value addressed by a `name`. If attribute is not exists the empty string is returned.
|
|
146
148
|
|
|
147
|
-
##### **setAttribute(name, value)**
|
|
149
|
+
##### **setAttribute(name, value)** => `boolean`
|
|
148
150
|
|
|
149
151
|
This method sets an attribute value addressed by a `name` and return `true` if succeed.
|
|
150
152
|
|
|
151
|
-
##### **delAttribute(name)**
|
|
153
|
+
##### **delAttribute(name)** => `boolean`
|
|
152
154
|
|
|
153
155
|
This method clears an attribute value addressed by a `name`.
|
|
154
156
|
|
|
155
|
-
##### **
|
|
157
|
+
##### **renameAttribute(name, value)** => `boolean`
|
|
158
|
+
|
|
159
|
+
> since: `v0.0.30`
|
|
160
|
+
|
|
161
|
+
This method renames an attribute addressed by a `name` to its new name given by a `value` parameter.
|
|
162
|
+
|
|
163
|
+
##### **clear()** => `void`
|
|
156
164
|
|
|
157
165
|
This method clears all attributes.
|
|
158
166
|
|
|
@@ -170,10 +178,10 @@ The class constructor receives an arguments listed below:
|
|
|
170
178
|
|
|
171
179
|
|parameter name|value type|default value|description|
|
|
172
180
|
|:---|---|---:|:---|
|
|
173
|
-
|`object
|
|
181
|
+
|`object`|`object`|---|a host object|
|
|
174
182
|
|`options`|`object`|---|an options settings|
|
|
175
183
|
|
|
176
|
-
|
|
184
|
+
###### `options` parameter
|
|
177
185
|
|
|
178
186
|
The `options` structure is listed below:
|
|
179
187
|
|
|
@@ -182,6 +190,10 @@ The `options` structure is listed below:
|
|
|
182
190
|
|`proxyModeEnable`|`boolean`|`false`|<*reserved*>|
|
|
183
191
|
|`parseOptions`|`object`|`EMPTY_OBJECT`|contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`)|
|
|
184
192
|
|
|
193
|
+
##### exceptions
|
|
194
|
+
|
|
195
|
+
If `object` parameter is not a type of `object` or not given a `TypeError` thrown.
|
|
196
|
+
|
|
185
197
|
#### class properties
|
|
186
198
|
|
|
187
199
|
|property name|value type|read only|description|
|
|
@@ -192,27 +204,33 @@ The `options` structure is listed below:
|
|
|
192
204
|
|
|
193
205
|
#### class methods
|
|
194
206
|
|
|
195
|
-
##### **hasAttribute(name)**
|
|
207
|
+
##### **hasAttribute(name)** => `boolean`
|
|
196
208
|
|
|
197
209
|
This method checks whether or not an attribute addressed by a `name` exists. If attribute exists, 'true' is returned.
|
|
198
210
|
|
|
199
|
-
##### **getAttribute(name)**
|
|
211
|
+
##### **getAttribute(name)** => `string`
|
|
200
212
|
|
|
201
213
|
This method returns an attribute value addressed by a `name`. If attribute is not exists the empty string is returned.
|
|
202
214
|
|
|
203
|
-
##### **setAttribute(name, value)**
|
|
215
|
+
##### **setAttribute(name, value)** => `boolean`
|
|
204
216
|
|
|
205
217
|
This method sets an attribute value addressed by a `name` and return `true` if succeed.
|
|
206
218
|
|
|
207
|
-
##### **delAttribute(name)**
|
|
219
|
+
##### **delAttribute(name)** => `boolean`
|
|
208
220
|
|
|
209
|
-
This method clears an attribute value addressed by a `name
|
|
221
|
+
This method clears an attribute value addressed by a `name` parameter.
|
|
222
|
+
|
|
223
|
+
##### **renameAttribute(name, value)** => `boolean`
|
|
224
|
+
|
|
225
|
+
> since: `v0.0.30`
|
|
210
226
|
|
|
211
|
-
|
|
227
|
+
This method renames an attribute addressed by a `name` to its new name given by a `value` parameter.
|
|
228
|
+
|
|
229
|
+
##### **getTextValue()** => `array`
|
|
212
230
|
|
|
213
231
|
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.
|
|
214
232
|
|
|
215
|
-
##### **setTextValue(value)**
|
|
233
|
+
##### **setTextValue(value)** => `boolean`
|
|
216
234
|
|
|
217
235
|
This method sets the value of a `textValue` property and its `lang` attribute and if succeed returns `true`.
|
|
218
236
|
|
|
@@ -222,28 +240,40 @@ The method received value that can be a string or an array. If value is an array
|
|
|
222
240
|
or
|
|
223
241
|
`[ <lang>, <textValue> ]`.
|
|
224
242
|
|
|
225
|
-
##### **hasChild(name)**
|
|
243
|
+
##### **hasChild(name)** => `boolean`
|
|
226
244
|
|
|
227
245
|
This method checks whether or not a child element addressed by `name` is exists.
|
|
228
246
|
|
|
229
|
-
##### **getChild(name)**
|
|
247
|
+
##### **getChild(name)** => `?(TXmlElementController|TXmlElementsListController)`
|
|
230
248
|
|
|
231
249
|
This method returns a child element addressed by `name`. If failed `null` is returned.
|
|
232
250
|
|
|
233
|
-
##### **addChild(name)**
|
|
251
|
+
##### **addChild(name)** => `?TXmlElementController`
|
|
234
252
|
|
|
235
|
-
This method adds
|
|
253
|
+
This method adds a new element as a child element addressed by a `name` parameter.
|
|
236
254
|
|
|
237
|
-
##### **delChild(name)**
|
|
255
|
+
##### **delChild(name)** => `boolean`
|
|
238
256
|
|
|
239
257
|
This method deletes a child element addressed by a `name`.
|
|
240
258
|
|
|
241
259
|
> 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.
|
|
242
260
|
|
|
243
|
-
##### **clear()**
|
|
261
|
+
##### **clear()** => `void`
|
|
244
262
|
|
|
245
263
|
This method clears an element content.
|
|
246
264
|
|
|
265
|
+
#### class methods (*experimental*)
|
|
266
|
+
|
|
267
|
+
> 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
|
+
|
|
269
|
+
##### **loadFromXMLString(str)** => `boolean`
|
|
270
|
+
|
|
271
|
+
This method loads an element content from a string given by a `str` parameter.
|
|
272
|
+
|
|
273
|
+
###### *exceptions*
|
|
274
|
+
|
|
275
|
+
This methods trows `Error` if something goes wrong through a parsing process of a string.
|
|
276
|
+
|
|
247
277
|
#### class methods (*special*)
|
|
248
278
|
|
|
249
279
|
##### **_getChildRaw(name)**
|
|
@@ -264,7 +294,7 @@ This method inserts a given object as a child element addressed by `name`.
|
|
|
264
294
|
|
|
265
295
|
This method returns a host for an element as an object. If failed `null` is returned.
|
|
266
296
|
|
|
267
|
-
##### **clear(item)**
|
|
297
|
+
##### **clear(item)** => `void`
|
|
268
298
|
|
|
269
299
|
This method clears an `item` content.
|
|
270
300
|
|
|
@@ -282,10 +312,10 @@ The class constructor receives an arguments listed below:
|
|
|
282
312
|
|
|
283
313
|
|parameter name|value type|default value|description|
|
|
284
314
|
|:---|---|---:|:---|
|
|
285
|
-
|`object
|
|
315
|
+
|`object`|`array`|---|a host object of an array type.|
|
|
286
316
|
|`options`|`object`|---|an options settings.|
|
|
287
317
|
|
|
288
|
-
|
|
318
|
+
###### `options` parameter
|
|
289
319
|
|
|
290
320
|
The `options` structure is listed below:
|
|
291
321
|
|
|
@@ -295,6 +325,10 @@ The `options` structure is listed below:
|
|
|
295
325
|
|`isNullItemsAllowed`|`boolean`|`false`|<*reserved*>|
|
|
296
326
|
|`parseOptions`|`object`|`EMPTY_OBJECT`|contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`)|
|
|
297
327
|
|
|
328
|
+
##### exceptions
|
|
329
|
+
|
|
330
|
+
If `object` parameter is not a type of `array` or not given a `TypeError` may be thrown in case if a `proxyModeEnable` options is set.
|
|
331
|
+
|
|
298
332
|
#### class properties
|
|
299
333
|
|
|
300
334
|
|property name|property type|read only|description|
|
|
@@ -306,47 +340,47 @@ The `options` structure is listed below:
|
|
|
306
340
|
|
|
307
341
|
#### class methods
|
|
308
342
|
|
|
309
|
-
##### **clear()**
|
|
343
|
+
##### **clear()** => `void`
|
|
310
344
|
|
|
311
345
|
This method clears a list.
|
|
312
346
|
|
|
313
|
-
##### **isEmpty()**
|
|
347
|
+
##### **isEmpty()** => `boolean`
|
|
314
348
|
|
|
315
349
|
This method returns `true` if a list has no elements and `false` otherwise.
|
|
316
350
|
|
|
317
|
-
##### **isNotEmpty()**
|
|
351
|
+
##### **isNotEmpty()** => `boolean`
|
|
318
352
|
|
|
319
353
|
This method returns `true` if a list contains at least one element and `false` otherwise.
|
|
320
354
|
|
|
321
|
-
##### **chkIndex(index)**
|
|
355
|
+
##### **chkIndex(index)** => `boolean`
|
|
322
356
|
|
|
323
357
|
This method checks if a given index fits a range of elements within the list. If so `true` is returned.
|
|
324
358
|
|
|
325
|
-
##### **isValidItem(obj)**
|
|
359
|
+
##### **isValidItem(obj)** => `boolean`
|
|
326
360
|
|
|
327
361
|
This method checks whether or not a given element is valid.
|
|
328
362
|
|
|
329
|
-
##### **getItem(index)**
|
|
363
|
+
##### **getItem(index)** => `?TXmlElementController`
|
|
330
364
|
|
|
331
365
|
This method returns an element addressed by `index`. If failed `null` is returned.
|
|
332
366
|
|
|
333
|
-
##### **addItem(obj)**
|
|
367
|
+
##### **addItem(obj)** => `index`
|
|
334
368
|
|
|
335
369
|
This method adds an element to a list members. If succeed an index of the element is returned.
|
|
336
370
|
|
|
337
|
-
##### **setItem(index, obj)**
|
|
371
|
+
##### **setItem(index, obj)** => `boolean`
|
|
338
372
|
|
|
339
373
|
This method replaces an element addressed by `index` with a new element. If succeed `true` is returned.
|
|
340
374
|
|
|
341
|
-
##### **insItem(index, obj)**
|
|
375
|
+
##### **insItem(index, obj)** => `boolean`
|
|
342
376
|
|
|
343
377
|
This method inserts an element in the position addressed by `index`. If succeed `true` is returned.
|
|
344
378
|
|
|
345
|
-
##### **delItem(index)**
|
|
379
|
+
##### **delItem(index)** => `boolean`
|
|
346
380
|
|
|
347
381
|
This method deletes an element addressed by `index`. If succeed `true` is returned.
|
|
348
382
|
|
|
349
|
-
##### **loadItems(items, options)**
|
|
383
|
+
##### **loadItems(items, options)** => `number`
|
|
350
384
|
|
|
351
385
|
This method loaded a list of elements listed by `items` and returns a quantity of a successfully added elements.
|
|
352
386
|
|
|
@@ -391,7 +425,7 @@ The class constructor receives an arguments listed below:
|
|
|
391
425
|
|`object`|`object`|---|a host object for the document content.|
|
|
392
426
|
|`options`|`object`|---|an options settings.|
|
|
393
427
|
|
|
394
|
-
|
|
428
|
+
###### `options` parameter
|
|
395
429
|
|
|
396
430
|
The `options` structure is listed below:
|
|
397
431
|
|
|
@@ -399,6 +433,10 @@ The `options` structure is listed below:
|
|
|
399
433
|
|:---|---|---:|:---|
|
|
400
434
|
|`parseOptions`|`object`|`EMPTY_OBJECT`|contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`)|
|
|
401
435
|
|
|
436
|
+
##### exceptions
|
|
437
|
+
|
|
438
|
+
If `object` parameter is not a type of `object` or not given a `TypeError` thrown.
|
|
439
|
+
|
|
402
440
|
#### class properties
|
|
403
441
|
|
|
404
442
|
|property name|property type|read only|description|
|
|
@@ -408,7 +446,7 @@ The `options` structure is listed below:
|
|
|
408
446
|
|
|
409
447
|
#### class methods (*special*)
|
|
410
448
|
|
|
411
|
-
##### **init()**
|
|
449
|
+
##### **init()** => `boolean`
|
|
412
450
|
|
|
413
451
|
This method initializes an element with a default values.
|
|
414
452
|
|
|
@@ -429,7 +467,7 @@ The class constructor receives an arguments listed below:
|
|
|
429
467
|
|`object`|`object`|---|a host object for the document content|
|
|
430
468
|
|`options`|`object`|---|an options settings|
|
|
431
469
|
|
|
432
|
-
|
|
470
|
+
###### `options` parameter
|
|
433
471
|
|
|
434
472
|
The `options` structure is listed below:
|
|
435
473
|
|
|
@@ -469,7 +507,7 @@ The class constructor creates a new instance of the class.
|
|
|
469
507
|
|
|
470
508
|
The class constructor receives an `options` parameter as its argument.
|
|
471
509
|
|
|
472
|
-
|
|
510
|
+
###### `options` parameter
|
|
473
511
|
|
|
474
512
|
The `options` structure is listed below:
|
|
475
513
|
|
|
@@ -489,11 +527,11 @@ The `options` structure is listed below:
|
|
|
489
527
|
|
|
490
528
|
#### class methods
|
|
491
529
|
|
|
492
|
-
##### **clear()**
|
|
530
|
+
##### **clear()** => `void`
|
|
493
531
|
|
|
494
532
|
This method clears a document content.
|
|
495
533
|
|
|
496
|
-
##### **saveToXMLString()**
|
|
534
|
+
##### **saveToXMLString()** => `string`
|
|
497
535
|
|
|
498
536
|
This method returns a document content as a string.
|
|
499
537
|
|
|
@@ -501,7 +539,7 @@ This method returns a document content as a string.
|
|
|
501
539
|
|
|
502
540
|
This method saves a document content into a file addressed by `src`.
|
|
503
541
|
|
|
504
|
-
##### **loadFromXMLString(str)**
|
|
542
|
+
##### **loadFromXMLString(str)** => `boolean`
|
|
505
543
|
|
|
506
544
|
This method loads a document content from a string given by `str`.
|
|
507
545
|
|