source: frontend/node_modules/xml-name-validator/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1# Validate XML Names and Qualified Names
2
3This 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.
4
5## Usage
6
7This package's main module's default export takes a string and will return an object of the form `{ success, error }`, where `success` is a boolean and if it is `false`, then `error` is a string containing some hint as to where the match went wrong.
8
9```js
10"use strict":
11var xnv = require("xml-name-validator");
12var assert = require("assert");
13
14// Will return { success: true, error: undefined }
15xnv.name("x");
16xnv.name(":");
17xnv.name("a:0");
18xnv.name("a:b:c");
19
20// Will return { success: false, error: <an explanatory string> }
21xnv.name("\\");
22xnv.name("'");
23xnv.name("0");
24xnv.name("a!");
25
26// Will return { success: true, error: undefined }
27xnv.qname("x");
28xnv.qname("a0");
29xnv.qname("a:b");
30
31// Will return { success: false, error: <an explanatory string> }
32xnv.qname(":a");
33xnv.qname(":b");
34xnv.qname("a:b:c");
35xnv.qname("a:0");
36```
Note: See TracBrowser for help on using the repository browser.