Skip to content

Commit 68d6a21

Browse files
committed
Renamed class and fixed typos
1 parent 20fbfd2 commit 68d6a21

8 files changed

Lines changed: 123 additions & 27 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "typesxml",
33
"productName": "TypesXML",
4-
"version": "1.18.0",
4+
"version": "1.19.0",
55
"description": "Open source XML library written in TypeScript",
66
"keywords": [
77
"XML",
@@ -47,7 +47,7 @@
4747
"url": "https://github.com/rmraya/TypesXML.git"
4848
},
4949
"devDependencies": {
50-
"@types/node": "^24.12.0",
50+
"@types/node": "^24.12.2",
5151
"typescript": "^6.0.2"
5252
}
5353
}

ts/XMLAttribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class XMLAttribute implements XMLNode {
3232
return this.value;
3333
}
3434

35-
setvalue(value: string): void {
35+
setValue(value: string): void {
3636
this.value = value;
3737
}
3838

ts/dtd/ContentModel.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ContentParticle } from "./contentParticle.js";
1414
import { DTDChoice } from "./dtdChoice.js";
1515
import { DTDName } from "./dtdName.js";
1616
import { DTDPCData } from "./dtdPCData.js";
17-
import { DTDSecuence } from "./dtdSecuence.js";
17+
import { DTDSequence } from "./dtdSequence.js";
1818

1919
export const Cardinality = {
2020
NONE: 0, // (exactly one)
@@ -174,7 +174,7 @@ export class ContentModel {
174174
}
175175

176176
isContentParticle(obj: any): boolean {
177-
return obj instanceof DTDName || obj instanceof DTDChoice || obj instanceof DTDSecuence || obj instanceof DTDPCData;
177+
return obj instanceof DTDName || obj instanceof DTDChoice || obj instanceof DTDSequence || obj instanceof DTDPCData;
178178
}
179179

180180
processGroup(group: Array<any>): ContentParticle {
@@ -189,8 +189,8 @@ export class ContentModel {
189189
if (obj instanceof DTDChoice) {
190190
return obj as DTDChoice;
191191
}
192-
if (obj instanceof DTDSecuence) {
193-
return obj as DTDSecuence;
192+
if (obj instanceof DTDSequence) {
193+
return obj as DTDSequence;
194194
}
195195
if (obj instanceof DTDName) {
196196
return obj as DTDName;
@@ -212,7 +212,7 @@ export class ContentModel {
212212
if (sep === null) {
213213
throw new Error('No separator found when parsing group');
214214
}
215-
let result: ContentParticle = sep === "|" ? new DTDChoice() : new DTDSecuence();
215+
let result: ContentParticle = sep === "|" ? new DTDChoice() : new DTDSequence();
216216
for (let obj of group) {
217217
if (obj === "|" || obj === ",") {
218218
continue;
@@ -221,7 +221,7 @@ export class ContentModel {
221221
result.addParticle(new DTDName(obj));
222222
} else if (obj instanceof DTDChoice) {
223223
result.addParticle(obj);
224-
} else if (obj instanceof DTDSecuence) {
224+
} else if (obj instanceof DTDSequence) {
225225
result.addParticle(obj);
226226
} else if (obj instanceof DTDName) {
227227
result.addParticle(obj);
@@ -292,8 +292,8 @@ export class ContentModel {
292292
children.add(child);
293293
}
294294
}
295-
if (particle instanceof DTDSecuence) {
296-
const sequence = particle as DTDSecuence;
295+
if (particle instanceof DTDSequence) {
296+
const sequence = particle as DTDSequence;
297297
for (const child of sequence.getChildren()) {
298298
children.add(child);
299299
}
@@ -336,7 +336,7 @@ export class ContentModel {
336336
if (particle instanceof DTDName) {
337337
return this.matchNameParticle(particle, children, start);
338338
}
339-
if (particle instanceof DTDSecuence) {
339+
if (particle instanceof DTDSequence) {
340340
return this.matchSequenceParticle(particle, children, start);
341341
}
342342
if (particle instanceof DTDChoice) {
@@ -363,7 +363,7 @@ export class ContentModel {
363363
return index;
364364
}
365365

366-
private matchSequenceParticle(sequence: DTDSecuence, children: string[], start: number): number {
366+
private matchSequenceParticle(sequence: DTDSequence, children: string[], start: number): number {
367367
const min:number = this.getMinOccurs(sequence.getCardinality());
368368
const max: number = this.getMaxOccurs(sequence.getCardinality());
369369
let index: number = start;
@@ -416,7 +416,7 @@ export class ContentModel {
416416
return index;
417417
}
418418

419-
private matchSequenceOnce(sequence: DTDSecuence, children: string[], start: number): number {
419+
private matchSequenceOnce(sequence: DTDSequence, children: string[], start: number): number {
420420
let index:number = start;
421421
for (const subParticle of sequence.getParticles()) {
422422
const nextIndex: number = this.matchParticle(subParticle, children, index);

ts/dtd/dtdChoice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { Cardinality } from "./ContentModel.js";
1414
import { ContentParticle, ContentParticleType } from "./contentParticle.js";
1515
import { DTDName } from "./dtdName.js";
16-
import { DTDSecuence } from "./dtdSecuence.js";
16+
import { DTDSequence } from "./dtdSequence.js";
1717

1818
export class DTDChoice implements ContentParticle {
1919

@@ -83,8 +83,8 @@ export class DTDChoice implements ContentParticle {
8383
children.add(child);
8484
}
8585
}
86-
if (particle instanceof DTDSecuence) {
87-
let sequence = particle as DTDSecuence;
86+
if (particle instanceof DTDSequence) {
87+
let sequence = particle as DTDSequence;
8888
// add all the children of the sequence
8989
for (const child of sequence.getChildren()) {
9090
children.add(child);

ts/dtd/dtdSecuence.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ContentParticle, ContentParticleType } from "./contentParticle.js";
1515
import { DTDChoice } from "./dtdChoice.js";
1616
import { DTDName } from "./dtdName.js";
1717

18-
export class DTDSecuence implements ContentParticle {
18+
export class DTDSequence implements ContentParticle {
1919

2020
private cardinality: typeof Cardinality[keyof typeof Cardinality];
2121
private content: Array<ContentParticle>;
@@ -83,8 +83,8 @@ export class DTDSecuence implements ContentParticle {
8383
children.add(child);
8484
}
8585
}
86-
if (particle instanceof DTDSecuence) {
87-
let sequence = particle as DTDSecuence;
86+
if (particle instanceof DTDSequence) {
87+
let sequence = particle as DTDSequence;
8888
// add all the children of the sequence
8989
for (const child of sequence.getChildren()) {
9090
children.add(child);

ts/dtd/dtdSequence.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 { Cardinality } from "./ContentModel.js";
14+
import { ContentParticle, ContentParticleType } from "./contentParticle.js";
15+
import { DTDChoice } from "./dtdChoice.js";
16+
import { DTDName } from "./dtdName.js";
17+
18+
export class DTDSequence implements ContentParticle {
19+
20+
private cardinality: typeof Cardinality[keyof typeof Cardinality];
21+
private content: Array<ContentParticle>;
22+
23+
constructor() {
24+
this.content = new Array<ContentParticle>();
25+
this.cardinality = Cardinality.NONE;
26+
}
27+
28+
public addParticle(particle: ContentParticle) {
29+
this.content.push(particle);
30+
}
31+
32+
getType(): typeof ContentParticleType[keyof typeof ContentParticleType] {
33+
return ContentParticleType.SEQUENCE;
34+
}
35+
36+
setCardinality(cardinality: typeof Cardinality[keyof typeof Cardinality]) {
37+
this.cardinality = cardinality;
38+
}
39+
40+
getCardinality(): typeof Cardinality[keyof typeof Cardinality] {
41+
return this.cardinality;
42+
}
43+
44+
toString() {
45+
let sb: string = '(';
46+
for (let i: number = 0; i < this.content.length; i++) {
47+
let particle = this.content[i];
48+
sb = sb + particle.toString();
49+
if (i < this.content.length - 1) {
50+
sb = sb + ',';
51+
}
52+
}
53+
sb = sb + ')';
54+
switch (this.cardinality) {
55+
case Cardinality.NONE:
56+
return sb.toString();
57+
case Cardinality.OPTIONAL:
58+
return sb + "?";
59+
case Cardinality.ONEMANY:
60+
return sb + "+";
61+
case Cardinality.ZEROMANY:
62+
return sb + "*";
63+
default:
64+
// ignore
65+
}
66+
return sb.toString();
67+
}
68+
69+
getParticles(): Array<ContentParticle> {
70+
return this.content;
71+
}
72+
73+
getChildren(): Set<string> {
74+
const children: Set<string> = new Set<string>();
75+
for (const particle of this.content) {
76+
if (particle instanceof DTDName) {
77+
children.add(particle.getName());
78+
}
79+
if (particle instanceof DTDChoice) {
80+
let choice = particle as DTDChoice;
81+
// add all the children of the choice
82+
for (const child of choice.getChildren()) {
83+
children.add(child);
84+
}
85+
}
86+
if (particle instanceof DTDSequence) {
87+
let sequence = particle as DTDSequence;
88+
// add all the children of the sequence
89+
for (const child of sequence.getChildren()) {
90+
children.add(child);
91+
}
92+
}
93+
}
94+
return children;
95+
}
96+
}

ts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export { DTDGrammar } from "./dtd/DTDGrammar.js";
5050
export { DTDName } from "./dtd/dtdName.js";
5151
export { DTDPCData } from "./dtd/dtdPCData.js";
5252
export { DTDSequenceModel } from "./dtd/DTDSequenceModel.js";
53-
export { DTDSecuence } from "./dtd/dtdSecuence.js";
53+
export { DTDSequence } from "./dtd/dtdSequence.js";
5454
export { ElementDecl } from "./dtd/ElementDecl.js";
5555
export { EntityDecl } from "./dtd/EntityDecl.js";
5656
export { NotationDecl } from "./dtd/NotationDecl.js";

0 commit comments

Comments
 (0)