|
1 | | -Node-LibXML |
2 | | -========== |
3 | | - |
| 1 | +# Node-LibXML |
4 | 2 |
|
5 | 3 | #### For old node.js versions please use verison < 4.0.0 Already for old LTS node (4,6,8) `npm install [email protected]`; |
6 | | -#### For new node.js versions (10,12,14) we are using n-api so please install `npm install [email protected]` (4.0.0 is not working) |
7 | 4 |
|
| 5 | +#### For new node.js versions (10,12,14,16,18,20) we are using n-api so please install `npm install [email protected]`, its compatible with arm proc too for version >= 16 (you wil notice a free memoery message when using free memory function after node >16) 🙂 |
8 | 6 |
|
9 | | -Node-Libxml is a LibXML2 Node.js Wrapper |
| 7 | +Node-Libxml is a LibXML2 Node.js Wrapper |
10 | 8 |
|
11 | | -It can perform: |
| 9 | +It can perform: |
12 | 10 |
|
13 | 11 | - Wellformed check & rerror report |
14 | | -- Validity against DTD/XSD(Schema) check, |
| 12 | +- Validity against DTD/XSD(Schema) check, |
15 | 13 | - Get doctype informations (about dtd) |
16 | 14 | - GetXpath Values |
17 | 15 | - Load XMl from string or file path |
18 | 16 |
|
19 | | -## Requirements: |
| 17 | +## Requirements: |
20 | 18 |
|
21 | 19 | Node-Libxml has nos any dependencies, it's fully bundled, so you can just use it as it comes :) |
22 | 20 |
|
23 | | -Works on : Linux, Osx & Windows (no 32bits, **just 64 bits**) |
24 | | -## Why use it |
| 21 | +Works on : Linux, Osx & Windows (no 32bits, **just 64 bits**) |
| 22 | + |
| 23 | +## Why use it |
| 24 | + |
25 | 25 | Node-libxml has been thought differently than [libxmljs](https://github.com/libxmljs/libxmljs); whereas libxmljs can be use in commun uses, you can use node-libxml if: |
| 26 | + |
26 | 27 | - You wan to validate against DTD (libxmljs can't) |
27 | 28 | - You want a silent program if xml is not wellformed (node-libxml returns wellformed error in object; libxmljs throws) |
28 | 29 | - You want to do xml processing in parallel forks |
29 | 30 | - You want to load XML from file path OR string |
30 | 31 | - You want to validate against DTD / schema on multiple documents with just ONE dtd/schema loaded in memory (libxmljs loads it on each validation request), so it's clearly by far fastest! |
31 | 32 |
|
32 | | - |
33 | 33 | ## Install |
34 | 34 |
|
35 | 35 | ```bash |
@@ -62,110 +62,108 @@ Node-libxml has been thought differently than [libxmljs](https://github.com/libx |
62 | 62 | //... & all xpath could do I think |
63 | 63 | ``` |
64 | 64 |
|
65 | | -check [tests](./test/libxml-test.js) for more examples |
66 | | - |
| 65 | +check [tests](./test/libxml-test.js) for more examples |
67 | 66 |
|
68 | 67 | ## API |
69 | 68 |
|
70 | | - |
71 | 69 | ### Loading functions |
72 | 70 |
|
73 | | - |
74 | | - |
75 | 71 | ##### loadXml(string) |
| 72 | + |
76 | 73 | A function of libxml to load the XML file |
77 | 74 | `TAKE a path & RETURN true if wellformed | false if not` |
78 | 75 | `SET a an array 'wellformedErrors' in libxml element containing wellformed errors` |
79 | 76 |
|
80 | 77 | ##### loadXmlFromString(string) |
| 78 | + |
81 | 79 | A function of libxml to create the xml Dom from a string |
82 | 80 | `TAKE a string containing xml & RETURN true if wellformed | false if not` |
83 | 81 | `SET a an array 'wellformedErrors' in libxml element containing wellformed errors` |
84 | 82 |
|
85 | | - |
86 | 83 | ##### loadDtds(array) |
| 84 | + |
87 | 85 | A function of libxml to load the DTDs files |
88 | 86 | `TAKE an array of path of & RETURN nothing` |
89 | 87 | `SET a an array 'dtdsLoadedErrors' in libxml element IF error happend on loading dtd(s)` |
90 | 88 |
|
91 | | - |
92 | 89 | ##### loadSchemas(array) |
| 90 | + |
93 | 91 | A function of libxml to load the XSDs files |
94 | 92 | `TAKE an array of path of & RETURN nothing` |
95 | 93 | `SET a an array 'schemasLoadedErrors' in libxml element IF error happend on loading xsd(s)` |
96 | 94 | [ex](./test/libxml-test.js#L157) |
97 | 95 |
|
98 | | - |
99 | 96 | ### Validating functions |
100 | 97 |
|
101 | | - |
102 | 98 | ##### validateAgainstDtd() |
| 99 | + |
103 | 100 | A function of libxml to validate against the previously loaded DTD(s) |
104 | 101 | `TAKE nothing & RETURN a string which is the name of the first dtd which has validated` |
105 | 102 | `RETURN false if no dtd(s) have validate the xml` |
106 | 103 | `RETURN null if no any dtd have been corectly loaded` |
107 | 104 | `SET a an array 'validationDtdErrors' in libxml element if no dtd has validate` |
108 | 105 |
|
109 | 106 | ##### validateAgainstSchemas() |
| 107 | + |
110 | 108 | A function of libxml to validate against the previously loaded DTD(s) |
111 | 109 | `TAKE nothing & RETURN a string which is the name of the first dtd which has validated` |
112 | 110 | `RETURN false if no dtd(s) have validate the xml` |
113 | 111 | `RETURN null if no any schema have been corectly loaded` |
114 | 112 | `SET a an array 'validationDtdErrors' in libxml element if no dtd has validate` |
115 | 113 |
|
116 | | - |
117 | 114 | ### Get informations of the the XML |
118 | 115 |
|
119 | | - |
120 | 116 | #### getDtd() |
| 117 | + |
121 | 118 | A function of libxml to evaluate the xpath on the previously loaded XML |
122 | 119 | `TAKE nothin & RETURN an object containing name,externalId & systemId` |
123 | 120 |
|
124 | | - |
125 | 121 | #### xpathSelect(string) |
| 122 | + |
126 | 123 | A function of libxml to evaluate the xpath on the previously loaded XML |
127 | 124 | `TAKE string & RETURN value depending on what you asked (number, boolean..)` |
128 | 125 | `RETURN null if no match` |
129 | 126 | [ex](./test/libxml-test.js#L69) |
130 | 127 |
|
131 | | - |
132 | 128 | ### Memory management |
| 129 | + |
133 | 130 | Use those functions when you have finished jobs of elements, or before overwrite them. |
134 | 131 | [ex](./test/libxml-test.js#100) |
135 | 132 |
|
136 | | - |
137 | 133 | ##### freeXml() |
| 134 | + |
138 | 135 | A function of libxml to free XML memory file |
139 | 136 | `TAKE nothing & RETURN nothin` |
140 | 137 | `FREE memory & clear 'wellformedErrors' property on libxml instance` |
141 | 138 |
|
142 | | - |
143 | 139 | ##### freeDtds() |
| 140 | + |
144 | 141 | A function of libxml to free all the DTD in memory |
145 | 142 | `TAKE nothing & RETURN nothin` |
146 | 143 | `FREE memory & clear 'dtdsLoadedErrors' property on libxml instance` |
147 | 144 | `FREE memory & clear 'validationDtdErrors' property on libxml instance` |
148 | 145 |
|
149 | | - |
150 | 146 | ##### freeSchemas() |
| 147 | + |
151 | 148 | A function of libxml to free all the Schema in memory |
152 | 149 | `TAKE nothing & RETURN nothin` |
153 | 150 | `FREE memory & clear 'schemasLoadedErrors' property on libxml instance` |
154 | 151 | `FREE memory & clear 'validationSchemaErrors' property on libxml instance` |
155 | 152 |
|
156 | | - |
157 | 153 | ##### clearAll() |
| 154 | + |
158 | 155 | A function of libxml to free all the memory taken by libxml2 |
159 | 156 | `TAKE nothing & RETURN nothin` |
160 | 157 | free all memory in all instance in all fork using by libxml. |
161 | 158 |
|
162 | | - |
163 | 159 | ## Contribute |
164 | 160 |
|
165 | 161 | ### Install |
| 162 | + |
166 | 163 | - `npm i` |
167 | | -- then move the build-tmp-napi-*{anyversionyougot} as -> `mv build-tmp-napi-v7 build` __(for the moment I did not found how to build directly to buiuld forlder with pre-gyp for n-api)__ |
168 | 164 | - `npm test` should pass 😎 |
| 165 | +- `npm run publish` |
169 | 166 |
|
170 | 167 | ## Important notes |
| 168 | + |
171 | 169 | Travis & appveyor cannot be used anymore with n-api because auto-publish from node-pre-gyp-github not working anymore + we have now n release for one node version |
0 commit comments