Debian Codegraph @

CHANGELOG.md

raw symbols SCIP
1 # Change Log
2
3 ## [0.3.14] (2026-06-21)
4
5 ### Changed
6
7 * `Node::node_ptr_mut` now guards mutable access with
8 `RefCell::try_borrow_mut` instead of the
9 `Rc::strong_count <= NODE_RC_MAX_GUARD` heuristic. It returns `Err` **only**
10 when the node's cell is *actively* borrowed (a genuine re-entrant aliasing
11 conflict on the same wrapped node); a high `Rc::strong_count` from benign
12 `Node` clones — the owning document's node cache plus caller-held handles —
13 no longer blocks mutation. All clones share one `RefCell`, so
14 `try_borrow_mut` is exactly the per-node exclusion check; the old proxy both
15 false-positived on benign clones and could panic via `borrow_mut` on the very
16 conflict it was meant to catch.
17
18 ### Fixed
19
20 * Spurious `Can not mutably reference a shared Node` errors when mutating a node
21 that merely has several live clones (e.g. large or heavily-shared trees, or
22 any node also held in a caller-side cache). Such mutations now succeed; the
23 error is reserved for real active-borrow re-entrancy.
24
25 ### Deprecated
26
27 * `NODE_RC_MAX_GUARD` and `set_node_rc_guard` are now no-ops, retained only for
28 API compatibility. The strong-count threshold they tuned is no longer
29 consulted by `node_ptr_mut`.
30
31 ## [0.3.13] (2026-06-11)
32
33 ### Added
34
35 * Opt-in **static linking** of libxml2. Set the `LIBXML2_STATIC` environment
36 variable and `build.rs` probes via pkg-config with `.statik(true)`,
37 emitting `cargo:rustc-link-lib=static=xml2` (plus the transitive `-lm`).
38 Point `PKG_CONFIG_PATH` at a non-system prefix holding a PIC `libxml2.a`
39 to get a binary with no runtime `libxml2.so` dependency — independent of
40 the host's libxml2 SONAME, which bumped `.so.2` → `.so.16` at libxml2 2.14.
41 Unset (the default) is unchanged: a normal dynamic link against the host
42 libxml2.
43 * New cargo features **`runtime`** (default) and **`static`** that select how
44 bindgen locates libclang to generate the FFI bindings at build time.
45 `cargo build --no-default-features --features static` routes bindgen to
46 `clang-sys/static`, enabling fully static / musl / Alpine builds where a
47 runtime `dlopen` of libclang is unavailable. Together with `LIBXML2_STATIC`,
48 this resolves [#110](https://github.com/KWARC/rust-libxml/issues/110).
49
50 ## [0.3.12] (2026-05-23)
51
52 ### Added
53
54 * New `io` module: `io::register_input_callback(match_url, open)` is
55 a safe wrapper around `xmlRegisterInputCallbacks`. Accepts two
56 closures (`&str -> bool`, `&str -> Option<Vec<u8>>`) and installs
57 them as a custom URL-scheme handler. The intended use is bundling
58 XSLT stylesheets / RNG schemas via `include_bytes!` and serving
59 them through a synthetic scheme (e.g. `embed:///foo.xsl`), so
60 libxslt's `xsl:import` resolution can reach the embedded bytes
61 without touching the disk. Closures may run on any thread libxml2
62 calls them from (`Send + Sync + 'static`).
63
64 ## [0.3.11] (2026-05-18)
65
66 ### Added
67
68 * `Document::remove_internal_subset`, a safe wrapper around
69 `xmlGetIntSubset` + `xmlUnlinkNode` + `xmlFreeDtd`. Mirrors
70 XML::LibXML's `Document::removeInternalSubset` (Perl): drops the
71 internal DTD node so subsequent serialisation no longer emits the
72 `<!DOCTYPE …>` preamble. Idempotent, safe on doctype-less
73 documents.
74
75 ### Changes
76
77 * Whole-crate clippy pass: `cargo clippy --fix --all-targets` plus
78 manual touch-ups so the workspace builds warning-free on the
79 current stable.
80 * Added an arm64 build/test job to `.github/workflows/CI.yml`
81 (thanks @wetneb).
82
83 ### Fixed
84
85 * Test suite portability on ARM64 — switched to portable types in
86 `tests/xml_copy_invariant_tests.rs` so the cross-platform CI run
87 passes alongside x86_64 (thanks @wetneb).
88
89 ## [0.3.10] (2026-05-09)
90
91 ### Added
92
93 * `Node::set_rust_owned` / `Node::is_rust_owned` (and `RoNode::is_rust_owned`)
94 for explicit ownership transfer of detached subtrees. Lets callers reclaim
95 unlinked nodes that would otherwise leak.
96 * `Document::dup_node_into_new_doc` — deep-copy a subtree into a fresh
97 independent document. Works around `xmlDocCopyNode` returning NULL on
98 repeated extraction within one source document.
99
100 ### Fixed
101
102 * `_Node::Drop` no longer fires `xmlFreeNode` against memory the source
103 document still owns. Internally backed by a 3-variant `Linkage` enum
104 (`Linked` / `Unlinked` / `RustOwned`) replacing the prior `unlinked: bool`.
105 * `Document::import_node` now rejects `RustOwned` source nodes.
106
107 ## [0.3.9] (2026-04-22)
108
109 ### Added
110
111 * `Node::new_comment` constructor, wrapping `xmlNewDocComment`. Returns an
112 unlinked comment node bound to the given document; propagates an error
113 rather than panicking on embedded NULs.
114 * `libxml::init_parser()`, a top-level safe wrapper around
115 `xmlInitParser()` guarded by `std::sync::Once`. Useful for application
116 code that touches libxml2 directly without going through `parser::Parser`.
117
118 ### Changes
119
120 * `Parser::default()` and `Parser::default_html()` now route through
121 `libxml::init_parser()` instead of their own private `Once`, giving a
122 single source of truth for libxml2 parser initialisation.
123
124 ## [0.3.8] (2025-25-09)
125
126 ### Changes
127
128 * Corrected the vcpkg include directories used during build
129
130 ## [0.3.7] (2025-18-08)
131
132 ### Changes
133
134 * Corrected the bindgen configuration for c14n, thanks to @Qubitza
135
136 ## [0.3.6] (2025-13-07)
137
138 ### Added
139
140 * c14n, thanks to @saks and @tstenner
141 * add `canonicalize` method for `Node` and `Document`
142 * see `tests/c14n.rs` for examples
143 * Utility node methods, thanks to @saks (nokogiri inspired)
144 * add `Node::ancestors` method
145 * add `Node::at_xpath` method. Similar to `findnodes` but nokogiri inspired.
146
147 This work still hasn't been extended to `RoNode`, contributions welcome.
148
149 ### Changes
150
151 * Added more low-level headers from bindgen for wrapper uses interested in unsafe low-level libxml2 calls.
152 The bindgen coverage has been in flux since the v0.3.4 release, as we stabilize the new build approach.
153
154 ### Removed
155
156 ## [0.3.5] (2025-28-04)
157
158 This release stabilizes the new "bindgen during build" approach of v0.3.4 to more platforms.
159
160 Support for newer libxml2 versions has been improved.
161 - CI support for v2.12.9, v2.13.8, v2.14.1
162
163 Thanks go to @wetneb and @charmitro for contributing.
164
165 ### Added
166
167 * cargo build: expose libxml2 version to main build script;
168 * creating a new `Parser` now initializes via `bindings::xmlInitParser`, called at most once.
169
170 ### Changes
171
172 * cargo build: mark `max_align_t` as opaque to fix i386 build failure
173 * cfg: adapt mutability of error pointer depending on libxml version
174 * change the return type of `xmlGetNodeType` from `u32` to the more portable `bindings::xmlElementType`
175 * change the argument type of `NodeType::from_int` from `u32` to the more portable `bindings::xmlElementType`
176 * protect `Schema` initialization to be closer to thread-safe (note that this wrapper is NOT thread-safe in general)
177
178 ### Removed
179 * The use of `SchemaParserContext` and `SchemaValidationContext` is currently NOT thread safe.
180 Hence, The `schema_test` has been weakened to run in a single thread (future improvements welcome).
181
182 ## [0.3.4] (2025-16-04)
183
184 Thanks go to @wetneb, @anwaralameddin, @rudolphfroger, @jcamiel, @imcsk8 for contributions to this release.
185
186 ### Added
187
188 * Node methods: `get_property_no_ns` (alias: `get_attribute_no_ns`), `get_properties_ns` (alias: `get_attributes_ns`), `has_property_no_ns` (alias: `has_attribute_no_ns`), `remove_property_no_ns` (alias: `remove_attribute_no_ns`), `get_property_node_ns` (alias: `get_attribute_node_ns`), `get_property_node_no_ns` (alias: `get_attribute_node_no_ns`)
189 * Added implementations of `Hash`, `PartialEq` and `Eq` traits for `Namespace`
190
191 ### Changed
192
193 * Call bindgen at build time on Unix platforms (thanks @wetneb)
194
195 ## [0.3.3] 2023-17-07
196
197 ### Changed
198
199 * Update the implementation of `StructuredError` so that all validation errors are returned from the validation methods present on `SchemaValidationContext`. Previously, all returned validation errors were identical due to libxml reusing a global memory address for all reported errors. Thanks @JDSeiler !
200 * The `message` method of `StructuredError` has been deprecated.
201
202 ## [0.3.2] 2023-07-05
203
204 ### Added
205
206 * XPath: `Context::findvalues`, with optional node-bound evaluation, obtaining `String` values.
207
208 * `Node::findvalues` method for direct XPath search obtaining `String` values, without first explicitly instantiating a `Context`. Reusing a `Context` remains more efficient.
209
210 ## [0.3.1] 2022-26-03
211
212 * Added: Thanks to @lepapareil, @hurlenko and @ballsteve for contributing installation docs for Windows and MacOS.
213 * Added: `Node` and `RoNode` now have `has_property` (alias `has_attribute`) and `has_property_ns` (alias `has_attribute_ns`) to check attribute presence without allocating the value.
214 * Added: `xpath::is_well_formed_xpath`, thanks @bcpeinhardt !
215
216 ## [0.3.0] 2021-27-05
217
218 * Change `Parser::parse_file/string_with_encoding` to `Parser::parse_file/string_with_options`.
219
220 * Introduce `ParserOptions` which encapsulates the forced encoding setting together with libxml2s HTML and XML parser options.
221
222 * For systems without a pkg-config capability, we now use the `LIBXML2` environment variable to detect an installed libxml2 toolchain. (thanks @przygienda !)
223
224 ## [0.2.16] 2021-31-01
225
226 ### Added
227
228 * More element-oriented methods: `get_next_element_sibling`, `get_prev_element_sibling`, `get_last_element_child`, added to both `Node` and `RoNode`.
229 * `Document::ronode_to_string` for printing read-only nodes
230 * `RoNode::node_ptr` for getting the internal libxml2 raw pointer of a read-only node
231
232 ## [0.2.15] 2020-28-09
233
234 Thanks to @JoshuaNitschke for contributing OS-based package detection for the native libxml2! Also thanks to @coding-yogi, @ignatenkobrain and @simoin for investigating platform-specific issues with this crate, some of which expect resolution in upcoming versions.
235
236 ### Added
237
238 * Support for x64-Windows use via the vcpkg package manager (with new CI monitoring via appveyor).
239
240 ### Changed
241
242 * Added back an `Error` trait implementation for `XmlParseError`
243
244 ### Removed
245
246 * Dropped a large number of memory layout tests that were auto-generated by bindgen, until we have a more sophisticated test-generation setup that can enforce multiple architectures. Ideally this has no day-to-day impact and just makes portability easier in the short-term.
247
248 ## [0.2.14] 2020-27-03
249
250 ### Changed
251
252 More consistently use `c_char` to successfully compile on ARM targets
253
254 ## [0.2.13] 2020-16-01
255
256 Thanks to @jangernert for the upgrades to `Document` serialization.
257 Thanks to @lweberk for contributing the `Schema` featureset and to @cbarber for refining the FFI interop.
258
259 ### Added
260
261 * `Document::to_string_with_options` allowing to customize document serialization
262 * `Document::SaveOptions` containing the currently supported serialization options, as provided internally by libxml
263 * `Schema` holding and managing `xmlSchemaPtr` as created while parsing by `SchemaParserContext`
264 * `SchemaParserContext` holding source of XSD and parsing into a `Schema` while gathering and –in case returning– errors that arise from the XSD parser across the FFI to libxml
265 * `SchemaValidationContext` holding the `Schema` from resulting `SchemaParserContext` parse and offering validation methods for `Document`, `Node` or file path to XML, while gathering and –in case returning– validation errors from the XML validator across the FFI to libxml
266
267 ### Changed
268
269 * the `Document::to_string()` serialization method is now implemented through `fmt::Display` and no longer takes an optional boolean flag. The default behavior is now unformatted serialization - previously `to_string(false)`, while `to_string(true)` can be realized via
270
271 ```
272 .to_string_with_options(SaveOptions { format: true, ..SaveOptions::default()})`
273 ```
274
275 ## [0.2.12] 2019-16-06
276
277 Thanks to @Alexhuszagh for contributing all enhancements for the `0.2.12` release!
278
279 ### Added
280
281 * BOM-aware Unicode support
282 * New `Parser` methods allowing to specify an explicit encoding: `parse_file_with_encoding`, `parse_string_with_encoding`, `is_well_formed_html_with_encoding`
283
284 ### Changed
285
286 * Default encodings in `Parser` are now left for libxml to guess internally, rather than defaulted to `utf-8`.
287
288 ## [0.2.11] 2019-15-04
289
290 ### Added
291
292 * `RoNode::to_hashable` and `RoNode::null` for parity with existing `Node`-leveraging applications
293
294 ## [0.2.10] 2019-14-04
295
296 ### Added
297
298 * `RoNode` primitive for simple and efficient **read-only** parallel processing
299 * Benchmarking a 120 MB XML document shows a twenty five fold speedup, when comparing `Node` to parallel rayon processing over `RoNode` with a 32 logical core desktop
300 * While `RoNode` is added as an experiment for high performance read-only scans, any mutability requires using `Node` and incurring a bookkeeping cost of safety at runtime.
301 * Introduced benchmarking via `criterion`, only installed during development.
302 * `benches/parsing_benchmarks` contains examples of parallel scanning via `rayon` iterators.
303 * added `Document::get_root_readonly` method for obtaining a `RoNode` root.
304 * added `Context::node_evaluate_readonly` method for searching over a `RoNode`
305 * added `Context::get_readonly_nodes_as_vec` method for collecting xpath results as `RoNode`
306
307 ## [0.2.9] 2019-28-03
308
309 * Squash memory leak in creating new `Node`s from the Rust API
310 * Safely unlink `Node`s obtained via XPath searches
311
312 ## [0.2.8] 2019-25-03
313
314 ### Changed
315
316 Minor internal changes to make the crate compile more reliably under MacOS, and other platforms which enable the `LIBXML_THREAD_ENABLED` compile-time flag. Thank you @caldwell !
317
318 ## [0.2.7] 2019-09-03
319
320 ### Added
321
322 * implement and test `replace_child_node` for element nodes
323
324 ## [0.2.6] 2018-07-12
325
326 * Internal update to Rust 2018 Edition
327 * fix deallocation bugs with `.import_node()` and `.get_namespaces()`
328
329 ## [0.2.5] 2018-26-09
330
331 ### Added
332
333 * `Node::null` placeholder that avoids the tricky memory management of `Node::mock` that can lead to memory leaks. Really a poor substitute for the better `Option<Node>` type with a `None` value, which is **recommended** instead.
334
335 ## [0.2.4] 2018-24-09
336
337 ### Added
338
339 * `Context::from_node` method for convenient XPath context initialization via a Node object. Possible as nodes keep a reference to their owner `Document` object.
340
341 ### Changed
342
343 * Ensured memory safety of cloning xpath `Context` objects
344 * Switched to using `Weak` references to the owner document, in `Node`, `Context` and `Object`, to prevent memory leaks in mutli-document pipelines.
345 * Speedup to XPath node retrieval
346
347 ## [0.2.3] 2018-19-09
348
349 ### Added
350
351 * `Node::findnodes` method for direct XPath search, without first explicitly instantiating a `Context`. Reusing a `Context` remains more efficient.
352
353 ## [0.2.2] 2018-23-07
354
355 * Expose the underlying `libxml2` data structures in the public crate interface, to enable a first [libxslt](https://crates.io/crates/libxslt) crate proof of concept.
356
357 ## [0.2.1] 2018-23-07
358
359 ### Added
360
361 * `Node::set_node_rc_guard` which allows customizing the reference-count mutability threshold for Nodes.
362 * serialization tests for `Document`
363 * (crate internal) full set of libxml2 bindings as produced via `bindgen` (see #39)
364 * (crate internal) using libxml2's type language in the wrapper Rust modules
365 * (crate internal) setup bindings for reuse in higher-level crates, such as libxslt
366
367 ### Changed
368
369 * `NodeType::from_c_int` renamed to `NodeType::from_int`, now accepting a `u32` argument
370
371 ### Removed
372
373 * Removed dependence on custom C code; also removed gcc from build dependencies
374
375 ## [0.2.0] 2018-19-07
376
377 This release adds fundamental breaking changes to the API. The API continues to be considered unstable until the `1.0.0` release.
378
379 ### Added
380
381 * `dup` and `dup_from` methods for deeply duplicating a libxml2 document
382 * `is_unlinked` for quick check if a `Node` has been unlinked from a parent
383
384 ### Changed
385
386 * safe API for `Node`s and `Document`s, with automatic pointer bookkeeping and memory deallocation, by @triptec
387 * `Node`s are now bookkept by their owning document
388 * libxml2 low-level memory deallocation is postponed until the `Document` is dropped, with the exception of unlinked nodes, who are deallocated on drop.
389 * `Document::get_root_element` now has an option type, and returns `None` for an empty Document
390 * `Node::mock` now takes owner `Document` as argument
391 * proofed tests with `valgrind` and removed all obvious memory leaks
392 * All node operations that modify a `Node` now both require a `&mut Node` argument and return a `Result` type.
393 * Full list of changed signatures in Node: `remove_attribute`, `remove_property`, `set_name`, `set_content`, `set_property`, `set_property_ns`, `set_attribute`, `set_attribute_ns`, `remove_attribute`, `set_namespace`, `recursively_remove_namespaces`, `append_text`
394 * Tree transforming operations that use operate on `&mut self`, and no longer return a Node if the return value is identical to the argument.
395 * Changed signatures: `add_child`, `add_prev_sibling`, `add_next_sibling`
396 * `Result` types should always be checked for errors, as mutability conflicts are reported during runtime.
397
398 ### Removed
399
400 * `global` module, which attempted to manage global libxml state for threaded workflows. May be readed after the API stabilizes
401
402 ## [0.1.2] 2018-12-01
403
404 * We welcome Andreas (@triptec) to the core developer team!
405
406 ### Added
407
408 * Workaround `.free` method for freeing nodes, until the `Rc<RefCell<_Node>>` free-on-drop solution by Andreas is introduced in 0.2
409
410 ## [0.1.1] 2017-18-12
411
412 ### Added
413
414 * `get_first_element_child` - similar to `get_first_child` but only returns XML Elements
415 * `is_element_node` - check if a given `Node` is an XML Element
416
417 ### Changed
418
419 * Requiring owned `Node` function arguments only when consumed - `add_*` methods largely take `&Node` now.
420
421 ## [0.1.0] 2017-09-11
422
423 Pushing up release to a 0.1, as contributor interest is starting to pick up, and the 0. version were getting a bit silly/wrong.
424
425 ### Added
426
427 * Node methods: `unbind_node`, `recursively_remove_namespaces`, `set_name`,
428 * Document methods: `import_node`
429
430 ### Changed
431
432 * Updated gcc build to newer incantation, upped dependency version.
433
434 ## [0.0.75] 2017-04-06
435
436 ### Added
437
438 * Node methods: `get_namespace_declarations`, `get_property_ns` (alias: `get_attribute_ns`), `remove_property` (alias: `remove_attribute`), `get_attribute_node`, `get_namespace`, `lookup_namespace_prefix`, `lookup_namespace_uri`
439
440 * XPath methods: `findvalue` and `findnodes`, with optional node-bound evaluation.
441
442 ### Changed
443
444 * The Node setter for a namespaced attribute is now `set_property_ns` (alias: `set_attribute_ns`)
445 * Node set_* methods are now consistently defined on `&mut self`
446 * Refactored wrongly used `url` to `href` for namespace-related Node ops.
447 * Fixed bug with Node's `get_content` method always returning empty
448 * More stable `append_text` for node, added tests
449
450 ## [0.0.74] 2016-25-12
451
452 ### Changed
453
454 * Namespace::new only requires a borrowed &Node now
455 * Fixed bug with wrongly discarded namespace prefixes on Namespace::new
456
457 ### Added
458
459 * Namespace methods: `get_prefix`, `get_url`
460
461 ## [0.0.73] 2016-25-12
462
463 ### Added
464
465 * Document method: `as_node`
466
467 ## [0.0.72] 2016-25-12
468
469 ### Added
470
471 * Node methods: `get_last_child`, `get_child_nodes`, `get_child_elements`, `get_properties`, `get_attributes`
472
473 ## [0.0.71] 2016-29-11
474
475 ### Changed
476
477 * Namespace::new takes Node argument last
478
479 ### Added
480
481 * Node namespace accessors - `set_namespace`, `get_namespaces`, `set_ns_attribute`, `set_ns_property`
482 * Namespace registration for XPath
483
484 ## [0.0.7] 2016-27-11
485
486 ### Changed
487
488 * stricter dependency spec in Cargo.toml
489 * cargo clippy compliant
490 * Document's `get_root_element` returns the document pointer as a Node for empty documents, type change from `Option<Node>` to simple `<Node>`
491
492 ### Added
493
494 * Node accessors: `set_attribute`, `get_attribute`, `set_property` (the `attribute` callers are simple aliases for `property`)
495 * Node `to_hashable` for simple hashing of nodes
496 * Node `mock` for simple mock nodes in testing
497
498 ## [0.0.5] 2016-07-01
499
500 Thanks to @grray for most of these improvements!
501
502 ### Changed
503
504 * Switched to using the more permissive MIT license, consistent with libxml2 licensing
505 * Fixed segfault issues with xpath contexts
506
507 ### Added
508
509 * Can now evaluate ```string(/foo//@bar)``` type XPath expressions, and use their result via ```.to_string()```
510
511 ## [0.0.4] 2016-04-25
512
513 ### Changed
514
515 * The ```Node.add_child``` method now adds a Node, while the old behavior of creating a new node with a given namespace and name is now ```Node.new_child```
516
517 ### Added
518
519 * Can add following siblings via ```Node.add_next_sibling```
520 * Can now add text nodes via ```Node.new_text```