JSPM

  • Created
  • Published
  • Downloads 391
  • Score
    100M100P100Q88759F
  • License MIT

Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name)

Package Exports

  • charcode-is-valid-xml-name-character

Readme

charcode-is-valid-xml-name-character

Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name)

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 1.13.0 (npm i charcode-is-valid-xml-name-character@1.13.0).

npm i charcode-is-valid-xml-name-character

Quick Take

import { strict as assert } from "assert";

import {
  isProduction4,
  isProduction4a,
  validFirstChar,
  validSecondCharOnwards,
} from "charcode-is-valid-xml-name-character";

// Spec: https://www.w3.org/TR/REC-xml/#NT-NameStartChar

assert.equal(isProduction4("Z"), true);
assert.equal(isProduction4("?"), false);

assert.equal(isProduction4a("?"), false);
assert.equal(isProduction4a("-"), true);

assert.equal(validFirstChar("a"), true);
assert.equal(validFirstChar("1"), false);

assert.equal(validSecondCharOnwards("a"), true);
assert.equal(validSecondCharOnwards("?"), false);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License

Copyright © 2010-2025 Roy Revelt and other contributors

ok codsen star