How to use the xpath.select function in xpath

To help you get started, we’ve selected a few xpath 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 kiliman / operator-mono-lig / gsub.js View on Github external
const buildGsubTables = (_dom, ligature) => {
  dom = _dom;

  if (/_/.test(ligature.glyph) === false) {
    // not a ligature, so see if glyph exists in font (as substitute)
    const glyphNode = xpath.select(
      `ttFont/GlyphOrder/GlyphID[@name="${ligature.name}"]`,
      dom,
      true
    );
    if (!glyphNode) {
      return;
    }
  }

  const glyphs = ligature.name.replace(/\.liga$/, '').split('_');
  const isSingleGlyph = glyphs.length == 1;

  gsubDom = xpath.select('ttFont/GSUB', dom, true);

  // look for 'calt' feature
  featureListDom = xpath.select('FeatureList', gsubDom, true);
github auth0 / node-samlp / lib / utils.js View on Github external
function configureSigningCredentials(xml, cb) {
    if (options.signingCert || options.thumprints) { return cb(null, true) };

    if (!options.getCredentials) {
      return cb(null, false);
    }

    var issuer, sessionIndex, nameId;
    var issuerNode = xpath.select(constants.ELEMENTS[type].ISSUER_PATH, xml);

    if (issuerNode && issuerNode.length > 0) {
      issuer = issuerNode[0].textContent;
    }

    // If LogoutRequest, we should check sessionIndex too
    if (constants.ELEMENTS[type].SESSION_INDEX_PATH){
      var sessionIndexNode = xpath.select(constants.ELEMENTS[type].SESSION_INDEX_PATH, xml);
      if (sessionIndexNode && sessionIndexNode.length > 0) {
        sessionIndex = sessionIndexNode[0].textContent;
      }
    }

    // If LogoutRequest, we should check sessionIndex too
    if (constants.ELEMENTS[type].NAME_ID){
      var nameIdNode = xpath.select(constants.ELEMENTS[type].NAME_ID, xml);
github yaronn / xml-crypto / lib / enveloped-signature.js View on Github external
EnvelopedSignature.prototype.process = function (node, options) {
  if (null == options.signatureNode) {
    // leave this for the moment...
    var signature = xpath.select("./*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']", node)[0];
    if (signature) signature.parentNode.removeChild(signature);
    return node;
  }
  var signatureNode = options.signatureNode;
  var expectedSignatureValue = utils.findFirst(signatureNode, ".//*[local-name(.)='SignatureValue']/text()").data;
  var signatures = xpath.select(".//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']", node);
  for (var h in signatures) {
    if (!signatures.hasOwnProperty(h)) continue;
    var signature = signatures[h];
    var signatureValue = utils.findFirst(signature, ".//*[local-name(.)='SignatureValue']/text()").data;
    if (expectedSignatureValue === signatureValue) {
      signature.parentNode.removeChild(signature);
    }
  }
  return node;
};
github kiliman / operator-mono-lig / index.js View on Github external
);

  // patch CFFFont
  const cffFont = xpath.select('/ttFont/CFF/CFFFont', dom, true);

  cffFont.setAttribute('name', ligFontName);
  setAttribute(cffFont, 'FullName', 'value', fullName);
  setAttribute(cffFont, 'FamilyName', 'value', familyName);

  const charStrings = xpath.select('/CharStrings/CharString', configDom);
  const targetCharStrings = xpath.select('CharStrings', cffFont, true);

  const subrs = {
    map: [],
    source: await loadConfigAsync('subrs'),
    target: xpath.select('/ttFont/CFF/CFFFont/Private/Subrs', dom, true)
  };
  const gsubrs = {
    map: [],
    source: await loadConfigAsync('gsubrs'),
    target: xpath.select('/ttFont/CFF/GlobalSubrs', dom, true)
  };

  charStrings.forEach(node => {
    patchCharStringSubrs(node, subrs, gsubrs);
    targetCharStrings.appendChild(node);
  });
}
github SunGard-Labs / fix2json / fix2json.js View on Github external
var fieldName = groupFields[l].attributes[0].value;
                componentGroupFields[componentName][componentGroupName].push(fieldName);
            }

            var groupComponents = componentGroups[k].getElementsByTagName('component');
            for (l = 0; l < groupComponents.length; l++) {
                var compName = groupComponents[l].attributes[0].value;
                componentGroupFields[componentName][componentGroupName] = componentGroupFields[componentName][componentGroupName].concat(flattenComponent(compName, dom));
            }

        }

    }

    var names = messageNames(dom);
    var messages = xpath.select('//fix/messages/message', dom);

    for (var m = 0; m < messages.length; m++) {
        var messageName = messages[m].attributes[0].value;
        GROUPS[messageName] = {};
        var messageComponents = messages[m].getElementsByTagName('component');

        for (var n = 0; n < messageComponents.length; n++) {
            var componentName = messageComponents[n].attributes[0].value;
            var groupNames = Object.keys(componentGroupFields[componentName]);

            for (o = 0; o < groupNames.length; o++) { // collapse fields into GROUPS index
                GROUPS[messageName][groupNames[o]] = componentGroupFields[componentName][groupNames[o]];
            }
        }
    }
}
github gongfuPanada / node-dynamicscrm-api / lib / util.js View on Github external
res.on('end', function () {
                var resXml = domParser.parseFromString(xml); 
                
                var fault = xpath.select(faultTextXpath, resXml);
                if (fault.length > 0)  return cb(new Error(fault.toString()),null);


                var location = xpath.select("//*[local-name()='import' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']/@location", resXml).map(function(attr) 
                    { return attr.value;})[0];

                if (location.length > 0) {
                    var opts = {
                        host: urljs.parse(location).host,
                        path: urljs.parse(location).pathname + urljs.parse(location).search
                    };    

                    var response = https.get (opts, function(res) {
                        var xml = '';
                        res.setEncoding('utf8');
                        res.on('data', function (chunk) { xml += chunk; })
                        res.on('end', function () {

                            var resXml = domParser.parseFromString(xml);
                            var fault = xpath.select(faultTextXpath, resXml);
github SunGard-Labs / fix2json / fix2json.js View on Github external
function messageNames(dom) {

    var messages = [];
    var path = '//fix/messages/message';
    var msgs = xpath.select(path, dom);

    for (var i = 0; i < msgs.length; i++) {
        messages.push({
            type: msgs[i].attributes[2].value,
            name: msgs[i].attributes[0].value
        });
    }

    MESSAGES = messages;

}
github node-ebics / node-ebics-client / lib / orders / H004 / response.js View on Github external
bankKeys() {
		const orderData = this.orderData().toString();
		if (!Object.keys(orderData).length) return {};

		const doc = new DOMParser().parseFromString(orderData, 'text/xml');
		const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
		const keyNodes = select('//xmlns:PubKeyValue', doc);
		const bankKeys = {};

		if (!keyNodes.length) return {};

		for (let i = 0; i < keyNodes.length; i++) {
			const type = lastChild(keyNodes[i].parentNode).textContent;
			const modulus = xpath.select(".//*[local-name(.)='Modulus']", keyNodes[i])[0].textContent;
			const exponent = xpath.select(".//*[local-name(.)='Exponent']", keyNodes[i])[0].textContent;

			const mod = Buffer.from(modulus, 'base64');
			const exp = Buffer.from(exponent, 'base64');
			bankKeys[`bank${type}`] = {
				mod,
				exp,
			};
		}

		return bankKeys;
	},
github SunGard-Labs / fix2json / fix2json.js View on Github external
function getFixVer(dom) {

    var fixMaj = xpath.select("//fix/@major", dom)[0].value;
    var fixMin = xpath.select("//fix/@minor", dom)[0].value;
    var fixSp = xpath.select("//fix/@servicepack", dom)[0].value;
    FIX_VER = [fixMaj, fixMin, fixSp].join('.');

}
github apigee / apigeelint / lib / package / Endpoint.js View on Github external
Endpoint.prototype.getFlows = function() {
  if (!this.flows) {
    var doc = xpath.select("//Flows", this.element),
      ep = this;
    ep.flows = [];
    if (doc) {
      doc.forEach(function(flowsElement) {
        //flows get a flow from here
        var fdoc = xpath.select("./Flow", flowsElement);
        if (fdoc) {
          fdoc.forEach(function(flowElement) {
            ep.flows.push(new Flow(flowElement, ep));
          });
        }
      });
    }
  }
  return this.flows;
};

xpath

DOM 3 XPath implemention and helper for node.js and the web

MIT
Latest version published 11 months ago

Package Health Score

77 / 100
Full package analysis