'use strict'; // import fs from "fs" // import path from "path" // import { dirname } from 'node:path'; // import { fileURLToPath } from 'node:url'; // const __dirname = dirname(fileURLToPath(import.meta.url)); /** * Generate a flat XML document with `n` sibling elements. * Each element has `attrCount` attributes and a text body. * Shape: text ... */ export function makeFlat(elementCount, attrCount = 2) { const attrs = Array.from({ length: attrCount }, (_, i) => `a${i}="v${i}"`).join(' '); let xml = '\n\n'; for (let i = 0; i < elementCount; i++) { xml += ` text content ${i}\n`; } xml += ''; return xml; } /** * Generate a deeply nested XML document with `depth` levels and `breadth` * children per level. * Shape: …text… */ export function makeDeep(depth, breadth = 2) { function nest(d) { if (d === 0) return `text at depth ${depth}`; const tag = `l${depth - d}`; const children = Array.from({ length: breadth }, () => nest(d - 1)).join(''); return `<${tag}>${children}`; } // console.log(nest(depth)) return `${nest(depth)}`; } /** * Generate XML with embedded comments and CDATA, plus processing instructions. * Includes a run of unpaired tags (
style handled as unpaired, not * self-closing) interleaved so the `isUnpaired` branch in readOpeningTag is * exercised too — pass `tags.unpaired: ['br']` in fxpOptions when using this * fixture, or the
tags will just parse as ordinary empty elements. */ export function makeMixed(elementCount) { let xml = '\n\n\n'; for (let i = 0; i < elementCount; i++) { xml += ` \n`; xml += ` ${i}]]>\n`; // xml += `
\n`; //SAX and SAXES doesn't support unpaired tags } xml += '
'; return xml; } /** * Generate an SVG-shaped document: xmlns-prefixed root, deep nesting, * and many elements with long `d` attribute values — stresses * AttributeProcessor's per-char scan on long attribute strings and * readOpeningTag's namespace extraction (colonIdx split on every tag). * * Shape: ...... * * @param {number} pathCount number of leaves * @param {number} groupDepth levels of nested wrapping the paths * @param {number} pathLength number of "L x y" segments per path's `d` attr */ export function makeSvg(pathCount, groupDepth = 4, pathLength = 40) { const d = 'M0 0 ' + Array.from({ length: pathLength }, (_, i) => `L${i} ${i * 2}`).join(' '); let inner = ''; for (let i = 0; i < pathCount; i++) { inner += ``; } for (let i = 0; i < groupDepth; i++) inner = `${inner}`; return `\n` + `` + inner + ``; } /** * Generate an HTML-shaped document with \n`; xml += `
content ${i}
\n`; } xml += ''; return xml; } export function loadXml() { //return fs.readFileSync(path.join(__dirname, 'mini-sample.xml')).toString(); // saxes 2x // return "" //saxes 3x // return ` // // // // // // // // // // // // // // // // // // // // ` // return `${"text".repeat(20)}` return `${"text".repeat(20)}` }