MCPcopy Create free account
hub / github.com/charto/cxml / constructor

Method constructor

src/parser/ParserConfig.ts:40–100  ·  view source on GitHub ↗

XML parser configuration. * @param config Parent object for cloning. * @param native Reference to C++ object. For internal use only.

(config?: ParserOptions | ParserConfig, native?: NativeConfig | null)

Source from the content-addressed store, hash-verified

38 * @param config Parent object for cloning.
39 * @param native Reference to C++ object. For internal use only. */
40 constructor(config?: ParserOptions | ParserConfig, native?: NativeConfig | null) {
41 if(config instanceof ParserConfig) {
42 this.isLinked = true;
43
44 this.options = config.options;
45
46 this.uriSpace = config.uriSpace;
47 this.prefixSpace = config.prefixSpace;
48 this.elementSpace = config.elementSpace;
49 this.attributeSpace = config.attributeSpace;
50
51 this.xmlnsToken = config.xmlnsToken;
52
53 this.emptyPrefixToken = config.emptyPrefixToken;
54 this.xmlnsPrefixToken = config.xmlnsPrefixToken;
55 this.processingPrefixToken = config.processingPrefixToken;
56
57 this.uriSet = config.uriSet;
58 this.prefixSet = config.prefixSet;
59
60 this.namespaceList = config.namespaceList;
61 this.namespaceTbl = config.namespaceTbl;
62 this.maxNamespace = config.maxNamespace;
63
64 this.nsMapper = config.nsMapper;
65 } else {
66 this.options = config || {};
67
68 this.uriSpace = new TokenSpace(TokenKind.uri);
69 this.prefixSpace = new TokenSpace(TokenKind.prefix);
70 this.elementSpace = new TokenSpace(TokenKind.element);
71 this.attributeSpace = new TokenSpace(TokenKind.attribute);
72
73 this.xmlnsToken = this.attributeSpace.createToken('xmlns');
74
75 this.uriSet = new TokenSet(this.uriSpace);
76 this.prefixSet = new TokenSet(this.prefixSpace);
77
78 this.namespaceList = [];
79 this.namespaceTbl = {};
80 this.maxNamespace = 0;
81 }
82
83 // this.clonedNamespaceCount = this.maxNamespace;
84
85 if(!native) {
86 this.emptyPrefixToken = this.prefixSet.createToken('');
87 this.xmlnsPrefixToken = this.prefixSet.createToken('xmlns');
88 this.processingPrefixToken = this.prefixSet.createToken('?');
89
90 native = new NativeConfig(this.xmlnsToken.id, this.emptyPrefixToken.id, this.xmlnsPrefixToken.id, this.processingPrefixToken.id);
91 }
92
93 this.native = native;
94
95 if(!this.isLinked && !this.options.omitDefaults) {
96 this.bindNamespace(Namespace.processing);
97 this.bindNamespace(Namespace.unknown);

Callers

nothing calls this directly

Calls 2

bindNamespaceMethod · 0.95
createTokenMethod · 0.45

Tested by

no test coverage detected