UNPKG

3.09 kBTypeScriptView Raw
1/**
2 * Copyright (C) 2016-2019 Michael Kourlas
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { IStringOptions } from "../options";
17/**
18 * The options used to create a new declaration.
19 */
20export interface IXmlDeclOptions {
21 /**
22 * The encoding attribute to be included in the declaration. If defined,
23 * this value must be a valid encoding. By default, no encoding attribute
24 * is included.
25 */
26 encoding?: string;
27 /**
28 * The value of the standalone attribute to be included in the declaration.
29 * If defined, this value must be "yes" or "no". By default, no standalone
30 * attribute is included.
31 */
32 standalone?: string;
33 /**
34 * The XML version to be included in the declaration. If defined, this
35 * value must be a valid XML version number. Defaults to "1.0".
36 */
37 version?: string;
38}
39/**
40 * Represents a declaration.
41 *
42 * A declaration is structured as follows, where `{version}` is the XML
43 * version, `{encoding}` is the encoding of the document, and `{standalone}`
44 * is either "yes" or "no", depending on whether the document may contain
45 * external markup declarations:
46 *
47 * ```xml
48 * <?xml version="{version}" encoding="{encoding}" standalone="{standalone}"?>
49 * ```
50 */
51export default class XmlDecl<Parent> {
52 private readonly _validation;
53 private _encoding;
54 private readonly _parent;
55 private _standalone;
56 private _version;
57 constructor(parent: Parent, validation: boolean, options: IXmlDeclOptions);
58 /**
59 * Gets the encoding associated with this declaration.
60 */
61 get encoding(): string | undefined;
62 /**
63 * Sets the encoding associated with this declaration.
64 */
65 set encoding(encoding: string | undefined);
66 /**
67 * Gets the value of the standalone attribute associated with this
68 * declaration.
69 */
70 get standalone(): string | undefined;
71 /**
72 * Sets the value of the standalone attribute associated with this
73 * declaration.
74 */
75 set standalone(standalone: string | undefined);
76 /**
77 * Gets the XML version associated with this declaration.
78 */
79 get version(): string;
80 /**
81 * Sets the XML version associated with this declaration.
82 */
83 set version(version: string);
84 /**
85 * Returns an XML string representation of this declaration.
86 */
87 toString(options?: IStringOptions): string;
88 /**
89 * Returns the parent of this declaration.
90 */
91 up(): Parent;
92}