MCPcopy Create free account
hub / github.com/denoland/std / finalize

Method finalize

xml/_parser.ts:682–698  ·  view source on GitHub ↗

* Finalize parsing and validate that all elements are closed. * * @throws {XmlSyntaxError} If there are unclosed elements or no root element.

()

Source from the content-addressed store, hash-verified

680 * @throws {XmlSyntaxError} If there are unclosed elements or no root element.
681 */
682 finalize(): void {
683 if (this.#elementStack.length > 0) {
684 const unclosed = this.#elementStack[this.#elementStack.length - 1]!;
685 throw new XmlSyntaxError(
686 `Unclosed element <${unclosed.rawName}>`,
687 unclosed,
688 );
689 }
690
691 // XML 1.0 §2.1: A well-formed document must have exactly one root element
692 if (!this.#hasRoot) {
693 throw new XmlSyntaxError(
694 "No root element found in XML document",
695 { line: 0, column: 0, offset: 0 },
696 );
697 }
698 }
699}

Callers 4

collectEventsFunction · 0.95
_tokenizer_test.tsFile · 0.45
parseXmlRecordsFunction · 0.45
parseXmlStreamFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected