{"id":13339469,"url":"https://github.com/remcohaszing/xast-namespaces","last_synced_at":"2026-05-20T14:15:07.241Z","repository":{"id":57400990,"uuid":"329423008","full_name":"remcohaszing/xast-namespaces","owner":"remcohaszing","description":"Attach namespace information to a xast XML element tree.","archived":false,"fork":false,"pushed_at":"2022-10-25T12:58:53.000Z","size":478,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-19T12:53:11.504Z","etag":null,"topics":["javascript","unist","xast","xml"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remcohaszing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-13T20:24:28.000Z","updated_at":"2023-03-01T10:17:44.000Z","dependencies_parsed_at":"2022-09-19T01:10:54.651Z","dependency_job_id":null,"html_url":"https://github.com/remcohaszing/xast-namespaces","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/remcohaszing/xast-namespaces","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fxast-namespaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fxast-namespaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fxast-namespaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fxast-namespaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remcohaszing","download_url":"https://codeload.github.com/remcohaszing/xast-namespaces/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Fxast-namespaces/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266706612,"owners_count":23971904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","unist","xast","xml"],"created_at":"2024-07-29T19:20:03.684Z","updated_at":"2026-05-20T14:15:07.236Z","avatar_url":"https://github.com/remcohaszing.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xast-namespaces\n\n\u003e Attach namespace information to a xast XML element tree.\n\n[![build status](https://github.com/remcohaszing/xast-namespaces/workflows/ci/badge.svg)](https://github.com/remcohaszing/xast-namespaces/actions)\n[![codecov](https://codecov.io/gh/remcohaszing/xast-namespaces/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/xast-namespaces)\n[![npm](https://img.shields.io/npm/v/xast-namespaces)](https://www.npmjs.com/package/xast-namespaces)\n[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)\n\nThis library exposes a function which takes a [xast](https://github.com/syntax-tree/xast) tree and\nattaches namespace information to each element.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [`attachNamespaces(tree)`](#attachnamespacestree)\n- [Compatibility](#compatibility)\n- [License](#license)\n\n## Installation\n\n```sh\nnpm install xast-namespaces\n```\n\n## Usage\n\n```js\nimport assert from 'node:assert/strict'\n\nimport { attachNamespaces } from 'xast-namespaces'\n\nconst tree = {\n  type: 'element',\n  name: 'ns:parent',\n  attributes: {\n    'xmlns:ns': 'https://ns.example'\n  },\n  children: [\n    {\n      type: 'element',\n      name: 'ns:child',\n      attributes: {\n        'ns:attr': 'value'\n      },\n      children: []\n    }\n  ]\n}\n\nconst result = attachNamespaces(tree)\nassert.deepStrictEqual(result, {\n  type: 'element',\n  name: 'ns:parent',\n  namespace: 'ns',\n  namespaceURI: 'https://ns.example',\n  localName: 'parent',\n  namespaces: {\n    ns: 'https://ns.example'\n  },\n  attributes: {\n    'xmlns:ns': 'https://ns.example'\n  },\n  namespacedAttributes: [\n    {\n      type: 'attribute',\n      name: 'xmlns:ns',\n      namespace: 'xmlns',\n      namespaceURI: undefined,\n      localName: 'ns',\n      value: 'https://ns.example'\n    }\n  ],\n  children: [\n    {\n      type: 'element',\n      name: 'ns:child',\n      namespace: 'ns',\n      namespaceURI: 'https://ns.example',\n      localName: 'child',\n      namespaces: {\n        ns: 'https://ns.example'\n      },\n      attributes: {\n        'ns:attr': 'value'\n      },\n      namespacedAttributes: [\n        {\n          type: 'attribute',\n          name: 'ns:attr',\n          namespace: 'ns',\n          namespaceURI: 'https://ns.example',\n          localName: 'attr',\n          value: 'value'\n        }\n      ],\n      children: []\n    }\n  ]\n})\n```\n\n## API\n\n### `attachNamespaces(tree)`\n\nAttach XML namespace data to a xast tree.\n\n#### Options\n\n- `tree` The document tree to attach namespace data to. If a `xast` root is passed, its element\n  child will be used.\n\n#### Returns\n\nA copy of the tree, but with namespace data attached.\n\n## Compatibility\n\nThis project is compatible with Node.js 22 or greater.\n\n## License\n\n[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Fxast-namespaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremcohaszing%2Fxast-namespaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Fxast-namespaces/lists"}