lycwed-gulp-xml-transformer
Transform xml documents gulp plugin
Install
$ npm install --save-dev lycwed-gulp-xml-transformer
Supports node >= 0.10
Usage
var xmlTransformer = ; /* * edit XML document by using user specific object */gulp ; /* * attributes can be functions too */gulp
Note
Please see libxmljs wiki page to get more information about libxmljs API.
Based on gulp-xml-editor.
API
xmlTransformer(transformations, nsUri)
transformations
Type: Object | Array<Object> | Function
The objects must be one of following.
// to modify(or add) the text of the element path: 'xpath to the element' text: 'new text value' // to modify(or add) a attribute of the element path: 'xpath to the element' attr: 'attrName': 'attrValue' // to modify(or add) some attributes of the element path: 'xpath to the element' attrs: 'attrName1': 'attrValue1' 'attrName2': 'attrValue2' // alternatively path: 'xpath to the element' attrs: 'attrName1': 'attrValue1' 'attrName2': 'attrValue2' // if the new value of the attribute depends on the old value, pass in a function path: 'xpath to the element' attrs: oldVal
The if a function is supplied, it must have the following signature: function (doc, [libxmljs]) {}
, and must return a libxmljs Document object. The doc
argument is a libxmljs Document object, and the libxmljs
argument is libxmljs object.
nsUri
Type: Object | string
A string representing the Namespace URI of the elements to transform, or an object literal with namespaces.
License
See the LICENSE file for license rights and limitations (MIT).