Skip to content

Commit f2df0b6

Browse files
committed
Merge branch 'main' of https://github.com/rmraya/TypesXML
2 parents 08f6f7d + 269cfcc commit f2df0b6

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

ts/tests/RootAttributeHandler.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023-2026 Maxprograms.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 1.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/org/documents/epl-v10.html
8+
*
9+
* Contributors:
10+
* Maxprograms - initial API and implementation
11+
*******************************************************************************/
12+
13+
import { Catalog } from '../Catalog.js';
14+
import { ContentHandler } from '../ContentHandler.js';
15+
import { Grammar } from '../grammar/Grammar.js';
16+
import { XMLAttribute } from '../XMLAttribute.js';
17+
18+
export class RootAttributeHandler implements ContentHandler {
19+
20+
private grammar: Grammar | undefined;
21+
private rootSeen: boolean = false;
22+
23+
hasSchemaRef(): boolean {
24+
return this.grammar !== undefined;
25+
}
26+
27+
initialize(): void {}
28+
setCatalog(_catalog: Catalog): void {}
29+
startDocument(): void {}
30+
endDocument(): void {}
31+
xmlDeclaration(_version: string, _encoding: string, _standalone: string | undefined): void {}
32+
33+
startElement(_name: string, _atts: Array<XMLAttribute>): void {
34+
if (!this.rootSeen) {
35+
this.rootSeen = true;
36+
return;
37+
}
38+
throw new Error('RootAttributeHandler: root seen');
39+
}
40+
41+
endElement(_name: string): void {}
42+
internalSubset(_declaration: string): void {}
43+
characters(_ch: string): void {}
44+
ignorableWhitespace(_ch: string): void {}
45+
comment(_ch: string): void {}
46+
processingInstruction(_target: string, _data: string): void {}
47+
startCDATA(): void {}
48+
endCDATA(): void {}
49+
startDTD(_name: string, _publicId: string, _systemId: string): void {}
50+
endDTD(): void {}
51+
skippedEntity(_name: string): void {}
52+
getCurrentText(): string { return ''; }
53+
54+
getGrammar(): Grammar | undefined {
55+
return this.grammar;
56+
}
57+
58+
setGrammar(grammar: Grammar | undefined): void {
59+
this.grammar = grammar;
60+
}
61+
}

0 commit comments

Comments
 (0)