How to use saxes - 3 common examples

To help you get started, we’ve selected a few saxes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exceljs / exceljs / spec / unit / xlsx / xform / test-xform-helper.js View on Github external
result.post = true;
        const xform = new CompositeXform({
          tag: 'compy',
          children: [
            {
              name: 'pre',
              xform: new BooleanXform({ tag: 'pre', attr: 'val' }),
            },
            { name: childXform.tag, xform: childXform },
            {
              name: 'post',
              xform: new BooleanXform({ tag: 'post', attr: 'val' }),
            },
          ],
        });
        const parser = new saxes.SaxesParser();

        xform
          .parse(parser)
          .then(model => {
            // console.log('parsed Model', JSON.stringify(model));
            // console.log('expected Model', JSON.stringify(result));

            // eliminate the undefined
            const clone = _.cloneDeep(model, false);

            // console.log('result', JSON.stringify(clone));
            // console.log('expect', JSON.stringify(result));
            expect(clone).to.deep.equal(result);
            resolve();
          })
          .catch(reject);
github jsdom / jsdom / lib / jsdom / browser / parser / xml.js View on Github external
function createParser(rootNode, globalObject, saxesOptions) {
  const parser = new SaxesParser({
    ...saxesOptions,
    // Browsers always have namespace support.
    xmlns: true,
    // We force the parser to treat all documents (even documents declaring themselves to be XML 1.1 documents) as XML
    // 1.0 documents. See https://github.com/jsdom/jsdom/issues/2677 for a discussion of the stakes.
    defaultXMLVersion: "1.0",
    forceXMLVersion: true
  });
  const openStack = [rootNode];

  function getOwnerDocument() {
    const currentElement = openStack[openStack.length - 1];

    return isHTMLTemplateElement(currentElement) ?
      currentElement._templateContents._ownerDocument :
      currentElement._ownerDocument;
github michaelnisi / pickup / index.js View on Github external
this.encoding = encodingFromOpts(opts)
  this.decoder = new StringDecoder(this.encoding)

  this.eventMode = opts && opts.eventMode

  this.state = new State(
    null,
    null,
    false,
    new Map(),
    '',
    new Set(['content:encoded', 'pubDate'])
  )

  const parser = new sax.SaxesParser(opts ? opts.parser : null)

  parser.ontext = (text) => {
    const t = text.trim()

    if (t.length === 0) {
      debug('discarding text: whitespace')
      return
    }

    const state = this.state
    const current = state.entry || state.feed

    if (!current || !state.map) return

    let key = state.key()

saxes

An evented streaming XML parser in JavaScript

ISC
Latest version published 2 years ago

Package Health Score

76 / 100
Full package analysis

Popular saxes functions