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

Method onStartTagOpen

xml/_parser.ts:195–228  ·  view source on GitHub ↗
(
    name: string,
    line: number,
    column: number,
    offset: number,
  )

Source from the content-addressed store, hash-verified

193 // XmlTokenCallbacks implementation
194
195 onStartTagOpen(
196 name: string,
197 line: number,
198 column: number,
199 offset: number,
200 ): void {
201 const colonIndex = name.indexOf(":");
202
203 // Validate QName syntax (Namespaces §3)
204 const qnameError = validateQName(name, colonIndex);
205 if (qnameError) {
206 throw new XmlSyntaxError(
207 `Invalid element name '${name}': ${qnameError}`,
208 { line, column, offset },
209 );
210 }
211
212 // Elements cannot use xmlns prefix (Namespaces 1.0 errata NE08)
213 if (colonIndex !== -1 && name.startsWith("xmlns:")) {
214 throw new XmlSyntaxError(
215 "Element name cannot use the 'xmlns' prefix",
216 { line, column, offset },
217 );
218 }
219
220 this.#pendingName = name;
221 this.#pendingColonIndex = colonIndex;
222 this.#pendingLine = line;
223 this.#pendingColumn = column;
224 this.#pendingOffset = offset;
225 this.#hasPendingElement = true;
226 this.#attrIterator._reset();
227 this.#pendingNsBindings.length = 0; // Reset for new element
228 }
229
230 onAttribute(name: string, value: string): void {
231 if (this.#hasPendingElement) {

Callers

nothing calls this directly

Calls 3

validateQNameFunction · 0.90
startsWithMethod · 0.80
_resetMethod · 0.80

Tested by

no test coverage detected