How to use libxslt - 10 common examples

To help you get started, we’ve selected a few libxslt 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 fireflylearning / pattern-library / src / gulp-plugins / gulp-mdtoXSLT.js View on Github external
return through.obj(function(file, enc, callback) {
        var context = getContext(file);
        var t = this;
        // output(context);
        var templateXMLPath = getXMLPath(file, context);
        var templateXSLPath = getXSLPath(file, context);
        if(debug) gutil.log(templateXMLPath, templateXSLPath);

        var documentString = renderer.renderFile(templateXMLPath, context);
        context.xmlDocumentString = documentString.replace('', '');
        var stylesheetString = renderer.renderFile(templateXSLPath, context);
        output(documentString);
        output(stylesheetString);

        libxslt.parse(stylesheetString, function(err, stylesheet) {

            if (err) {
                alwaysOutput('\n\n' + stylesheetString);
                t.emit('error', new PluginError({
                    plugin: 'MdtoXSLT',
                    message: 'Error parsing xsl stylesheet: ' + file.path + '; failed with error: ' + err
                }));
                return callback();
            }

            stylesheet.apply(documentString, {}, function(err, result) {

                if (err) {
                    gutil.log(file.path);
                    alwaysOutput('\n\n' + documentString);
                    t.emit('error', new PluginError({
github microsoft / ELL / interfaces / javascript / swigToTypescript / templates / index.js View on Github external
var fs = require('fs');
var libxslt = require('libxslt');

var xsltFilename = process.argv[2];
var documentFilename = process.argv[3];
var outputFilename = process.argv[4];

libxslt.parseFile(xsltFilename, function (err, stylesheet) {
    if (err) {
        console.log("Error during XSLT parsing:");
        console.log(err);
        return;
    }

    stylesheet.applyToFile(documentFilename, function (err, result) {
        // err contains any error from parsing the document or applying the stylesheet 
        // result is a string containing the result of the transformation 
        fs.writeFile(outputFilename, result);
    });
});
github kobotoolbox / enketo-express / app / models / manifest-model.js View on Github external
/**
 * @module manifest-model
 */

const libxml = require( 'libxslt' ).libxmljs;
const url = require( 'url' );
const path = require( 'path' );
const fs = require( 'fs' );
const config = require( './config-model' ).server;
const client = require( 'redis' ).createClient( config.redis.cache.port, config.redis.cache.host, {
    auth_pass: config.redis.cache.password
} );
const utils = require( '../lib/utils' );
const debug = require( 'debug' )( 'manifest-model' );

// in test environment, switch to different db
if ( process.env.NODE_ENV === 'test' ) {
    client.select( 15 );
}

/**
github kobotoolbox / enketo-express / app / models / manifest-model.js View on Github external
client.get( manifestKey, ( error, manifest ) => {
            if ( error ) {
                reject( error );
            } else if ( manifest && manifest !== 'null' ) {
                debug( 'getting manifest from cache' );
                resolve( manifest );
            } else {
                debug( 'building manifest from scratch' );
                const doc1 = libxml.parseHtml( html1 );
                const doc2 = libxml.parseHtml( html2 );
                const themesSupported = config[ 'themes supported' ] || [];
                let resources = [];

                // href attributes of link elements
                resources = resources.concat( _getLinkHrefs( doc1 ) );
                resources = resources.concat( _getLinkHrefs( doc2 ) );

                // additional themes
                resources = resources.concat( _getAdditionalThemes( resources, themesSupported ) );

                // translations
                resources = resources.concat( _getTranslations( lang ) );

                // any resources inside css files
                resources = resources.concat( _getResourcesFromCss( resources ) );
github kobotoolbox / enketo-express / app / models / manifest-model.js View on Github external
client.get( manifestKey, ( error, manifest ) => {
            if ( error ) {
                reject( error );
            } else if ( manifest && manifest !== 'null' ) {
                debug( 'getting manifest from cache' );
                resolve( manifest );
            } else {
                debug( 'building manifest from scratch' );
                const doc1 = libxml.parseHtml( html1 );
                const doc2 = libxml.parseHtml( html2 );
                const themesSupported = config[ 'themes supported' ] || [];
                let resources = [];

                // href attributes of link elements
                resources = resources.concat( _getLinkHrefs( doc1 ) );
                resources = resources.concat( _getLinkHrefs( doc2 ) );

                // additional themes
                resources = resources.concat( _getAdditionalThemes( resources, themesSupported ) );

                // translations
                resources = resources.concat( _getTranslations( lang ) );

                // any resources inside css files
                resources = resources.concat( _getResourcesFromCss( resources ) );
github DefinitelyTyped / DefinitelyTyped / libxslt / libxslt-tests.ts View on Github external
const document: libxmljs.XMLDocument = libxslt.libxmljs.parseXmlString('');

let stylesheet: libxslt.Stylesheet;

stylesheet = libxslt.parse('');

stylesheet = libxslt.parse(document);

libxslt.parse('', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parse(document, (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parseFile('/path/to/file', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

let applyOptions: libxslt.ApplyOptions = {};

applyOptions = {
	outputFormat: 'string',
	noWrapParams: true
github DefinitelyTyped / DefinitelyTyped / libxslt / libxslt-tests.ts View on Github external
import * as libxslt from 'libxslt';
import * as libxmljs from 'libxmljs';

const document: libxmljs.XMLDocument = libxslt.libxmljs.parseXmlString('');

let stylesheet: libxslt.Stylesheet;

stylesheet = libxslt.parse('');

stylesheet = libxslt.parse(document);

libxslt.parse('', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parse(document, (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parseFile('/path/to/file', (err, result) => {
	if (err == null) {
		stylesheet = result;
github DefinitelyTyped / DefinitelyTyped / libxslt / libxslt-tests.ts View on Github external
import * as libxslt from 'libxslt';
import * as libxmljs from 'libxmljs';

const document: libxmljs.XMLDocument = libxslt.libxmljs.parseXmlString('');

let stylesheet: libxslt.Stylesheet;

stylesheet = libxslt.parse('');

stylesheet = libxslt.parse(document);

libxslt.parse('', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parse(document, (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parseFile('/path/to/file', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});
github DefinitelyTyped / DefinitelyTyped / libxslt / libxslt-tests.ts View on Github external
import * as libxslt from 'libxslt';
import * as libxmljs from 'libxmljs';

const document: libxmljs.XMLDocument = libxslt.libxmljs.parseXmlString('');

let stylesheet: libxslt.Stylesheet;

stylesheet = libxslt.parse('');

stylesheet = libxslt.parse(document);

libxslt.parse('', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parse(document, (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parseFile('/path/to/file', (err, result) => {
github DefinitelyTyped / DefinitelyTyped / libxslt / libxslt-tests.ts View on Github external
import * as libxslt from 'libxslt';
import * as libxmljs from 'libxmljs';

const document: libxmljs.XMLDocument = libxslt.libxmljs.parseXmlString('');

let stylesheet: libxslt.Stylesheet;

stylesheet = libxslt.parse('');

stylesheet = libxslt.parse(document);

libxslt.parse('', (err, result) => {
	if (err == null) {
		stylesheet = result;
	}
});

libxslt.parse(document, (err, result) => {
	if (err == null) {
		stylesheet = result;

libxslt

[Fork] Node.js bindings for libxslt compatible with libxmljs

MIT
Latest version published 1 year ago

Package Health Score

55 / 100
Full package analysis