xml-toolkit 1.1.0 → 1.1.1

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/lib/XMLParser.js CHANGED
@@ -84,7 +84,7 @@ const XMLParser = class {
84
84
  this.element = node
85
85
  if (this.document === null) {
86
86
  this.document = node
87
- if (this.xs !== null) this.validator = new XMLValidatior (this.xs, node, () => nodes.pos)
87
+ if (this.xs !== null) this.validator = new XMLValidatior (this.xs, node, () => BigInt (nodes.pos))
88
88
  }
89
89
  else {
90
90
  if (this.xs !== null) this.validator.startElement (node)
package/lib/XSAnyType.js CHANGED
@@ -37,7 +37,7 @@ module.exports = class {
37
37
 
38
38
  this.elements = this.#parent.elements.concat (this.elements)
39
39
 
40
- this.content = new Occurable ([this.#parent.content, this.content])
40
+ this.content = new Occurable ([this.#parent.content, this.content].filter (Boolean))
41
41
 
42
42
  }
43
43
 
@@ -15,7 +15,7 @@ class XMLValidationState {
15
15
  }
16
16
  catch (cause) {
17
17
 
18
- throw Error (`Validation problem with ${parsedNode.src} at position ${this.getPosition ()}: ${cause.message}`, {cause})
18
+ throw Error (`Validation problem with ${this.formatPosition (parsedNode)}: ${cause.message}`, {cause})
19
19
 
20
20
  }
21
21
 
@@ -47,13 +47,19 @@ class XMLValidationState {
47
47
 
48
48
  }
49
49
 
50
+ formatPosition ({src}) {
51
+
52
+ const pos = String (this.getPosition () - BigInt (src.length))
53
+
54
+ return `${src} at position ${pos}`
55
+
56
+ }
57
+
50
58
  blameUnexpectedTag (parsedNode, match) {
51
59
 
52
60
  const expected = match.allExpected (parsedNode); if (expected == null) this.blameNothingExpected ()
53
61
 
54
- const {src} = parsedNode, {length} = src
55
-
56
- throw Error (`Unexpected ${src} at position ${BigInt (this.getPosition ()) - BigInt (length)}, expected: ${expected}`)
62
+ throw Error (`Unexpected ${this.formatPosition (parsedNode)}, expected: ${expected}`)
57
63
 
58
64
  }
59
65
 
@@ -101,8 +107,8 @@ class XMLValidationState {
101
107
 
102
108
  }
103
109
  catch (cause) {
104
-
105
- throw Error (`Validation problem with the contents of <${this.parsedNode.name}...> at position ${this.getPosition ()}: ${cause.message}`, {cause})
110
+
111
+ throw Error (`Validation problem with the contents of ${this.formatPosition (this.parsedNode)}: ${cause.message}`, {cause})
106
112
 
107
113
  }
108
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-toolkit",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "XML parser, marshaller, SOAP adapter",
5
5
  "main": "index.js",
6
6
  "files": [