You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@dailyraisin/gulp-xslt

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dailyraisin/gulp-xslt

XSLT transformation plugin for gulp

2.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

gulp-xslt Build Status Build status

XSL transformation plugin for gulp

Usage

example.xml

<?xml version="1.0" encoding="utf-8"?>
<foo>
    <bar attr="value">baz</bar>
    <bar>qux</bar>
</foo>

template.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


    <xsl:param name="someVariable">defaultValue</xsl:param>
    <xsl:param name="anotherVariable"/>


    <xsl:template match="foo">
        <output>
            <xsl:attribute name="attr">
                <xsl:value-of select="$someVariable"/>
            </xsl:attribute>
            <xsl:apply-templates select="$anotherVariable"/>
        </output>
    </xsl:template>


    <xsl:template match="bar">
        <xsl:copy-of select="."/>
    </xsl:template>


    <xsl:output method="xml" encoding="utf-8" indent="yes"/>


</xsl:stylesheet>

task.js

var gulp = require('gulp');
var xslt = require('gulp-xslt');

gulp.task('xsl', function() {
    gulp.src('./example.xml')
        .pipe(xslt('./template.xsl', {
            someVariable: '"someValue"', // string
            anotherVariable: '/foo/bar[@attr]' // xpath that will be evaluated
        }))
        .pipe(gulp.dest('./build/'));
});

Will produce: ./build/example.xml

<?xml version="1.0" encoding="utf-8"?>
<output attr="someValue">
    <bar attr="value">baz</bar>
</output>

Keywords

gulpplugin

FAQs

Package last updated on 05 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts