https://github.com/mbg/c14n
Haskell bindings for the c14n implementation in LibXML (XML canonicalisation)
https://github.com/mbg/c14n
c14n canonicalization haskell xml
Last synced: about 1 year ago
JSON representation
Haskell bindings for the c14n implementation in LibXML (XML canonicalisation)
- Host: GitHub
- URL: https://github.com/mbg/c14n
- Owner: mbg
- License: mit
- Created: 2020-06-25T18:07:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-01T15:23:59.000Z (over 2 years ago)
- Last Synced: 2024-04-25T23:02:20.769Z (about 2 years ago)
- Topics: c14n, canonicalization, haskell, xml
- Language: Haskell
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# c14n

[](https://github.com/mbg/c14n/actions/workflows/haskell.yml)
[](https://github.com/mbg/c14n/actions/workflows/stackage-nightly.yml)
[](https://hackage.haskell.org/package/c14n)
Haskell bindings for the c14n implementation in libxml (XML canonicalisation). Unfortunately there is (at the time of writing) no pure Haskell implementation, so this seems like the best option.
## Requirements
You need to have `libxml2` installed, including on macOS (with `brew install libxml2`). Then build with `stack build`.
## Usage
The `Text.XML.C14N` module exports a function named `c14n` which provides a mid-level interface to the canonicalisation function from `libxml2`. It will handle most of the marshalling, but not much more. For example:
```haskell
> c14n [] c14n_1_1 [] False Nothing "foobar"
"foobar"
```
The arguments, in order, are:
* Parser options, see the module documentation or the [libxml2 documentation](http://xmlsoft.org/html/libxml-parser.html)
* The canonicalisation specification to use (`c14n_1_0`, `c14n_exclusive_1_0`, or `c14n_1_1`).
* A (potentially empty) list of namespace prefixes which is used when the canonicalisation specification used is `c14n_exclusive_1_0`
* A boolean value indicating whether to keep comments in the output or not.
* An XPath location path used to select a set of nodes that should be included in the canonicalised result