How to use the ltx.Element function in ltx

To help you get started, we’ve selected a few ltx 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 kartikrustagi / nodejs-xmpp-server / node_modules / node-xmpp / lib / xmpp / stream_parser.js View on Github external
this.parser.addListener('startElement', function(name, attrs) {
        // TODO: refuse anything but 
        if (!self.element && name == 'stream:stream') {
			//console.log("StreamParser : emitting start");
			//'start' event is captured by Connection (startParser)
            self.emit('start', attrs);
        } else {
	    var child;
            if (!self.element) {
                /* A new stanza */
		child = new Stanza(name, attrs);
                self.element = child;
                self.bytesParsedOnStanzaBegin = self.bytesParsed;
            } else {
                /* A child element of a stanza */
		child = new ltx.Element(name, attrs);
                self.element = self.element.cnode(child);
            }
        }
    });
github webinos / Webinos-Platform / webinos / common / xmpp / lib / xmpp.js View on Github external
resultQuery.c('identity', {'category': 'client', 'type': 'webinos'});
	
    	for (var i in currentFeatures) {
    	    logger.trace('key found: ' + currentFeatures[i]);
    	    var splitted = currentFeatures[i].split('#');
    	    var id = splitted[splitted.length - 1];
	    
    	    logger.trace('Feature id found: ' + id);
	    
    	    if (id && this.sharedFeatures[id]) {
    	        // a webinos feature
    	        logger.trace('Feature found: ' + id);
        	    var feature = this.sharedFeatures[id];

                var instanceNode = new ltx.Element('instance', {'xmlns': 'webinos:rpc#disco', 'id': feature.id });
                instanceNode.cnode(new ltx.Element('displayName').t(feature.displayName));
                instanceNode.cnode(new ltx.Element('description').t(feature.description));

                var featureNode = new ltx.Element('feature', {'var': feature.ns});
                featureNode.cnode(instanceNode);
        		resultQuery.cnode(featureNode);
    	    } else {
    	        // an xmpp feature
    	        var feature = currentFeatures[i];

                var featureNode = new ltx.Element('feature', {'var': feature});
        		resultQuery.cnode(featureNode);
    	    }
    	}
	
    	var result = new xmpp.Element('iq', { 'to': stanza.attrs.from, 'type': 'result', 'id': stanza.attrs.id });
    	result.cnode(resultQuery);
github xmppjs / radiowave / lib / components / Xep0060-pubsub / modules / Publish.js View on Github external
Publish.prototype.buildPublishedStanza = function (node, items) {
  // send response to sender
  var publishDetail = new ltx.Element('publish', {
    node: node.name
  });
  publishDetail.children = items;

  var detail = new ltx.Element(
    'pubsub', {
      'xmlns': 'http://jabber.org/protocol/pubsub'
    }).cnode(publishDetail).up();

  return detail;
};
github microsoft / azure-pipelines-tasks / Tasks / Common / packaging-common / nuget / Utility.ts View on Github external
// strip BOM; xml parser doesn't like it
    if (xmlString.charCodeAt(0) === 0xFEFF) {
        xmlString = xmlString.substr(1);
    }

    // parse sources xml
    let xml: ltx.Element;
    try {
        xml = ltx.parse(xmlString);
    } catch (e) {
        throw new Error(tl.loc("NGCommon_NuGetConfigIsInvalid", configPath));
    }

    // give clearer errors if the user has set an invalid nuget.config
    if(!xml.nameEquals(new ltx.Element("configuration"))) {
        if(xml.nameEquals(new ltx.Element("packages"))) {
            throw new Error(tl.loc(
                "NGCommon_NuGetConfigIsPackagesConfig",
                configPath,
                tl.getVariable("Task.DisplayName")));
        }
        else {
            throw new Error(tl.loc("NGCommon_NuGetConfigIsInvalid", configPath));
        }
    }

    // check that the config contains packageSources entries
    let hasSources = false;
    let packageSources = xml.getChild("packageSources");
    let addPackageSources: ltx.Element[];
    if (packageSources) {
github kartikrustagi / nodejs-xmpp-server / node_modules / node-xmpp / lib / xmpp / c2s.js View on Github external
C2SStream.prototype.onRegistration = function(stanza) {
    var self = this;
    var register = stanza.getChild('query', NS_REGISTER);
    var reply = new ltx.Element('iq', { type: 'result' });
    if (stanza.attrs.id)
        reply.attrs.id = stanza.attrs.id;

    if (stanza.attrs.type === 'get') {
        reply.c('query', { xmlns: NS_REGISTER }).
            c("instructions").t("Choose a username and password for use with this service. ").up().
            c("username").up().
            c("password");
			self.send(reply);
    }
    else if (stanza.attrs.type === 'set') {
        var jid = new JID(register.getChildText('username'), this.server.options.domain_custom)
        this.emit('register', { jid: jid,
                                       username: register.getChildText('username'),
                                       password: register.getChildText('password'),
                                       client: self },
github anoopc / node-xmpp-via-bosh / boshclient.js View on Github external
this.bindResource = function(res_name)
	{
		var resource = new ltx.Element("resource");
		resource.t(res_name);
		var bind = new ltx.Element("bind", {xmlns : NS_XMPP_BIND});
		bind.cnode(resource);
		var iq = new ltx.Element("iq", {id : "bind_1", type : "set", xmlns : NS_CLIENT});
		iq.cnode(bind);
		this.sendXml(iq);
	}
github anoopc / node-xmpp-via-bosh / boshclient.js View on Github external
this.sendMessage = function(to, mbody, type)
	{
		var message = new ltx.Element("message", {to : to, from : this.sess_attr.jid.toString(), type : type || "chat", "xml:lang" : "en"});
		var body = new ltx.Element("body").t(mbody);
		message.cnode(body);
		this.send(message);
	}
github anoopc / node-xmpp-via-bosh / boshclient.js View on Github external
exports.$pres = function(attrib){
	return new ltx.Element("presence", attrib);
}
github buddycloud / buddycloud-http-api / src / account.js View on Github external
function createDeleteAccountIQ() {
  var removeEl = new ltx.Element('iq', { type: 'set' })
        .c('query', { xmlns: 'jabber:iq:register' })
        .c('remove')
  return removeEl.root();
}
github xmppjs / xmpp.js / lib / node-xmpp-server / server.js View on Github external
exports.dialbackResult = function(from, to, isValid) {
    return new ltx.Element(
        'db:result',
        {
            to: to,
            from: from,
            type: isValid ? 'valid' : 'invalid'
        }
    )
}