# xml-name-validator

> Validates whether a string matches the production for an XML name or qualified name

Latest version **5.0.0** (published 2023-11-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install xml-name-validator
pnpm add xml-name-validator
yarn add xml-name-validator
bun add xml-name-validator
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-11-12 |
| First published | 2014-12-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/xml-name-validator) |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Domenic Denicola |
| Maintainers | timothygu, domenic, sebmaster, zirro, tmpvar, joris-van-der-wel |
| Keywords | xml, name, qname |

## Links

- npm: https://www.npmjs.com/package/xml-name-validator
- Repository: https://github.com/jsdom/xml-name-validator
- Homepage: https://github.com/jsdom/xml-name-validator#readme
- Issues: https://github.com/jsdom/xml-name-validator/issues
- npm.io page: https://npm.io/package/xml-name-validator

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2023-11-12
- 4.0.0 — 2021-09-18
- 3.0.0 — 2017-10-23
- 2.0.1 — 2015-02-24
- 1.0.0 — 2014-12-28

## README

# Validate XML Names and Qualified Names

This package simply tells you whether or not a string matches the [`Name`](http://www.w3.org/TR/xml/#NT-Name) or [`QName`](http://www.w3.org/TR/xml-names/#NT-QName) productions in the XML Namespaces specification. We use it for implementing the [validate](https://dom.spec.whatwg.org/#validate) algorithm in jsdom, but you can use it for whatever you want.

## Usage

This package's main module exports two functions, `name()` and `qname()`. Both take a string and return a boolean indicating whether or not the string matches the relevant production.

```js
"use strict":
const xnv = require("xml-name-validator");

// Will return true
xnv.name("x");
xnv.name(":");
xnv.name("a:0");
xnv.name("a:b:c");

// Will return false
xnv.name("\\");
xnv.name("'");
xnv.name("0");
xnv.name("a!");

// Will return true
xnv.qname("x");
xnv.qname("a0");
xnv.qname("a:b");

// Will return false
xnv.qname(":a");
xnv.qname(":b");
xnv.qname("a:b:c");
xnv.qname("a:0");
```

---
_Source: https://npm.io/package/xml-name-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
