How to use the xmldom.DOMImplementation function in xmldom

To help you get started, we’ve selected a few xmldom 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 cascornelissen / svg-spritemap-webpack-plugin / lib / generate-svg.js View on Github external
return new Promise((resolve, reject) => {
        // No point in generating when there are no files
        if ( !files.length ) {
            return resolve();
        }

        // Initialize DOM/XML/SVGO
        const DOMParser = new xmldom.DOMParser();
        const XMLSerializer = new xmldom.XMLSerializer();
        const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);
        const SVGOptimizer = new svgo(merge(options.output.svgo, {
            plugins: [
                // Prevent empty var:* attributes from getting removed prematurely
                { removeEmptyAttrs: false },

                // Prevent groups from getting optimized prematurely as they may contain var:* attributes
                { moveGroupAttrsToElems: false },
                { collapseGroups: false },

                // Prevent titles from getting removed prematurely
                { removeTitle: false }
            ]
        }));

        // Create SVG element
        const svg = XMLDoc.createElement('svg');
github linkedinlabs / icon-magic / packages / @icon-magic / distribute / src / create-sprite.ts View on Github external
export function createSVGDoc(): { DOCUMENT: Document; svgEl: SVGSVGElement } {
  LOGGER.debug(`in create svg doc`);
  const DOM = new DOMImplementation();
  const doctype = DOM.createDocumentType(
    'svg',
    '-//W3C//DTD SVG 1.1//EN',
    'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
  );
  const SVG_NS = 'http://www.w3.org/2000/svg';
  // Create an SVG Document and set its doctype
  const DOCUMENT = DOM.createDocument(SVG_NS, 'svg', doctype);
  // Create SVG element
  const svgEl = DOCUMENT.createElementNS(SVG_NS, 'svg');
  svgEl.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
  svgEl.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
  svgEl.setAttribute('version', '1.1');
  // Add <svg> element to SVG Document
  DOCUMENT.appendChild(svgEl);
  LOGGER.debug(`creating svg document ${DOCUMENT}`);</svg>
github cascornelissen / svg-spritemap-webpack-plugin / lib / style-formatters / scss.js View on Github external
view: ''
        },
        format: {
            type: 'data',
            publicPath: ''
        },
        variables: {
            sprites: 'sprites',
            variables: 'variables',
            sizes: 'sizes',
            mixin: 'sprite'
        }
    }, options);

    const XMLSerializer = new xmldom.XMLSerializer();
    const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);

    const output = symbols.reduce((accumulator, symbol) => {
        const svg = XMLDoc.createElement('svg');
        svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
        svg.setAttribute('viewBox', symbol.getAttribute('viewBox'));

        // Clone symbol contents to svg
        Array.from(symbol.childNodes).forEach((childNode) => {
            if ( ['title'].includes(childNode.nodeName.toLowerCase()) ) {
                return;
            }

            svg.appendChild(childNode);
        });

        const sprite = XMLSerializer.serializeToString(svg);
github cascornelissen / svg-spritemap-webpack-plugin / lib / style-formatters / css.js View on Github external
module.exports = (symbols = [], options = {}) => {
    options = merge({
        prefix: '',
        postfix: {
            symbol: '',
            view: ''
        },
        format: {
            type: 'data',
            publicPath: ''
        }
    }, options);

    const XMLSerializer = new xmldom.XMLSerializer();
    const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);

    const sprites = symbols.map((symbol) => {
        const svg = XMLDoc.createElement('svg');
        svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
        svg.setAttribute('viewBox', symbol.getAttribute('viewBox'));

        // Clone symbol contents to svg
        Array.from(symbol.childNodes).forEach((childNode) => {
            if ( ['title'].includes(childNode.nodeName.toLowerCase()) ) {
                return;
            }

            svg.appendChild(childNode);
        });

        const selector = symbol.getAttribute('id').replace(options.postfix.symbol, '');
github testem / testem / lib / reporters / xunit_reporter.js View on Github external
summaryDisplay() {
    var doc = new XmlDom.DOMImplementation().createDocument('', 'testsuite');

    var rootNode = doc.documentElement;
    rootNode.setAttribute('name', 'Testem Tests');
    rootNode.setAttribute('tests', this.total);
    rootNode.setAttribute('skipped', this.skipped);
    rootNode.setAttribute('failures', this.failures());
    rootNode.setAttribute('timestamp', new Date());
    rootNode.setAttribute('time', this.duration());

    for (var i = 0, len = this.results.length; i &lt; len; i++) {
      var testcaseNode = this.getTestResultNode(doc, this.results[i]);
      rootNode.appendChild(testcaseNode);
    }
    return doc.documentElement.toString();
  }
github mapcontrib / mapcontrib / public / js / helper / osmEdit.js View on Github external
_buildXml(changesetId) {
    const xml = new DOMImplementation().createDocument('', '', null);
    const osmElement = xml.createElement('osm');
    const parentElement = xml.createElement(this._element.type);

    delete this._element.attributes.user;

    this._element.attributes.changeset = changesetId;

    for (const key in this._element.attributes) {
      if ({}.hasOwnProperty.call(this._element.attributes, key)) {
        parentElement.setAttribute(key, this._element.attributes[key]);
      }
    }

    for (const tag of this._element.tags) {
      const tagElement = xml.createElement('tag');
github microsoft / azure-pipelines-tasks / Tasks / Common / webdeployment-common / xmlvariablesubstitutionutility.ts View on Github external
import Q = require('q');
import tl = require('vsts-task-lib/task');
import fs = require('fs');

var utility = require ('./utility.js');
var xmldom = require('xmldom');
var serializer = new xmldom.XMLSerializer;
var implementation = new xmldom.DOMImplementation;

export async function substituteAppSettingsVariables(folderPath) {
    var configFiles = tl.glob(folderPath + "/**/*config");
    var tags = ["applicationSettings", "appSettings", "connectionStrings", "configSections"];
    for(var index in configFiles) {
        await substituteXmlVariables(configFiles[index], tags);
    }
}

async function substituteXmlVariables(configFile, tags){
    if(!tl.exist(configFile)) {
        throw new Error(tl.loc("Configfiledoesntexists", configFile));
    }
    if( !tl.stats(configFile).isFile()) {
        return;
    }
github mapcontrib / mapcontrib / public / js / helper / osmEdit.js View on Github external
_buildChangesetXml() {
    const xml = new DOMImplementation().createDocument('', '', null);
    const osmElement = xml.createElement('osm');
    const changesetElement = xml.createElement('changeset');
    const createdByElement = xml.createElement('tag');
    const commentElement = xml.createElement('tag');

    createdByElement.setAttribute('k', 'created_by');
    createdByElement.setAttribute('v', this._changesetCreatedBy);
    changesetElement.appendChild(createdByElement);

    commentElement.setAttribute('k', 'comment');
    commentElement.setAttribute('v', this._changesetComment);
    changesetElement.appendChild(commentElement);

    osmElement.appendChild(changesetElement);
    xml.appendChild(osmElement);
github cliqz-oss / browser-core / fern / reporter.js View on Github external
summaryDisplay() {
    const doc = new XmlDom.DOMImplementation().createDocument('', 'testsuite');

    const rootNode = doc.documentElement;
    rootNode.setAttribute('name', 'Testem Tests');
    rootNode.setAttribute('tests', this.total);
    rootNode.setAttribute('skipped', this.skipped);
    rootNode.setAttribute('failures', this.failures());
    rootNode.setAttribute('timestamp', new Date());
    rootNode.setAttribute('time', this.duration());

    for (let i = 0, len = this.results.length; i &lt; len; i += 1) {
      const testcaseNode = this.getTestResultNode(doc, this.results[i]);
      rootNode.appendChild(testcaseNode);
    }
    return doc.documentElement.toString();
  },
  display() {
github LeanKit-Labs / seriate / src / asTable.js View on Github external
var _ = require( "lodash" );
var sql = require( "mssql" );
var xmldom = require( "xmldom" );
var domImplementation = new xmldom.DOMImplementation();
var xmlSerializer = new xmldom.XMLSerializer();
var buildTableVariableSql = require( "./build-table-variable-sql" );
var xmldom = require( "xmldom" );

function toXml( values, schema ) {
	var doc = domImplementation.createDocument();
	var keys = _.keys( schema );

	var root = values.map( function( obj ) {
		return keys.reduce( function( row, key ) {
			var value = obj[ key ];
			if ( value !== null && value !== undefined ) {
				row.setAttribute( key, _.isDate( value ) ? value.toISOString() : value );
			}
			return row;
		}, doc.createElement( "row" ) );

xmldom

A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis