@amazon/vinyl-xml 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/index.cjs +976 -0
  2. package/dist/index.cjs.map +7 -0
  3. package/dist/index.js +986 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/types/current/index.d.ts +14 -0
  6. package/dist/types/current/index.d.ts.map +1 -0
  7. package/dist/types/current/index.js +13 -0
  8. package/dist/types/current/tsconfig.tsbuildinfo +1 -0
  9. package/dist/types/current/xlink/actuateValidator.d.ts +3 -0
  10. package/dist/types/current/xlink/actuateValidator.d.ts.map +1 -0
  11. package/dist/types/current/xlink/actuateValidator.js +11 -0
  12. package/dist/types/current/xml/ParseXmlHandler.d.ts +56 -0
  13. package/dist/types/current/xml/ParseXmlHandler.d.ts.map +1 -0
  14. package/dist/types/current/xml/ParseXmlHandler.js +5 -0
  15. package/dist/types/current/xml/ParseXmlHandlerImpl.d.ts +49 -0
  16. package/dist/types/current/xml/ParseXmlHandlerImpl.d.ts.map +1 -0
  17. package/dist/types/current/xml/ParseXmlHandlerImpl.js +198 -0
  18. package/dist/types/current/xml/QName.d.ts +33 -0
  19. package/dist/types/current/xml/QName.d.ts.map +1 -0
  20. package/dist/types/current/xml/QName.js +19 -0
  21. package/dist/types/current/xml/XmlSchemaError.d.ts +15 -0
  22. package/dist/types/current/xml/XmlSchemaError.d.ts.map +1 -0
  23. package/dist/types/current/xml/XmlSchemaError.js +23 -0
  24. package/dist/types/current/xml/mappedXmlRules.d.ts +118 -0
  25. package/dist/types/current/xml/mappedXmlRules.d.ts.map +1 -0
  26. package/dist/types/current/xml/mappedXmlRules.js +122 -0
  27. package/dist/types/current/xml/mergeXmlRules.d.ts +62 -0
  28. package/dist/types/current/xml/mergeXmlRules.d.ts.map +1 -0
  29. package/dist/types/current/xml/mergeXmlRules.js +89 -0
  30. package/dist/types/current/xml/parseXml.d.ts +76 -0
  31. package/dist/types/current/xml/parseXml.d.ts.map +1 -0
  32. package/dist/types/current/xml/parseXml.js +305 -0
  33. package/dist/types/current/xml/stringifyXml.d.ts +67 -0
  34. package/dist/types/current/xml/stringifyXml.d.ts.map +1 -0
  35. package/dist/types/current/xml/stringifyXml.js +225 -0
  36. package/dist/types/current/xml/xmlRules.d.ts +207 -0
  37. package/dist/types/current/xml/xmlRules.d.ts.map +1 -0
  38. package/dist/types/current/xml/xmlRules.js +134 -0
  39. package/dist/types/current/xmlns/org/w3/1999/xlink.d.ts +7 -0
  40. package/dist/types/current/xmlns/org/w3/1999/xlink.d.ts.map +1 -0
  41. package/dist/types/current/xmlns/org/w3/1999/xlink.js +5 -0
  42. package/dist/types/current/xmlns/org/w3/2001/XmlSchema.d.ts +17 -0
  43. package/dist/types/current/xmlns/org/w3/2001/XmlSchema.d.ts.map +1 -0
  44. package/dist/types/current/xmlns/org/w3/2001/XmlSchema.js +5 -0
  45. package/dist/types/ts3.7/index.d.ts +14 -0
  46. package/dist/types/ts3.7/xlink/actuateValidator.d.ts +3 -0
  47. package/dist/types/ts3.7/xml/ParseXmlHandler.d.ts +56 -0
  48. package/dist/types/ts3.7/xml/ParseXmlHandlerImpl.d.ts +49 -0
  49. package/dist/types/ts3.7/xml/QName.d.ts +33 -0
  50. package/dist/types/ts3.7/xml/XmlSchemaError.d.ts +15 -0
  51. package/dist/types/ts3.7/xml/mappedXmlRules.d.ts +118 -0
  52. package/dist/types/ts3.7/xml/mergeXmlRules.d.ts +118 -0
  53. package/dist/types/ts3.7/xml/parseXml.d.ts +76 -0
  54. package/dist/types/ts3.7/xml/stringifyXml.d.ts +67 -0
  55. package/dist/types/ts3.7/xml/xmlRules.d.ts +207 -0
  56. package/dist/types/ts3.7/xmlns/org/w3/1999/xlink.d.ts +7 -0
  57. package/dist/types/ts3.7/xmlns/org/w3/2001/XmlSchema.d.ts +17 -0
  58. package/dist/types/ts4.1/index.d.ts +14 -0
  59. package/dist/types/ts4.1/xlink/actuateValidator.d.ts +3 -0
  60. package/dist/types/ts4.1/xml/ParseXmlHandler.d.ts +56 -0
  61. package/dist/types/ts4.1/xml/ParseXmlHandlerImpl.d.ts +49 -0
  62. package/dist/types/ts4.1/xml/QName.d.ts +33 -0
  63. package/dist/types/ts4.1/xml/XmlSchemaError.d.ts +15 -0
  64. package/dist/types/ts4.1/xml/mappedXmlRules.d.ts +118 -0
  65. package/dist/types/ts4.1/xml/mergeXmlRules.d.ts +118 -0
  66. package/dist/types/ts4.1/xml/parseXml.d.ts +77 -0
  67. package/dist/types/ts4.1/xml/stringifyXml.d.ts +67 -0
  68. package/dist/types/ts4.1/xml/xmlRules.d.ts +207 -0
  69. package/dist/types/ts4.1/xmlns/org/w3/1999/xlink.d.ts +7 -0
  70. package/dist/types/ts4.1/xmlns/org/w3/2001/XmlSchema.d.ts +17 -0
  71. package/dist/types/ts4.7/index.d.ts +14 -0
  72. package/dist/types/ts4.7/xlink/actuateValidator.d.ts +3 -0
  73. package/dist/types/ts4.7/xml/ParseXmlHandler.d.ts +56 -0
  74. package/dist/types/ts4.7/xml/ParseXmlHandlerImpl.d.ts +49 -0
  75. package/dist/types/ts4.7/xml/QName.d.ts +33 -0
  76. package/dist/types/ts4.7/xml/XmlSchemaError.d.ts +15 -0
  77. package/dist/types/ts4.7/xml/mappedXmlRules.d.ts +118 -0
  78. package/dist/types/ts4.7/xml/mergeXmlRules.d.ts +118 -0
  79. package/dist/types/ts4.7/xml/parseXml.d.ts +76 -0
  80. package/dist/types/ts4.7/xml/stringifyXml.d.ts +67 -0
  81. package/dist/types/ts4.7/xml/xmlRules.d.ts +207 -0
  82. package/dist/types/ts4.7/xmlns/org/w3/1999/xlink.d.ts +7 -0
  83. package/dist/types/ts4.7/xmlns/org/w3/2001/XmlSchema.d.ts +17 -0
  84. package/docs/XML_PARSING.md +210 -0
  85. package/package.json +82 -0
@@ -0,0 +1,56 @@
1
+ import { QName } from './QName';
2
+ import { XmlElement } from '../xml/ParseXmlHandlerImpl';
3
+ /**
4
+ * A handler for XML deserialization.
5
+ */
6
+ export interface ParseXmlHandler<T> {
7
+ /**
8
+ * A new document has begun.
9
+ */
10
+ startDocument(): void;
11
+ /**
12
+ * A document has completed parsing, the final object is ready.
13
+ */
14
+ endDocument(): T & XmlElement<T>;
15
+ /**
16
+ * Invoked when a new element has been started, after the element's attributes have been read.
17
+ *
18
+ * @param name An object representing the element's name and namespace.
19
+ * @param attributes The attributes associated with the currently opening element.
20
+ */
21
+ startElement(name: QName, attributes: Attributes): void;
22
+ /**
23
+ * Invoked after an element closing tag.
24
+ */
25
+ endElement(): void;
26
+ /**
27
+ * Provides a raw substring as a text node. The given text is expected to be decoded using
28
+ * `decodeEntities`.
29
+ *
30
+ * @param str
31
+ */
32
+ textNode(str: string): void;
33
+ /**
34
+ * Provides a raw substring as a cdata node. This text is _not_ expected to be decoded.
35
+ *
36
+ * @param str
37
+ */
38
+ cDataNode(str: string): void;
39
+ }
40
+ /**
41
+ * An attribute map, where the keys are the fully qualified attribute names.
42
+ */
43
+ export interface Attributes {
44
+ readonly [qName: string]: Attribute | undefined;
45
+ }
46
+ export interface Attribute {
47
+ /**
48
+ * This attribute's name.
49
+ */
50
+ readonly name: QName;
51
+ /**
52
+ * The unescaped attribute value.
53
+ */
54
+ readonly value: string;
55
+ }
56
+ //# sourceMappingURL=ParseXmlHandler.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { Cloneable } from '@amazon/vinyl-util';
2
+ import { XmlRules } from './xmlRules';
3
+ import { MappedXmlRules } from './mappedXmlRules';
4
+ import { Attributes, ParseXmlHandler } from './ParseXmlHandler';
5
+ import { QName } from './QName';
6
+ export interface ParseXmlHandlerOptions {
7
+ readonly validateRules: boolean;
8
+ }
9
+ /**
10
+ * A {@link ParseXmlHandler} implementation that follows {@link XmlRules}, building an object of
11
+ * the parameterized type.
12
+ */
13
+ export declare class ParseXmlHandlerImpl<T> implements ParseXmlHandler<T> {
14
+ private readonly rules;
15
+ private stack;
16
+ private options;
17
+ private busy;
18
+ constructor(rules: MappedXmlRules<T>, options?: Partial<ParseXmlHandlerOptions>);
19
+ startDocument(): void;
20
+ startElement(name: QName, attributes: Attributes): void;
21
+ textNode(str: string): void;
22
+ cDataNode(str: string): void;
23
+ endElement(): void;
24
+ endDocument(): T & XmlElement<T>;
25
+ private validate;
26
+ }
27
+ /**
28
+ * Creates an XML content handler for the given parsing rules.
29
+ *
30
+ * @param rules
31
+ * @param options
32
+ */
33
+ export declare function parseXmlHandler<T extends object>(rules: XmlRules<T>, options?: Partial<ParseXmlHandlerOptions>): ParseXmlHandlerImpl<T>;
34
+ declare const parentSymbol: unique symbol;
35
+ export interface XmlElement<T = any> extends Cloneable<T & XmlElement<T>> {
36
+ readonly parent: (XmlElement | null);
37
+ toJSON(): any;
38
+ }
39
+ export declare class XmlElementImpl<T> implements XmlElement<T> {
40
+ [prop: keyof any]: any;
41
+ private [parentSymbol];
42
+ constructor(parent?: XmlElement | null);
43
+ get parent(): XmlElement | null;
44
+ set parent(value: XmlElement | null);
45
+ clone(): T & XmlElementImpl<T>;
46
+ toJSON(): any;
47
+ }
48
+ export {};
49
+ //# sourceMappingURL=ParseXmlHandlerImpl.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { Uri } from '../xmlns/org/w3/2001/XmlSchema';
2
+ /**
3
+ * An XML name for an element or attribute.
4
+ */
5
+ export interface QName {
6
+ /**
7
+ * The fully qualified name.
8
+ * This will be the prefixed name or the unprefixed name if the prefix is empty.
9
+ * The prefixed name will be `prefix ':' localPart`
10
+ */
11
+ readonly qName: string;
12
+ /**
13
+ * The xmlns prefix.
14
+ */
15
+ readonly prefix: string | null;
16
+ /**
17
+ * The local part of this name.
18
+ */
19
+ readonly localPart: string;
20
+ /**
21
+ * The resolved xmlns uri for the associated prefix.
22
+ */
23
+ readonly namespaceUri: Uri | null;
24
+ }
25
+ /**
26
+ * Creates a new {@link QName} object.
27
+ *
28
+ * @param localPart
29
+ * @param prefix
30
+ * @param namespaceUri
31
+ */
32
+ export declare function qName(localPart: string, prefix?: string | null, namespaceUri?: Uri | null): QName;
33
+ //# sourceMappingURL=QName.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { ReportableError } from '@amazon/vinyl-util';
2
+ /**
3
+ * @private
4
+ */
5
+ export declare const xmlSchemaErrorLocale: {
6
+ readonly atLeastElements: "Expected at least {expected} occurrences of {property} but was {actual}";
7
+ readonly atMostElements: "Expected at most {expected} occurrences of {property} but was {actual}";
8
+ readonly cyclicReferences: "Cyclic reference detected";
9
+ readonly requiredAttribute: "Attribute '{property}' is required";
10
+ };
11
+ export declare class XmlSchemaError extends ReportableError {
12
+ get [Symbol.toStringTag](): string;
13
+ constructor(message: string);
14
+ }
15
+ //# sourceMappingURL=XmlSchemaError.d.ts.map
@@ -0,0 +1,118 @@
1
+ import { AnyRecord, Invariant } from '@amazon/vinyl-util';
2
+ import { XmlRules } from './xmlRules';
3
+ import { Uri } from '../xmlns/org/w3/2001/XmlSchema';
4
+ /**
5
+ * A machine-readable representation of parse rules for random access based on qualified namespace
6
+ * keys.
7
+ *
8
+ * Rule keys will either be `namespaceUri:localPart` or just `localPart` for wildcard rules if
9
+ * namespaceUri is not defined in the handler.
10
+ */
11
+ export interface MappedXmlRules<T> {
12
+ /**
13
+ * Enforces that this rule set can only be used to parse the expected type T.
14
+ */
15
+ readonly __type: Invariant<T>;
16
+ readonly attributes: ReadonlyMap<string, MappedAttributeRule>;
17
+ readonly elements: ReadonlyMap<string, MappedElementsRule>;
18
+ readonly characters: MappedCharactersRule | undefined;
19
+ }
20
+ export interface MappedAttributeRule {
21
+ /**
22
+ * The property name.
23
+ */
24
+ readonly property: keyof any;
25
+ /**
26
+ * If true, a parsing error will be thrown if the value is undefined.
27
+ */
28
+ readonly required: boolean;
29
+ /**
30
+ * If the current element has no matching attribute, default will be used.
31
+ */
32
+ readonly default: any;
33
+ /**
34
+ * Parses the attribute value.
35
+ */
36
+ readonly parse: (value: string) => any;
37
+ /**
38
+ * Converts the attribute value to a string.
39
+ */
40
+ readonly stringify: (value: any) => string;
41
+ /**
42
+ * The local part of the QName.
43
+ */
44
+ readonly localPart: string;
45
+ /**
46
+ * The namespace uri that must match.
47
+ */
48
+ readonly namespaceUri: Uri | null;
49
+ }
50
+ export interface MappedElementsRule {
51
+ /**
52
+ * The name of the property to set on the parent element.
53
+ */
54
+ readonly property: keyof any;
55
+ /**
56
+ * True if the parsed elements should populate into an array.
57
+ */
58
+ readonly array: boolean;
59
+ /**
60
+ * The minimum number of elements.
61
+ */
62
+ readonly minOccurs: number;
63
+ /**
64
+ * The maximum number of elements. Use null for unbounded.
65
+ */
66
+ readonly maxOccurs: number | null;
67
+ /**
68
+ * If true and there are 0 occurrences of the element, the parsed value will be an empty array
69
+ * instead of undefined.
70
+ */
71
+ readonly useEmptyArrays: boolean;
72
+ /**
73
+ * Returns the mappings for matched element(s).
74
+ */
75
+ readonly rules: () => MappedXmlRules<any>;
76
+ /**
77
+ * The local part of the QName.
78
+ */
79
+ readonly localPart: string;
80
+ /**
81
+ * The namespace uri that must match.
82
+ */
83
+ readonly namespaceUri: Uri | null;
84
+ }
85
+ export interface MappedCharactersRule {
86
+ readonly property: keyof any;
87
+ /**
88
+ * Parses the unescaped/processed characters.
89
+ * This will always be called, but characters may be an empty string if the element has no
90
+ * text content.
91
+ */
92
+ readonly parse: (characters: string) => any;
93
+ /**
94
+ * Converts the value to a string.
95
+ */
96
+ readonly stringify: (value: any) => string;
97
+ }
98
+ /**
99
+ * An empty rules map, used when there was no match for the started element.
100
+ * @private
101
+ */
102
+ export declare const EmptyRules: MappedXmlRules<AnyRecord>;
103
+ /**
104
+ * Creates machine-friendly content handler rules from the given {@link XmlRules}.
105
+ *
106
+ * @param rules The {@link XmlRules} to convert.
107
+ * @param parentNamespaceUri
108
+ */
109
+ export declare function mapXmlRules<T extends object>(rules: XmlRules<T>, parentNamespaceUri?: Uri | null): MappedXmlRules<T>;
110
+ /**
111
+ * Creates a rule key for mapped xml rules.
112
+ *
113
+ * @private
114
+ * @param localPart The {@link QName.localPart}
115
+ * @param namespaceUri The `namespaceUri` of the element.
116
+ */
117
+ export declare function xmlRuleKey(localPart: string, namespaceUri?: Uri | null): string;
118
+ //# sourceMappingURL=mappedXmlRules.d.ts.map
@@ -0,0 +1,118 @@
1
+ import { Fun } from '@amazon/vinyl-util';
2
+ import { XmlRules } from '../xml/xmlRules';
3
+ /**
4
+ * Recursively merges array types so that S[] & T[] becomes (S & T)[]
5
+ * When two array elements parsing rules are merged, the result is an array with intersected
6
+ * element types.
7
+ */
8
+ export type Merged<T> = T extends readonly any[] ? any : T extends Fun ? T : T extends object ? {
9
+ [P in keyof T]: any;
10
+ } : T;
11
+ /**
12
+ * `[S0, T0] & [S1, T1]` cannot be converted to `[S0 & S1, T0 & T1]`, but we can at least preserve
13
+ * the tuple when not intersected.
14
+ *
15
+ * Intersected tuples become arrays. E.g. `[S0, T0] & [S1, T1]` becomes `Array<S0 | S1 | T0 | T1>`
16
+ */
17
+ export type MergedTupleOrArray<T extends readonly any[]> = T extends [
18
+ infer V0
19
+ ] ? [
20
+ any
21
+ ] : T extends [
22
+ infer V0,
23
+ infer V1
24
+ ] ? [
25
+ any,
26
+ any
27
+ ] : T extends [
28
+ infer V0,
29
+ infer V1,
30
+ infer V2
31
+ ] ? [
32
+ any,
33
+ any,
34
+ any
35
+ ] : T extends [
36
+ infer V0,
37
+ infer V1,
38
+ infer V2,
39
+ infer V3
40
+ ] ? [
41
+ any,
42
+ any,
43
+ any,
44
+ any
45
+ ] : T extends [
46
+ infer V0,
47
+ infer V1,
48
+ infer V2,
49
+ infer V3,
50
+ infer V4
51
+ ] ? [
52
+ any,
53
+ any,
54
+ any,
55
+ any,
56
+ any
57
+ ] : T extends any[] ? Array<any> : T extends readonly [
58
+ infer V0
59
+ ] ? readonly [
60
+ any
61
+ ] : T extends readonly [
62
+ infer V0,
63
+ infer V1
64
+ ] ? readonly [
65
+ any,
66
+ any
67
+ ] : T extends readonly [
68
+ infer V0,
69
+ infer V1,
70
+ infer V2
71
+ ] ? readonly [
72
+ any,
73
+ any,
74
+ any
75
+ ] : T extends readonly [
76
+ infer V0,
77
+ infer V1,
78
+ infer V2,
79
+ infer V3
80
+ ] ? readonly [
81
+ any,
82
+ any,
83
+ any,
84
+ any
85
+ ] : T extends readonly [
86
+ infer V0,
87
+ infer V1,
88
+ infer V2,
89
+ infer V3,
90
+ infer V4
91
+ ] ? readonly [
92
+ any,
93
+ any,
94
+ any,
95
+ any,
96
+ any
97
+ ] : ReadonlyArray<any>;
98
+ /**
99
+ * Merges the given two xml rule sets into one.
100
+ */
101
+ export declare function mergeXmlRules<A extends object, B extends object>(a: XmlRules<A>, b: XmlRules<B>): XmlRules<Merged<A & B>>;
102
+ /**
103
+ * Merges the given three xml rule sets into one.
104
+ */
105
+ export declare function mergeXmlRules<A extends object, B extends object, C extends object>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>): XmlRules<Merged<A & B & C>>;
106
+ /**
107
+ * Merges the given four xml rule sets into one.
108
+ */
109
+ export declare function mergeXmlRules<A extends object, B extends object, C extends object, D extends object>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>, d: XmlRules<D>): XmlRules<Merged<A & B & C & D>>;
110
+ /**
111
+ * Merges the given five xml rule sets into one.
112
+ */
113
+ export declare function mergeXmlRules<A extends object, B extends object, C extends object, D extends object, E extends object>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>, d: XmlRules<D>, e: XmlRules<E>): XmlRules<Merged<A & B & C & D & E>>;
114
+ /**
115
+ * Merges the given six xml rule sets into one.
116
+ */
117
+ export declare function mergeXmlRules<A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>, d: XmlRules<D>, e: XmlRules<E>, f: XmlRules<F>): XmlRules<Merged<A & B & C & D & E & F>>;
118
+ //# sourceMappingURL=mergeXmlRules.d.ts.map
@@ -0,0 +1,76 @@
1
+ import { MutableDeep, StringReader } from '@amazon/vinyl-util';
2
+ import { Uri } from '../xmlns/org/w3/2001/XmlSchema';
3
+ import { Attributes, ParseXmlHandler } from './ParseXmlHandler';
4
+ import { QName } from './QName';
5
+ import { XmlElement } from './ParseXmlHandlerImpl';
6
+ export declare const XMLNS = "http://www.w3.org/2000/xmlns/";
7
+ /**
8
+ * Nested xml elements push current namespace information onto a stack.
9
+ *
10
+ * @private
11
+ */
12
+ export interface StackElement {
13
+ /**
14
+ * The qualified name of the current element on the stack. Used to validate expected closing
15
+ * element.
16
+ */
17
+ readonly qName: string;
18
+ /**
19
+ * The (mutable) namespaces map for the current stack.
20
+ */
21
+ readonly namespaceMap: Namespaces;
22
+ /**
23
+ * The default namespace.
24
+ */
25
+ defaultNamespaceUri: Uri | null;
26
+ }
27
+ /**
28
+ * Parses an XML document using a partial sax-style content handler.
29
+ * This allows for parsing without the entire document being read into memory first.
30
+ *
31
+ * XML Documents are mapped to data structures through content handlers instead of needing an
32
+ * intermediate model.
33
+ */
34
+ export declare function parseXml<T>(str: string, handler: ParseXmlHandler<T>): T & XmlElement<T>;
35
+ /**
36
+ * @private
37
+ */
38
+ export type Namespaces = Map<string, Uri | null>;
39
+ /**
40
+ * Given that the cursor is at a ' or ", reads the sequence of characters until an end quote is
41
+ * reached.
42
+ * The returned unescaped string is the text within the quotes.
43
+ * @private
44
+ */
45
+ export declare function readAttributeValue(c: StringReader): string;
46
+ /**
47
+ * Reads until the end of the tag >
48
+ * @private
49
+ */
50
+ export declare function untilTagClose(c: StringReader): void;
51
+ /**
52
+ * Returns true if the char code is a valid xml name character.
53
+ * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar
54
+ * @param charCode
55
+ * @private
56
+ */
57
+ export declare function isNameChar(charCode: number): boolean;
58
+ /**
59
+ * Reads an xml {@link QName}.
60
+ * The {@link QName.namespaceUri} returned will be null; it must be separately looked up.
61
+ *
62
+ * @param reader The current string reader.
63
+ * @private
64
+ */
65
+ export declare function readQName(reader: StringReader): MutableDeep<QName>;
66
+ /**
67
+ * Reads a series of xml attributes, separated by whitespace.
68
+ * Example: `ns1:key1="value1" key2 key3='value3'`
69
+ * Note: consumes all whitespace before and after attributes series.
70
+ *
71
+ * @return Returns a map of attribute `qName:string` to `Attribute` objects.
72
+ *
73
+ * @private
74
+ */
75
+ export declare function xmlAttributes(reader: StringReader, stackElement: StackElement): MutableDeep<Attributes>;
76
+ //# sourceMappingURL=parseXml.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { OptionalDeep } from '@amazon/vinyl-util';
2
+ import { Uri } from '../xmlns/org/w3/2001/XmlSchema';
3
+ import { MappedXmlRules } from './mappedXmlRules';
4
+ import { ReservedXmlRuleKeys } from '../xml/xmlRules';
5
+ export interface StringifyOptions {
6
+ /**
7
+ * The indentation. Default: 4 spaces
8
+ */
9
+ readonly indent: string;
10
+ /**
11
+ * The character(s) between lines. Default: \n
12
+ */
13
+ readonly newline: string;
14
+ /**
15
+ * A map of namespace uri to prefix strings.
16
+ * If a namespace is not found, a prefix will be generated.
17
+ */
18
+ readonly prefixMap: ReadonlyMap<Uri, string>;
19
+ /**
20
+ * If true, will include the XML declaration at the beginning of the stringified document.
21
+ * `<?xml version="1.0"?>`
22
+ */
23
+ readonly includeXmlDeclaration: boolean;
24
+ }
25
+ export declare class XmlWriter<T> {
26
+ private readonly rules;
27
+ private readonly options;
28
+ private readonly usedPrefixes;
29
+ private readonly traversed;
30
+ constructor(rules: MappedXmlRules<T>, options?: Partial<StringifyOptions>);
31
+ stringify(object: OptionalDeep<T, ReservedXmlRuleKeys>): string;
32
+ private qName;
33
+ /**
34
+ * Stringifies an element.
35
+ *
36
+ * @param object
37
+ * @param rule
38
+ * @param state
39
+ */
40
+ private stringifyElement;
41
+ /**
42
+ * Stringifies an element's attributes.
43
+ *
44
+ * @param object
45
+ * @param attributes
46
+ * @return Returns the attributes string. This will include a leading space if there are any
47
+ * found attributes.
48
+ */
49
+ private stringifyAttributes;
50
+ /**
51
+ * Stringifies a property as a CDATA node.
52
+ *
53
+ * @param object
54
+ * @param charactersRule
55
+ */
56
+ private stringifyCharacters;
57
+ /**
58
+ * Stringifies an element's child elements.
59
+ *
60
+ * @param object
61
+ * @param elements
62
+ * @param state
63
+ */
64
+ private stringifyChildren;
65
+ }
66
+ export declare function stringifyXml<T>(object: OptionalDeep<T, ReservedXmlRuleKeys>, rules: MappedXmlRules<T>, options?: Partial<StringifyOptions>): string;
67
+ //# sourceMappingURL=stringifyXml.d.ts.map