# XML exc c14n canonicalize

`xml-exc-c14n-canonicalize` · version 1.0.0 · Structured formats · free, no key needed

Exclusive XML Canonicalization 1.0 of a whole document, with an optional inclusive prefix list.

**Use when you need to: exclusive xml canonicalization of a whole document · xml exc c14n 1.0 serialize document · canonicalize entire xml without ancestor context.**

## Decide before calling

Read the [versioned contract](/v1/tools/xml-exc-c14n-canonicalize/versions/1.0.0) and the supported scope below. Reuse `xml-exc-c14n-canonicalize@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `xml-exc-c14n-canonicalize@1.0.0` for exclusive xml canonicalization of a whole document. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- exclusive xml canonicalization of a whole document
- xml exc c14n 1.0 serialize document
- canonicalize entire xml without ancestor context
- w3c exclusive canonical xml octets
- exc-c14n with inclusive namespace prefix list
- canonical form for xml signature transforms
- omit unused xmlns in exclusive c14n
- exclusive canonicalization with comments option

## Not supported

- inclusive canonical xml 1.0 or 1.1
- xml signature generation or verification
- arbitrary xpath node sets
- dtd and custom entity expansion
- xml 1.1 documents
- prefix rewriting

## Behavior

- Implements the W3C Exclusive XML Canonicalization 1.0 subset for one XML 1.0 document: UTF-8, no DTD, no custom entities, no XML 1.1, no XPath.
- Omitted with_comments means false. Omitted inclusive_prefixes means an empty list. Prefix-list order does not matter; a repeated prefix is invalid_input.
- Namespace declarations that are not visibly used are omitted unless the prefix or #default is in the inclusive list. Ancestor xml:lang, xml:space, and xml:base are not copied. The xml prefix is prebound and is never emitted.
- Attributes are serialized with one space and double quotes: namespace declarations by prefix (the default prefix first), then other attributes by namespace URI then local name, in Unicode code-point order. Empty elements become start and end tags. Character data escapes &, <, >, and CR. Attribute values escape &, <, ", tab, LF, and CR. No Unicode normalization is applied.
- A comment whose content contains "--" or ends with "-" is malformed and throws invalid_input, whether or not comments are emitted. Document-level comments and processing instructions are separated from the root by one LF. The XML declaration and prolog whitespace are omitted.
- utf8_bytes is the exact UTF-8 length of canonical_xml. Duplicate attributes and unbound prefixes throw invalid_input. A document that exceeds a declared byte, depth, node, attribute, name, or prefix limit throws limit_exceeded before or during the parse.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.

## Input

- `xml` (string, required): min length 1; max length 8192
- `with_comments` (boolean, optional)
- `inclusive_prefixes` (array of string, optional): max items 16; each min length 1; each max length 128; each pattern `^(#default|[A-Za-z_][A-Za-z0-9._-]*)$`

## Output

- `canonical_xml` (string, required): min length 1; max length 8192
- `utf8_bytes` (integer, required): min 7; max 8192

## Limits

- max input bytes: 8192
- max canonical bytes: 8192
- max output bytes: 49152
- max depth: 32
- max nodes: 1024
- max attributes per element: 32
- max inclusive prefixes: 16
- max name bytes: 128

## Example

Request input:

```json
{
  "xml": "<n1:elem1 xmlns:n1=\"http://b.example\">\n    content\n</n1:elem1>"
}
```

Response:

```json
{
  "result": {
    "canonical_xml": "<n1:elem1 xmlns:n1=\"http://b.example\">\n    content\n</n1:elem1>",
    "utf8_bytes": 62
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "xml-exc-c14n-canonicalize",
  "version": "1.0.0",
  "input": {
    "xml": "<n1:elem1 xmlns:n1=\"http://b.example\">\n    content\n</n1:elem1>"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/xml-exc-c14n-canonicalize/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"xml":"<n1:elem1 xmlns:n1=\"http://b.example\">\n    content\n</n1:elem1>"}'
```

The machine-readable contract is at [/v1/tools/xml-exc-c14n-canonicalize/versions/1.0.0](/v1/tools/xml-exc-c14n-canonicalize/versions/1.0.0).

### CLI

```sh
node cli.mjs run xml-exc-c14n-canonicalize 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [XML exc c14n subtree](/tools/xml-exc-c14n-subtree): Exclusive XML Canonicalization 1.0 of one selected element and its descendants.
- [Xpath10 paths](/tools/xpath10-paths): List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.
- [XML exc c14n validate](/tools/xml-exc-c14n-validate): Check whether XML is already in Exclusive XML Canonicalization 1.0 form.
- [Xpath10 count](/tools/xpath10-count): Count the nodes in an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union.
- [Xpath10 boolean](/tools/xpath10-boolean): Evaluate an XPath 1.0 boolean expression: comparisons, and, or, not, starts-with, contains, and boolean conversion.
- [Xpath10 evaluate](/tools/xpath10-evaluate): Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
