{"_id":"basex-standalone","_rev":"42-95da2ad4a994cf3de963628dd8981985","name":"basex-standalone","dist-tags":{"latest":"1.4.0"},"versions":{"0.1.0":{"name":"basex-standalone","version":"0.1.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.1.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"33055da7d2e5ed9e9614ca6c0f44ced7cd2de8a6","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.1.0.tgz","integrity":"sha512-5gWUHyyRCfQP1c3Ghgk2H1W3FzFR98OQEswpWN9Q5P5B6jHZy6jJLo850pND/SKc+RDRiRGcCIFwfc3NEiGRmA==","signatures":[{"sig":"MEYCIQCdIFyVOI/jGc+T0usIkcI/70XC5q72gPwzvcpMM3QipwIhAIVzqeHAaGC0DEKVT6mQgcIcIZg38g9zfjrgxj84hSdP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex_standalone = require('basex-standalone');\nbasex_standalone.awesome(); // \"awesome\"\n```\n\n## Documentation\n_(Coming soon)_\n\n## Examples\n_(Coming soon)_\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.2.0":{"name":"basex-standalone","version":"0.2.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.2.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"38b82e457ea652da953ad052c94da77540959804","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.2.0.tgz","integrity":"sha512-0jpkokI8yynATeq/YxLxQLeNvC1dJKA0b1Fww179JhpyrSOIolAJEYFZYKYupTlChFvtnqu9YOv+kipr53mCnw==","signatures":[{"sig":"MEUCIHN4CgeNSSajWm2qN94QBSELX4cbWBmnfuo4SgdrIP9NAiEA/lQUCSI5fzYXnOAnVfV4BywyHSd6UzdNzZ30Vknc5Jc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex_standalone = require('basex-standalone');\nbasex_standalone.awesome(); // \"awesome\"\n```\n\n## Documentation\n_(Coming soon)_\n\n## Examples\n_(Coming soon)_\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.2.2":{"name":"basex-standalone","version":"0.2.2","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.2.2","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"fef79a85e84b45a24a63fc254b724c749036a37d","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.2.2.tgz","integrity":"sha512-yUc3TvVi1X0itbVgiASQxP+kwIekdublkDXv4/DbcYrb0bLYFOA0oPdt/594ZY5oecJ1vpeBmA6MswBN3OzbLg==","signatures":[{"sig":"MEUCIQC97U7Hj3W9J/mG/Roz1qDAlo8YsMxvLiPQH9mVhorjfgIgXtaGxJlYVACfuMCPp35532DI6Eh8lel16w6PgLPxw/Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex_standalone = require('basex-standalone');\nbasex_standalone.awesome(); // \"awesome\"\n```\n\n## Documentation\n_(Coming soon)_\n\n## Examples\n_(Coming soon)_\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.2.3":{"name":"basex-standalone","version":"0.2.3","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.2.3","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"1eebc58133da0db4e8ecdebb61548042ba66fcde","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.2.3.tgz","integrity":"sha512-+liKo/exh8LjIv863UeFZMrp7XDOWebshnw+L51k3/ZGrihuaNGGrG9+ZulzvTN/U3pmy+Z7pXGV87luCuUANw==","signatures":[{"sig":"MEUCIQDi1+Zb9fFLZqo67MR9zsojo1XUVpgIyL2LWqicW8MKAQIgMtchTQ4bTBBgy7AqJbSgAELvzIGDmRlJOoHxB01UlhY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex_standalone = require('basex-standalone');\nbasex_standalone.awesome(); // \"awesome\"\n```\n\n## Documentation\n_(Coming soon)_\n\n## Examples\n_(Coming soon)_\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.0.1":{"name":"basex-standalone","version":"0.0.1","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.0.1","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"950cb37f10e54f20c609b948c67d52e3b041de96","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.0.1.tgz","integrity":"sha512-kRUJvn8tf8bLD8ApLwsZCE4Y+Fg/XnmbXHbHEganNjXwTKS5EoNDpHdE85aXhzlulDH/7uAkPL9K0PoQQ//xhg==","signatures":[{"sig":"MEYCIQCtHgVloIzXwD/brDTossTiHT4xVSqnkOpH7Z+wQCnCKAIhAMgQ8ONRXYnOY9s6v4RkTuF2hsb9CX+ryY7kZsbR182L","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n\n```\n\nOr run as an instance to set individual defaults\n\n```javascript\nvar basex = require('basex-standalone');\n\nvar b = new basex()\n\nb.defaults.debug = true\n\nb.env.path = '/tmp/basex'\n\n// prints '/tmp/basex/data'\nb.exec({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n\n```\n\nThe *promise* interface is used, as provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n## Documentation\n\n### Options\n\nFor better understanding of these options see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\n#### run\nType: `String`\nDefault value: `''`\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\nThe input string may point to an existing file. \nIf the file suffix is `.bxs`, the file content \nwill be evaluated as Command Script; otherwise, \nthe file contents will be evaluated as an XQuery expression.\n\nThis value is *expanded* to `RUN` multiple files.\n\n#### commands\nType: `String|Array`\nDefault value: `[]`\n\nExecute commands before *each* src / dest pair execution.\n\nIn order to execute set of commands *once* before \na target use a separate target and a MultiTask\n\n#### bind\nType: `Object`\nDefault value: `{}`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### xquery\nType: `String`\nDefault value: `null`\n\nExecutes the specified string as XQuery expression for *each* src / dest pair.\n\n#### debug\nType: `Boolean`\nDefault value: `false`\nArgument: `-d`\nToggles the debugging mode.\n\n#### newline\nType: `Boolean`\nDefault value: `false`\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### serializer\nType: `Object`\nDefault value: `{}`\nArgument(s): `-s<pars>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### update\nType: `Boolean`\nDefault value: `false`\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### whitespace\nType: `Boolean`\nDefault value: `false`\n\nPreserve whitespaces from input files (`-w`).\n\n### Environment\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nThe easiest way is to directly point to a `BaseX.jar` file by setting\nthe `env.jar` option (see below).\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be fount in java `CLASSPATH` by other means [more](http://en.wikipedia.org/wiki/Classpath_(Java)).\n\nTo contain `BaseX`'s data folders in some specific dir you can set\nthe env.path option (see below)\n\nEnvironment settings can be set module-wide:\n\n```javascript\nvar basex = require('basex-standalone')\n\nbasex.env.jar = 'lib/basex.jar'\n\n```\n\nor on individual instances:\n\n```javascript\n\nvar basex = require('basex-standalone')\nvar b = new basex()\n\nb.env.path = '/tmp/instancebasex'\n\n```\n\n#### env.java\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### env.jar\n\nType: `String`\n\nDefault value: `null`\n\nPath to BaseX.jar.\n\n\n#### env.path\n\nType: `String`\n\nDefault value: `tmp/basex`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n## Examples\n\nModify a document in-place using xquery\n\n```javascript\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```javascript\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.done(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```javascript\nbasex({ run: 'some/command/script.bxs'})\n.done(function(output){\n\tconsole.log(output)\n})\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.1.0-alpha":{"name":"basex-standalone","version":"0.1.0-alpha","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.1.0-alpha","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"b0d6463252e150e6e31ceb639ddd6f5d337ed301","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.1.0-alpha.tgz","integrity":"sha512-XTKUQ6dxjPewBdHehTCXX5ollZ08nE/twdVsr108SpCbw+aIDQOWjB6T6IfCU2UpX4Iek9ITJroOOMPlnUYBpA==","signatures":[{"sig":"MEUCIQCKTTj/j5oXY/0j+qOrwV7oQSlUCVxG2yOHqPGabo8w/gIgL8ELRIaElig5KxlJGNgsjcpVjukIMeWmW2ONCgpOcjs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n\n```\n\nOr run as an instance to set individual defaults\n\n```javascript\nvar basex = require('basex-standalone');\n\nvar b = new basex()\n\nb.defaults.debug = true\n\nb.env.path = '/tmp/basex'\n\n// prints '/tmp/basex/data'\nb.exec({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerfull document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\nAsyncronous execution is handled with\nthe *promise* interface, \nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n\n> Tip: For better performance, prefer command scripts \n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n\n### Options\n\nFor better understanding of these options see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\n\n\n#### run\n\nType: `String`\n\nDefault value: `''`\n\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\nThe input string may point to an existing file. \nIf the file suffix is `.bxs`, the file content \nwill be evaluated as Command Script; otherwise, \nthe file contents will be evaluated as an XQuery expression.\n\n> Note: The `run` option *only* accepts files as arguments\n> Use the `xquery` and `commands` options in order to \n> directly evaluate XQuery code and BaseX commands.\n\n#### commands\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before *each* src / dest pair execution.\n\nIn order to execute set of commands *once* before \na target use a separate target and a MultiTask\n\n#### bind\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### xquery\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression for *each* src / dest pair.\n\n#### debug\nType: `Boolean`\nDefault value: `false`\nArgument: `-d`\nToggles the debugging mode.\n\n#### newline\nType: `Boolean`\nDefault value: `false`\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### serializer\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### update\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### whitespace\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n\n### Environment\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nThe easiest way is to directly point to a `BaseX.jar` file by setting\nthe `env.jar` option (see below).\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be fount in java `CLASSPATH` by other means [more](http://en.wikipedia.org/wiki/Classpath).\n\nTo contain `BaseX`'s data folders in some specific dir you can set\nthe env.path option (see below)\n\nEnvironment settings can be set module-wide:\n\n```javascript\nvar basex = require('basex-standalone')\n\nbasex.env.jar = 'lib/basex.jar'\n\n```\n\nor on individual instances:\n\n```javascript\n\nvar basex = require('basex-standalone')\nvar b = new basex()\n\nb.env.path = '/tmp/instancebasex'\n\n```\n\n#### env.java\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### env.jar\n\nType: `String`\n\nDefault value: `null`\n\nPath to BaseX.jar.\n\n\n#### env.path\n\nType: `String`\n\nDefault value: `tmp/basex`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n## Examples\n\nModify a document in-place using xquery\n\n```javascript\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```javascript\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.done(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```javascript\nbasex({ run: 'some/command/script.bxs'})\n.done(function(output){\n\tconsole.log(output)\n})\n```\n\n## Release History\n\n0.0.1 - Initial release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.2.32","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.1.1":{"name":"basex-standalone","version":"0.1.1","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@0.1.1","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"52b0b6676cd869878a180a636e6b7c75d32c6efa","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-0.1.1.tgz","integrity":"sha512-lxIQW7BFE4/ymt1GrHyieGz7/EMU4Uc1ZnyXf6KAIH78TIRyk/Yn7ujab9kYgxiUzVgHo80Qsu0BvMc3V3uBag==","signatures":[{"sig":"MEYCIQClDds/MDkT51V9u3EpBIWbEDlAe01hey+pcC80e46hPAIhAJIVJVq3N67opa9rhrOoLyrQ1JQbkXxZweVRlZ0UmFQE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex-standalone","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```js\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n\n```\n\nOr run as an instance to set individual defaults\n\n```js\nvar basex = require('basex-standalone');\n\nvar b = new basex()\n\nb.defaults.debug = true\n\nb.env.basexpath = '/tmp/basex'\n\n// prints '/tmp/basex/data'\nb.op({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerful document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\nAsynchronous execution is handled with\nthe *promise* interface, \nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n\n> Tip: For better performance, prefer command scripts \n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n## Usage\n\nYou can either use the `Promise` based interface:\n\n```js\nvar BaseX = require('basex')\n\nvar basex = new BaseX()\n\nbasex.op({xquery: '1 to 10'}).then(console.log)\n```\n\nOr directly access the `ChildProcess`:\n\n```js\nvar BaseX = require('basex')\n\nvar basex = new BaseX({classpath: 'path/to/basex.jar'})\n\nvar cp = basex.spawn({xquery: '1 to 10'})\n\ncp.stdout.pipe(process.stdout)\n\n```\n\nA shortcut method to the `Promise` interface is to directly call the required module:\n\n```js\nvar basex = require('basex')\n\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\n\n### Options\n\nBoth `basex.spawn()` and `basex.op` accept the same set of options.\n\nDefault options can be set both on module level:\n\n```js\nvar BaseX = require('basex')\n\nBaseX.defaults({\n\tclasspath: 'path/to/basex.jar'\n})\n```\n\nand on instance level:\n  \n```js\nvar BaseX = require('basex')\n\n// Set some defaults on instantiation\nvar basex = new Basex({ classpath: 'basex.jar'})\n\n// Modify them\nbasex.defaults({\n  \tbasexpath: '/tmp/basex'\n})\n\n```\n\nOptions object is passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\nOptions are converted to `BaseX` standalone arguments. \nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\n\n#### run\n\nType: `String`\n\nDefault value: `''`\n\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\n\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\n\n#### commands\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before *each* src / dest pair execution.\n\nIn order to execute set of commands *once* before \na target use a separate target and a MultiTask\n\n#### bind\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### xquery\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression for *each* src / dest pair.\n\n#### debug\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-d`\n\nToggles the debugging mode.\n\n#### newline\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### serializer\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### update\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### whitespace\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n#### options.java\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### options.classpath\n\nType: `String`\n\nDefault value: `null`\n\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\n\nOther useful jar files are: \n\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\n\n\n#### options.basexpath\n\nType: `String`\n\nDefault value: `null`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n\n## Examples\n\nModify a document in-place using xquery\n\n```js\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```js\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```js\nbasex({ \n\trun: 'some/command/script.bxs'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\n## Release History\n\n0.0.1 - Initial release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas\nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.2","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.0":{"name":"basex-standalone","version":"1.0.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.0.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"24f85883c03245818ff3f5d794181c3892b23770","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.0.0.tgz","integrity":"sha512-x/3ImPCcaLB+LCOaWVwpSPCu2sBVcAODgN6nxHisljUV3tQqDQVEZRzJcNfdge3aifzFbVdDfUQAWP8rI0cJRQ==","signatures":[{"sig":"MEYCIQCda45tHcH9PaF2KbQX05X0//L28Mww7BRxblgbYwXE8wIhAKIdQVIk2sBwYufoYciunh8YSnb5NVZe33rWP+xtT4OY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```js\n\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr create a partial to set individual defaults\n\n```js\n\nvar basex = require('basex-standalone');\n\nvar b = basex.partial({\n\tdebug: true,\n\tbasexpath: '/tmp/basex'\n})\n\n// prints '/tmp/basex/data'\nb({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerful document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\nAsynchronous execution is handled with the *promise* interface, \nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n## Usage\n\nYou can either use the `Promise` based interface:\n\n```js\n\nvar basex = require('basex')\n\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr directly access the `ChildProcess`:\n\n```js\n\nvar basex = require('basex')\n\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\n\nvar cp = custom.spawn({xquery: '1 to 10'})\n\ncp.stdout.pipe(process.stdout)\n```\n\n### Partials\n\nPartials are a convenience to avoid setting all options on each operation.\n\n```js\n\nvar basex = require('basex-standalone')\n\nvar partial = basex.partial({debug: true, newlines: true})\n\npartial('1 to 10')\npartial('test.xql')\n```\n\nCalling the module as a constructor is equivalent to creating a partial.\n\n```js\n\nvar partial = basex.partial({debug.true})\n```\nis equal to \n\n```js\n\nvar partial = new basex({debug: true})\n```\n\n#### `basex.partial(defaults)`\n\nReturns: `Function`\n\nReturns a partially applied function that will always use the provided options as defaults.\n\n\n#### `partial(options)`\n\nReturns: `Promise`\n\nCalling the partial will execute an operation.\n\n#### `partial.spawn(options)`\n\nReturns: `ChildProcess`\n\nEach partial has a `spawn` method that returns the `child_process` directly.\nThis can be used as a mode low-level interface than promise objects.\n\n#### `partial.op(options)`\n\nReturns: `Promise`\n\nEquivalent of calling `partial(options)`. Returns a promise object.\n\n\n#### `partial.reset()`\n\nResets the partial to its initial state.\n\n#### `partial.defaults()`\n\nReturns a deep copy of the default options for the partial.\n\n#### `partial.defaults(key)`\n\nGets the value of key from the default options for the partial.\n\n#### `partial.defaults(key, value)`\n\nSets the value of key on the default options for the partial.\n\n#### `partial.defaults(options)`\n\nSets the value of all key, value pairs on the default options for the partial.\n\nDefault options also can be set with the same method on module level using `basex.defaults()`:\n\n```js\n\nvar basex = require('basex')\n\nbasex.defaults({\n\tclasspath: 'path/to/basex.jar'\n})\n```\n\n> These settings affect *all* future operations.\n\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\n\nTo restore the global defaults to their original values use `basex.reset()`\n\n\n### Options\n\nOptions are converted to `BaseX` standalone arguments. \nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\n\n#### `run`\n\nType: `String`\n\nDefault value: `''`\n\nThe actual operation to run.\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\n\n#### `commands`\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before running the operation.\n\n#### `bind`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### `xquery`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression before running the operation \nand after executing the `options.commands`.\n\n#### `debug`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-d`\n\nToggles the debugging mode.\n\n\n#### `input`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-i<input>`\n\nSets file/directory to use as context.\n\n\n#### `output`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-o<output>`\n\nSets file to write all output to.\n\n\n#### `newline`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### `serializer`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### `update`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### `whitespace`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n#### `java`\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### `classpath`\n\nType: `String|Array`\n\nDefault value: `null`\n\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\n\nOther useful jar files are: \n\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\n\n\n#### `basexpath`\n\nType: `String`\n\nDefault value: `null`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n\n## `basex.Job`\n\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\n\nAll `Job` methods except `Job.render()` are chainable.\n\n\n### `job.command(name, input, params), job.command(name, params)`\n\n`name`: the tagname of the command (`drop-db`)\n\nAppends a command to the script.\n\nAll command name, input, and params are validated \nand relevant errors are thrown.\n\n### `job.requires(module1, module2, ..., moduleN)`\n\nAdds a `REPO INSTALL <file>` command for each argument.\n\n### `job.bind(key, value), job.bind(bindings)`\n\nBinds parameters for XQuery external variables.\n\nThese bindings are collected and *prepended* to the command script \nbefore all other commands upon rendering.\n\n### `job.execute(command)`\n\nAppends an `EXECUTE` command. \nIf `command` can be a `basex.Job` instance.\n\n### `job.xquery(xquery)`\n\nAppends an `XQUERY` command.\n\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\n\nImports files.\n\nIn order to specify parsing options for the files without affecting\nglobal options, it appends an `EXECUTE` command that executes \na child Command Script. Options that can be set are:\n\n#### `options.db`\n\nSpecify the database to add files to. \nIf not set the currently opened database will be used.\nIf no db is currently open or the specified database does not exist\nthe script will fail upon execution.\n\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\n\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\n\n#### `options.{chop, intparse}`\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\n\n\n### `job.set(option, value), job.set(options)`\n\n`option`: Option name to set.\n`value`: Value to set the option to.\n\nor \n\n`options`: Object of option/value pairs.\n\nAppends single/multiple `SET` command.\n\n### `job.export(path)`\n\nAppends an `EXPORT <path>` command.\n\n### `job.check(db)`\n\nAppends an `CHECK <db>` command.\n\n### `job.open(db)`\n\nAppends an `OPEN <db>` command.\n\n### `job.close()`\n\nAppends a `CLOSE` command.\n\n### `job.run(file)`\n\nAppends a `RUN` command.\n\n### `job.render()`\n\nRenders the xml for this Command Script.\n\n### `job.toString()`\n\nAlias of `job.render()`\n\n\n## Examples\n\nModify a document in-place using xquery\n\n```js\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```js\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```js\nbasex('some/command/script.bxs')\n\t.then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\nOr do the same with a `basex.Job`:\n\n```js\n\nvar job = new basex.Job()\n\njob.command('info')\n\t.createdb('test')\n\t.import('some/file.xml', 'test.xml')\n\t.import('somedir/with/json/files', {\n\t\tparser: 'json',\n\t\tcreatefilter: '*.json'\n\t})\n\t.xquery(\"for $book ...\")\n\t.dropdb('test')\n\nbasex(job).then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\n\nRun several queries against an input document in a queue:\n\n```js\n\nvar b = basex.partial({input: 'doc.xml'})\n\nb('//a[@id = \"findme\"]/string()')\n\t.then(function(id){\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\n\t})\n\t.then(console.log)\n```\n\n\n## Release History\n1.0.0 - First Official Release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas\nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.2","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.1":{"name":"basex-standalone","version":"1.0.1","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.0.1","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"3f077710f5e2e70a7c6ed96bde343a0e28a130d5","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.0.1.tgz","integrity":"sha512-NH6JSiY9Pds9DT0WlVv8vCsL4chVpflmPNBgjxYXYbNEE5Ul5ACFUJFTSTZS+voTHkXZAPJ4hwJ+fcLPV/MHZg==","signatures":[{"sig":"MEYCIQCTHBamODUzpev5r4d9COi4+6qPeJPVxjXVtkpsqpBSGgIhAMV6gJCn5U8c41XLzO4K7nqvz8Vq5+9Ds3AOH1ASL4II","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```js\n\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr create a partial to set individual defaults\n\n```js\n\nvar basex = require('basex-standalone');\n\nvar b = basex.partial({\n\tdebug: true,\n\tbasexpath: '/tmp/basex'\n})\n\n// prints '/tmp/basex/data'\nb({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerful document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\nAsynchronous execution is handled with the *promise* interface, \nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n## Usage\n\nYou can either use the `Promise` based interface:\n\n```js\n\nvar basex = require('basex')\n\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr directly access the `ChildProcess`:\n\n```js\n\nvar basex = require('basex')\n\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\n\nvar cp = custom.spawn({xquery: '1 to 10'})\n\ncp.stdout.pipe(process.stdout)\n```\n\n### Partials\n\nPartials are a convenience to avoid setting all options on each operation.\n\n```js\n\nvar basex = require('basex-standalone')\n\nvar partial = basex.partial({debug: true, newlines: true})\n\npartial('1 to 10')\npartial('test.xql')\n```\n\nCalling the module as a constructor is equivalent to creating a partial.\n\n```js\n\nvar partial = basex.partial({debug.true})\n```\nis equal to \n\n```js\n\nvar partial = new basex({debug: true})\n```\n\n#### `basex.partial(defaults)`\n\nReturns: `Function`\n\nReturns a partially applied function that will always use the provided options as defaults.\n\n\n#### `partial(options)`\n\nReturns: `Promise`\n\nCalling the partial will execute an operation.\n\n#### `partial.spawn(options)`\n\nReturns: `ChildProcess`\n\nEach partial has a `spawn` method that returns the `child_process` directly.\nThis can be used as a mode low-level interface than promise objects.\n\n#### `partial.op(options)`\n\nReturns: `Promise`\n\nEquivalent of calling `partial(options)`. Returns a promise object.\n\n\n#### `partial.reset()`\n\nResets the partial to its initial state.\n\n#### `partial.defaults()`\n\nReturns a deep copy of the default options for the partial.\n\n#### `partial.defaults(key)`\n\nGets the value of key from the default options for the partial.\n\n#### `partial.defaults(key, value)`\n\nSets the value of key on the default options for the partial.\n\n#### `partial.defaults(options)`\n\nSets the value of all key, value pairs on the default options for the partial.\n\nDefault options also can be set with the same method on module level using `basex.defaults()`:\n\n```js\n\nvar basex = require('basex')\n\nbasex.defaults({\n\tclasspath: 'path/to/basex.jar'\n})\n```\n\n> These settings affect *all* future operations.\n\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\n\nTo restore the global defaults to their original values use `basex.reset()`\n\n\n### Options\n\nOptions are converted to `BaseX` standalone arguments. \nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\n\n#### `run`\n\nType: `String`\n\nDefault value: `''`\n\nThe actual operation to run.\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\n\n#### `commands`\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before running the operation.\n\n#### `bind`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### `xquery`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression before running the operation \nand after executing the `options.commands`.\n\n#### `debug`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-d`\n\nToggles the debugging mode.\n\n\n#### `input`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-i<input>`\n\nSets file/directory to use as context.\n\n\n#### `output`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-o<output>`\n\nSets file to write all output to.\n\n\n#### `newline`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### `serializer`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### `update`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### `whitespace`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n#### `java`\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### `classpath`\n\nType: `String|Array`\n\nDefault value: `null`\n\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\n\nOther useful jar files are: \n\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\n\n\n#### `basexpath`\n\nType: `String`\n\nDefault value: `null`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n\n## `basex.Job`\n\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\n\nAll `Job` methods except `Job.render()` are chainable.\n\n\n### `job.command(name, input, params), job.command(name, params)`\n\n`name`: the tagname of the command (`drop-db`)\n\nAppends a command to the script.\n\nAll command name, input, and params are validated \nand relevant errors are thrown.\n\n### `job.requires(module1, module2, ..., moduleN)`\n\nAdds a `REPO INSTALL <file>` command for each argument.\n\n### `job.bind(key, value), job.bind(bindings)`\n\nBinds parameters for XQuery external variables.\n\nThese bindings are collected and *prepended* to the command script \nbefore all other commands upon rendering.\n\n### `job.execute(command)`\n\nAppends an `EXECUTE` command. \nIf `command` can be a `basex.Job` instance.\n\n### `job.xquery(xquery)`\n\nAppends an `XQUERY` command.\n\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\n\nImports files.\n\nIn order to specify parsing options for the files without affecting\nglobal options, it appends an `EXECUTE` command that executes \na child Command Script. Options that can be set are:\n\n#### `options.db`\n\nSpecify the database to add files to. \nIf not set the currently opened database will be used.\nIf no db is currently open or the specified database does not exist\nthe script will fail upon execution.\n\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\n\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\n\n#### `options.{chop, intparse}`\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\n\n\n### `job.set(option, value), job.set(options)`\n\n`option`: Option name to set.\n`value`: Value to set the option to.\n\nor \n\n`options`: Object of option/value pairs.\n\nAppends single/multiple `SET` command.\n\n### `job.export(path)`\n\nAppends an `EXPORT <path>` command.\n\n### `job.check(db)`\n\nAppends an `CHECK <db>` command.\n\n### `job.open(db)`\n\nAppends an `OPEN <db>` command.\n\n### `job.close()`\n\nAppends a `CLOSE` command.\n\n### `job.run(file)`\n\nAppends a `RUN` command.\n\n### `job.render()`\n\nRenders the xml for this Command Script.\n\n### `job.toString()`\n\nAlias of `job.render()`\n\n\n## Examples\n\nModify a document in-place using xquery\n\n```js\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```js\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```js\nbasex('some/command/script.bxs')\n\t.then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\nOr do the same with a `basex.Job`:\n\n```js\n\nvar job = new basex.Job()\n\njob.command('info')\n\t.createdb('test')\n\t.import('some/file.xml', 'test.xml')\n\t.import('somedir/with/json/files', {\n\t\tparser: 'json',\n\t\tcreatefilter: '*.json'\n\t})\n\t.xquery(\"for $book ...\")\n\t.dropdb('test')\n\nbasex(job).then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\n\nRun several queries against an input document in a queue:\n\n```js\n\nvar b = basex.partial({input: 'doc.xml'})\n\nb('//a[@id = \"findme\"]/string()')\n\t.then(function(id){\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\n\t})\n\t.then(console.log)\n```\n\n\n## Release History\n1.0.1 - fix multiple values for `options.classpath` \n1.0.0 - First Official Release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas\nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.2","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.2":{"name":"basex-standalone","version":"1.0.2","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.0.2","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"70b1c424d45660b066123bcd2738daeda4ae7b45","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.0.2.tgz","integrity":"sha512-wFefGh8CrlcGPS1pkSmCfPTMNdb0X0pwEmcmQRzxUuF5UCkdk7hKrvLoL23mLZoaZAJhOXsA9U76jrUhXoRZwQ==","signatures":[{"sig":"MEUCIQDncsJIH96CFehQ8MZePxaUBYILSF8LwsOvtfryTVjOdAIgHUprpd/K41qdRdz0BFJxurTUlrrxFqfEl+/NNBDHeXI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```js\n\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr create a partial to set individual defaults\n\n```js\n\nvar basex = require('basex-standalone');\n\nvar b = basex.partial({\n\tdebug: true,\n\tbasexpath: '/tmp/basex'\n})\n\n// prints '/tmp/basex/data'\nb({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}).then(console.log)\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerful document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\nAsynchronous execution is handled with the *promise* interface, \nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\n\n\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n## Usage\n\nYou can either use the `Promise` based interface:\n\n```js\n\nvar basex = require('basex')\n\nbasex({xquery: '1 to 10'}).then(console.log)\n```\n\nOr directly access the `ChildProcess`:\n\n```js\n\nvar basex = require('basex')\n\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\n\nvar cp = custom.spawn({xquery: '1 to 10'})\n\ncp.stdout.pipe(process.stdout)\n```\n\n### Partials\n\nPartials are a convenience to avoid setting all options on each operation.\n\n```js\n\nvar basex = require('basex-standalone')\n\nvar partial = basex.partial({debug: true, newlines: true})\n\npartial('1 to 10')\npartial('test.xql')\n```\n\nCalling the module as a constructor is equivalent to creating a partial.\n\n```js\n\nvar partial = basex.partial({debug.true})\n```\nis equal to \n\n```js\n\nvar partial = new basex({debug: true})\n```\n\n#### `basex.partial(defaults)`\n\nReturns: `Function`\n\nReturns a partially applied function that will always use the provided options as defaults.\n\n\n#### `partial(options)`\n\nReturns: `Promise`\n\nCalling the partial will execute an operation.\n\n#### `partial.spawn(options)`\n\nReturns: `ChildProcess`\n\nEach partial has a `spawn` method that returns the `child_process` directly.\nThis can be used as a mode low-level interface than promise objects.\n\n#### `partial.op(options)`\n\nReturns: `Promise`\n\nEquivalent of calling `partial(options)`. Returns a promise object.\n\n\n#### `partial.reset()`\n\nResets the partial to its initial state.\n\n#### `partial.defaults()`\n\nReturns a deep copy of the default options for the partial.\n\n#### `partial.defaults(key)`\n\nGets the value of key from the default options for the partial.\n\n#### `partial.defaults(key, value)`\n\nSets the value of key on the default options for the partial.\n\n#### `partial.defaults(options)`\n\nSets the value of all key, value pairs on the default options for the partial.\n\nDefault options also can be set with the same method on module level using `basex.defaults()`:\n\n```js\n\nvar basex = require('basex')\n\nbasex.defaults({\n\tclasspath: 'path/to/basex.jar'\n})\n```\n\n> These settings affect *all* future operations.\n\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\n\nTo restore the global defaults to their original values use `basex.reset()`\n\n\n### Options\n\nOptions are converted to `BaseX` standalone arguments. \nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\n\n#### `run`\n\nType: `String`\n\nDefault value: `''`\n\nThe actual operation to run.\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\n\n#### `commands`\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before running the operation.\n\n#### `bind`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### `xquery`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression before running the operation \nand after executing the `options.commands`.\n\n#### `debug`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-d`\n\nToggles the debugging mode.\n\n\n#### `input`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-i<input>`\n\nSets file/directory to use as context.\n\n\n#### `output`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-o<output>`\n\nSets file to write all output to.\n\n\n#### `newline`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### `serializer`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### `update`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### `whitespace`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n#### `java`\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### `classpath`\n\nType: `String|Array`\n\nDefault value: `null`\n\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\n\nOther useful jar files are: \n\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\n\n\n#### `basexpath`\n\nType: `String`\n\nDefault value: `null`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n\n## `basex.Job`\n\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\n\nAll `Job` methods except `Job.render()` are chainable.\n\n\n### `job.command(name, input, params), job.command(name, params)`\n\n`name`: the tagname of the command (`drop-db`)\n\nAppends a command to the script.\n\nAll command name, input, and params are validated \nand relevant errors are thrown.\n\n### `job.requires(module1, module2, ..., moduleN)`\n\nAdds a `REPO INSTALL <file>` command for each argument.\n\n### `job.bind(key, value), job.bind(bindings)`\n\nBinds parameters for XQuery external variables.\n\nThese bindings are collected and *prepended* to the command script \nbefore all other commands upon rendering.\n\n### `job.execute(command)`\n\nAppends an `EXECUTE` command. \nIf `command` can be a `basex.Job` instance.\n\n### `job.xquery(xquery)`\n\nAppends an `XQUERY` command.\n\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\n\nImports files.\n\nIn order to specify parsing options for the files without affecting\nglobal options, it appends an `EXECUTE` command that executes \na child Command Script. Options that can be set are:\n\n#### `options.db`\n\nSpecify the database to add files to. \nIf not set the currently opened database will be used.\nIf no db is currently open or the specified database does not exist\nthe script will fail upon execution.\n\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\n\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\n\n#### `options.{chop, intparse}`\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\n\n\n### `job.set(option, value), job.set(options)`\n\n`option`: Option name to set.\n`value`: Value to set the option to.\n\nor \n\n`options`: Object of option/value pairs.\n\nAppends single/multiple `SET` command.\n\n### `job.export(path)`\n\nAppends an `EXPORT <path>` command.\n\n### `job.check(db)`\n\nAppends an `CHECK <db>` command.\n\n### `job.open(db)`\n\nAppends an `OPEN <db>` command.\n\n### `job.close()`\n\nAppends a `CLOSE` command.\n\n### `job.run(file)`\n\nAppends a `RUN` command.\n\n### `job.render()`\n\nRenders the xml for this Command Script.\n\n### `job.toString()`\n\nAlias of `job.render()`\n\n\n## Examples\n\nModify a document in-place using xquery\n\n```js\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```js\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```js\nbasex('some/command/script.bxs')\n\t.then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\nOr do the same with a `basex.Job`:\n\n```js\n\nvar job = new basex.Job()\n\njob.command('info')\n\t.createdb('test')\n\t.import('some/file.xml', 'test.xml')\n\t.import('somedir/with/json/files', {\n\t\tparser: 'json',\n\t\tcreatefilter: '*.json'\n\t})\n\t.xquery(\"for $book ...\")\n\t.dropdb('test')\n\nbasex(job).then(function(output){\n\t\tconsole.log(output)\n\t})\n```\n\n\nRun several queries against an input document in a queue:\n\n```js\n\nvar b = basex.partial({input: 'doc.xml'})\n\nb('//a[@id = \"findme\"]/string()')\n\t.then(function(id){\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\n\t})\n\t.then(console.log)\n```\n\n\n## Release History\n1.0.2 - fix order of required modules\n1.0.1 - fix multiple values for `options.classpath` \n1.0.0 - First Official Release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas\nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.2","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-curl":"~1.1.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.1.0":{"name":"basex-standalone","version":"1.1.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.1.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"8f1e7c79d086824608eb0ca102d0380006e4d7f7","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.1.0.tgz","integrity":"sha512-VrCfzYmBS1TYvcXzGYao8XcQkbRLEIPxbuoS05X3AU+x8aZhMGy63bxmKYRxaQegIe3YOhv5KkFCFTBloGKwxw==","signatures":[{"sig":"MEYCIQCmv1Y+hmWeQB0cCvGbytWK3wgcQKGgPpfinF17rTDeLwIhAOeu6QYh6Vocmt0mEQzaPN/2bR2kS/sku5nEDpkuqBcG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}).then(console.log)\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\nAsynchronous execution is handled with the *promise* interface, \r\nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\r\n\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nYou can either use the `Promise` based interface:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom.spawn({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to avoid setting all options on each operation.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n```\r\n\r\nCalling the module as a constructor is equivalent to creating a partial.\r\n\r\n```js\r\n\r\nvar partial = basex.partial({debug.true})\r\n```\r\nis equal to \r\n\r\n```js\r\n\r\nvar partial = new basex({debug: true})\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options)`\r\n\r\nReturns: `Promise`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n#### `partial.spawn(options)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nEach partial has a `spawn` method that returns the `child_process` directly.\r\nThis can be used as a mode low-level interface than promise objects.\r\n\r\n#### `partial.op(options)`\r\n\r\nReturns: `Promise`\r\n\r\nEquivalent of calling `partial(options)`. Returns a promise object.\r\n\r\n\r\n#### `partial.reset()`\r\n\r\nResets the partial to its initial state.\r\n\r\n#### `partial.defaults()`\r\n\r\nReturns a deep copy of the default options for the partial.\r\n\r\n#### `partial.defaults(key)`\r\n\r\nGets the value of key from the default options for the partial.\r\n\r\n#### `partial.defaults(key, value)`\r\n\r\nSets the value of key on the default options for the partial.\r\n\r\n#### `partial.defaults(options)`\r\n\r\nSets the value of all key, value pairs on the default options for the partial.\r\n\r\nDefault options also can be set with the same method on module level using `basex.defaults()`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex.defaults({\r\n\tclasspath: 'path/to/basex.jar'\r\n})\r\n```\r\n\r\n> These settings affect *all* future operations.\r\n\r\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\r\n\r\nTo restore the global defaults to their original values use `basex.reset()`\r\n\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs')\r\n\t.then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job).then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\n\r\nRun several queries against an input document in a queue:\r\n\r\n```js\r\n\r\nvar b = basex.partial({input: 'doc.xml'})\r\n\r\nb('//a[@id = \"findme\"]/string()')\r\n\t.then(function(id){\r\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\r\n\t})\r\n\t.then(console.log)\r\n```\r\n\r\n\r\n## Release History\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","prepublish":"node scripts/prepublish.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.1.1":{"name":"basex-standalone","version":"1.1.1","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.1.1","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"458026b216c41a348c9b630b54b499458a3fd40a","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.1.1.tgz","integrity":"sha512-lEdu/FERatWBM6OsStgrWdK5SPWkBbCH1bhULNp084eW+b58rYfZ/xS8ukMipJ73hDzZK0J38HRG5JT9q5pwsw==","signatures":[{"sig":"MEYCIQCmm9VX/XN68gB7k9qiNmR+BDxB+wz8bjATiDnsrhfIXQIhAI85dKcBYKqqveh2zgyRgSrteWohulYk0pYbIRi8E5uL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}).then(console.log)\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\nAsynchronous execution is handled with the *promise* interface, \r\nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\r\n\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nYou can either use the `Promise` based interface:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom.spawn({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to avoid setting all options on each operation.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n```\r\n\r\nCalling the module as a constructor is equivalent to creating a partial.\r\n\r\n```js\r\n\r\nvar partial = basex.partial({debug.true})\r\n```\r\nis equal to \r\n\r\n```js\r\n\r\nvar partial = new basex({debug: true})\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options)`\r\n\r\nReturns: `Promise`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n#### `partial.spawn(options)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nEach partial has a `spawn` method that returns the `child_process` directly.\r\nThis can be used as a mode low-level interface than promise objects.\r\n\r\n#### `partial.op(options)`\r\n\r\nReturns: `Promise`\r\n\r\nEquivalent of calling `partial(options)`. Returns a promise object.\r\n\r\n\r\n#### `partial.reset()`\r\n\r\nResets the partial to its initial state.\r\n\r\n#### `partial.defaults()`\r\n\r\nReturns a deep copy of the default options for the partial.\r\n\r\n#### `partial.defaults(key)`\r\n\r\nGets the value of key from the default options for the partial.\r\n\r\n#### `partial.defaults(key, value)`\r\n\r\nSets the value of key on the default options for the partial.\r\n\r\n#### `partial.defaults(options)`\r\n\r\nSets the value of all key, value pairs on the default options for the partial.\r\n\r\nDefault options also can be set with the same method on module level using `basex.defaults()`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex.defaults({\r\n\tclasspath: 'path/to/basex.jar'\r\n})\r\n```\r\n\r\n> These settings affect *all* future operations.\r\n\r\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\r\n\r\nTo restore the global defaults to their original values use `basex.reset()`\r\n\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs')\r\n\t.then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job).then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\n\r\nRun several queries against an input document in a queue:\r\n\r\n```js\r\n\r\nvar b = basex.partial({input: 'doc.xml'})\r\n\r\nb('//a[@id = \"findme\"]/string()')\r\n\t.then(function(id){\r\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\r\n\t})\r\n\t.then(console.log)\r\n```\r\n\r\n\r\n## Release History\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","prepublish":"node scripts/prepublish.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.1.2":{"name":"basex-standalone","version":"1.1.2","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.1.2","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"ea8ef1698ab28c2a72dadef63b86b0462116c98d","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.1.2.tgz","integrity":"sha512-jkD4hrtDGPdlllH3wgYX08Jctin6fHI/tlNtykQPWv4ugCT0+A0UD6ylPdu47K6eUR5kkEMeL5fi/Gym3f+luQ==","signatures":[{"sig":"MEUCICOuq6asmmW0b4iP8gAA9WyRWGbijNZ+IDJMh9R2vEzrAiEAmWEN6u0I8871QQdUqEB/uf+xJF9Hk+1SuDF75e/Epx4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}).then(console.log)\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\nAsynchronous execution is handled with the *promise* interface, \r\nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\r\n\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nYou can either use the `Promise` based interface:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom.spawn({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to avoid setting all options on each operation.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n```\r\n\r\nCalling the module as a constructor is equivalent to creating a partial.\r\n\r\n```js\r\n\r\nvar partial = basex.partial({debug.true})\r\n```\r\nis equal to \r\n\r\n```js\r\n\r\nvar partial = new basex({debug: true})\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options)`\r\n\r\nReturns: `Promise`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n#### `partial.spawn(options)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nEach partial has a `spawn` method that returns the `child_process` directly.\r\nThis can be used as a mode low-level interface than promise objects.\r\n\r\n#### `partial.op(options)`\r\n\r\nReturns: `Promise`\r\n\r\nEquivalent of calling `partial(options)`. Returns a promise object.\r\n\r\n\r\n#### `partial.reset()`\r\n\r\nResets the partial to its initial state.\r\n\r\n#### `partial.defaults()`\r\n\r\nReturns a deep copy of the default options for the partial.\r\n\r\n#### `partial.defaults(key)`\r\n\r\nGets the value of key from the default options for the partial.\r\n\r\n#### `partial.defaults(key, value)`\r\n\r\nSets the value of key on the default options for the partial.\r\n\r\n#### `partial.defaults(options)`\r\n\r\nSets the value of all key, value pairs on the default options for the partial.\r\n\r\nDefault options also can be set with the same method on module level using `basex.defaults()`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex.defaults({\r\n\tclasspath: 'path/to/basex.jar'\r\n})\r\n```\r\n\r\n> These settings affect *all* future operations.\r\n\r\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\r\n\r\nTo restore the global defaults to their original values use `basex.reset()`\r\n\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs')\r\n\t.then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job).then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\n\r\nRun several queries against an input document in a queue:\r\n\r\n```js\r\n\r\nvar b = basex.partial({input: 'doc.xml'})\r\n\r\nb('//a[@id = \"findme\"]/string()')\r\n\t.then(function(id){\r\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\r\n\t})\r\n\t.then(console.log)\r\n```\r\n\r\n\r\n## Release History\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","prepublish":"node scripts/prepublish.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.1.3":{"name":"basex-standalone","version":"1.1.3","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.1.3","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"61328a9121196ccd523c0eae4900dead89de1da6","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.1.3.tgz","integrity":"sha512-f++Lp2e556W3uFz3WlXobrqH5qNPI6+n2dkroMNOZo4rw1pml9C9Ds616bp46DxKWGhMBxiRbkXueIigLmh+vA==","signatures":[{"sig":"MEQCIApI00TeQkp+5WO7zoe2VvAbTfjRZreQbWvE65XUYh0oAiAFf9XrWDo10h9VQ6zJzCbwrJWZpk98KxJiSpiO5rwIFA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}).then(console.log)\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\nAsynchronous execution is handled with the *promise* interface, \r\nas provided by the `q` module [see more](http://documentup.com/kriskowal/q/)\r\n\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nYou can either use the `Promise` based interface:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10'}).then(console.log)\r\n```\r\n\r\nOr directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom.spawn({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to avoid setting all options on each operation.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n```\r\n\r\nCalling the module as a constructor is equivalent to creating a partial.\r\n\r\n```js\r\n\r\nvar partial = basex.partial({debug.true})\r\n```\r\nis equal to \r\n\r\n```js\r\n\r\nvar partial = new basex({debug: true})\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options)`\r\n\r\nReturns: `Promise`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n#### `partial.spawn(options)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nEach partial has a `spawn` method that returns the `child_process` directly.\r\nThis can be used as a mode low-level interface than promise objects.\r\n\r\n#### `partial.op(options)`\r\n\r\nReturns: `Promise`\r\n\r\nEquivalent of calling `partial(options)`. Returns a promise object.\r\n\r\n\r\n#### `partial.reset()`\r\n\r\nResets the partial to its initial state.\r\n\r\n#### `partial.defaults()`\r\n\r\nReturns a deep copy of the default options for the partial.\r\n\r\n#### `partial.defaults(key)`\r\n\r\nGets the value of key from the default options for the partial.\r\n\r\n#### `partial.defaults(key, value)`\r\n\r\nSets the value of key on the default options for the partial.\r\n\r\n#### `partial.defaults(options)`\r\n\r\nSets the value of all key, value pairs on the default options for the partial.\r\n\r\nDefault options also can be set with the same method on module level using `basex.defaults()`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex.defaults({\r\n\tclasspath: 'path/to/basex.jar'\r\n})\r\n```\r\n\r\n> These settings affect *all* future operations.\r\n\r\n> Note that upon execution global options are re-merged with the partial's defaults and the operation's options.\r\n\r\nTo restore the global defaults to their original values use `basex.reset()`\r\n\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs')\r\n\t.then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job).then(function(output){\r\n\t\tconsole.log(output)\r\n\t})\r\n```\r\n\r\n\r\nRun several queries against an input document in a queue:\r\n\r\n```js\r\n\r\nvar b = basex.partial({input: 'doc.xml'})\r\n\r\nb('//a[@id = \"findme\"]/string()')\r\n\t.then(function(id){\r\n\t\treturn b.op('//div[@class=\"'+resolve(id)+'\"]')\r\n\t})\r\n\t.then(console.log)\r\n```\r\n\r\n\r\n## Release History\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","install":"node scripts/install.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"q":"~0.9.6","lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.0":{"name":"basex-standalone","version":"1.2.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.2.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"358a7b0280a37265802e1f6428e1efce9e1e83b0","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.2.0.tgz","integrity":"sha512-mhTBcRA18RAt3Rs3z4DDvLzjq4Pqk4MoemkxolN/miTODndJNo6wqy8ATKyGe8e6E8Kv68IPub8PIEFyVWstDQ==","signatures":[{"sig":"MEYCIQCJ01ugaRXqXefhLMXDEFyiAwZ9eqEtN/hG/NlYkH+4jwIhAOF8tcSjUQzA5xbJX7npSh1J+O+tl52Q/Ayh2gXVCJMm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nUse buffered output by passing a callback\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10', function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nor directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to facilitate with default options handling.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options, callback)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs', function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job, function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\n## Release History\r\n1.2.0 - Simplify API and drop Q dependency\r\n1.1.0 - Include jar via downloading upon installation\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","install":"node scripts/install.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.1":{"name":"basex-standalone","version":"1.2.1","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.2.1","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"a724b3add55fd5c040de750e558f7a1e393f06af","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.2.1.tgz","integrity":"sha512-VDHa8ZV0LKpqDmuMarnj8QdNxdeRL7cXwFk4aDrI3xlfz9Y+4eT5ksKPA7ZfM5x9T+HFf4tx2FWtDw17pV/yfg==","signatures":[{"sig":"MEQCICBy316W2flGw4oKwqkO6F8viHNFaUKQfUVT217b0TleAiAb0SAr6Q7WfQvPYGUINCGnlnW5sZxFSp0Mkn94YOIsTA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nUse buffered output by passing a callback\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10', function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nor directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to facilitate with default options handling.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options, callback)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs', function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job, function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\n## Release History\r\n1.2.0 - Simplify API and drop Q dependency\r\n1.1.0 - Include jar via downloading upon installation\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","install":"node scripts/install.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1","mkdirp":"~0.3.5"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.2":{"name":"basex-standalone","version":"1.2.2","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.2.2","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"aceb4965d64950854f3308950ca41bf19bef3872","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.2.2.tgz","integrity":"sha512-wDJK0isf799HJH22NnMilrg0l807wN8SmfEEypx2bzQdNO8fRjcGX3RZaECEAlPZR+8WV3F8+PUTqV7KTtgloA==","signatures":[{"sig":"MEUCIQCGIWsOumwwdTrdSknTlSEPdFTzeVZTqNU/ZeJLZwR1LwIgckHWsKe7yyNXPhDDfcZNz2TK14rGX6Gin7DY5K02NUo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nUse buffered output by passing a callback\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10', function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nor directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to facilitate with default options handling.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options, callback)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide.\r\n\r\nOther useful jar files are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs', function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job, function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\n## Release History\r\n1.2.0 - Simplify API and drop Q dependency\r\n1.1.0 - Include jar via downloading upon installation\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test","install":"node scripts/install.js"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1","mkdirp":"~0.3.5"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.3.0":{"name":"basex-standalone","version":"1.3.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.3.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"d652a37c5d2f1b6579c961a069e7e00f08891847","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.3.0.tgz","integrity":"sha512-JqR/KRuRJb9MzxphpCYQRrkz6H8GKduqtC0resOhjsNLw9QqtX1/evXCscPuwprzIuKGEZ9T0gfRcvG4UtUYsQ==","signatures":[{"sig":"MEQCIATjDiJ6ie7dO0M0SwHM4Tds2QnQHnYgo1GUEITvOJ5pAiBc9LoEFOxFK8RDa35RNzKOA5M2RlPBdUlGkpBpUva86g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\r\n\r\nProcess data using `XQuery` with `BaseX` in standalone mode.\r\n\r\n## Getting Started\r\n\r\n\r\nInstall the module with: `npm install basex-standalone`\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\n// prints '1 2 3 4 5 6 7 8 9 10'\r\nbasex({xquery: '1 to 10'}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nOr create a partial to set individual defaults\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone');\r\n\r\nvar b = basex.partial({\r\n\tdebug: true,\r\n\tbasexpath: '/tmp/basex'\r\n})\r\n\r\n// prints '/tmp/basex/data'\r\nb({\r\n\tserializer: { method: 'text' },\r\n\txquery: 'db:system()/mainoptions/dbpath/text()'\r\n}, function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\n## Documentation\r\n\r\n\r\n`BaseX` includes a fast, feature-rich XQuery processor\r\nthat can juggle json, xml, csv and other data easily\r\nand provides powerful document manipulation facilities \r\nby implementing the XQuery Update specification.\r\n\r\nFor more information about `BaseX`, \r\nwhat you can do with it, \r\nand how to do it,\r\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\r\n\r\nThis module acts as a simple wrapper around `BaseX`'s\r\n*Standalone Mode* passing arguments via cli and reading back\r\nstdout/stderr output.\r\n\r\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\r\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\r\n\r\n## Usage\r\n\r\nUse buffered output by passing a callback\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nbasex({xquery: '1 to 10', function(error, data){\r\n\tif(e) throw e\r\n\telse console.log(data) \r\n})\r\n```\r\n\r\nor directly access the `ChildProcess`:\r\n\r\n```js\r\n\r\nvar basex = require('basex')\r\n\r\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\r\n\r\nvar cp = custom({xquery: '1 to 10'})\r\n\r\ncp.stdout.pipe(process.stdout)\r\n```\r\n\r\n### Partials\r\n\r\nPartials are a convenience to facilitate with default options handling.\r\n\r\n```js\r\n\r\nvar basex = require('basex-standalone')\r\n\r\nvar partial = basex.partial({debug: true, newlines: true})\r\n\r\npartial('1 to 10')\r\npartial('test.xql')\r\n\r\n```\r\n\r\n#### `basex.partial(defaults)`\r\n\r\nReturns: `Function`\r\n\r\nReturns a partially applied function that will always use the provided options as defaults.\r\n\r\n\r\n#### `partial(options, callback)`\r\n\r\nReturns: `ChildProcess`\r\n\r\nCalling the partial will execute an operation.\r\n\r\n### Options\r\n\r\nOptions are converted to `BaseX` standalone arguments. \r\nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\r\n\r\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\r\n\r\n\r\n#### `run`\r\n\r\nType: `String`\r\n\r\nDefault value: `''`\r\n\r\nThe actual operation to run.\r\n\r\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\r\n\r\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\r\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\r\n\r\n#### `commands`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `[]`\r\n\r\nArgument(s): `-c<COMMAND>`\r\n\r\nExecute commands before running the operation.\r\n\r\n#### `bind`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-b<name>=<val>`\r\n\r\nBinds external variables to XQuery expressions. \r\n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\r\n\r\n#### `xquery`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-q<xquery>`\r\n\r\nExecutes the specified string as XQuery expression before running the operation \r\nand after executing the `options.commands`.\r\n\r\n#### `debug`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-d`\r\n\r\nToggles the debugging mode.\r\n\r\n\r\n#### `input`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-i<input>`\r\n\r\nSets file/directory to use as context.\r\n\r\n\r\n#### `output`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nArgument: `-o<output>`\r\n\r\nSets file to write all output to.\r\n\r\n\r\n#### `newline`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-L`\r\n\r\nSeparates returned query items by newlines (instead of spaces) \r\nand appends a newline to the end of a result.\r\n\r\n#### `serializer`\r\n\r\nType: `Object`\r\n\r\nDefault value: `{}`\r\n\r\nArgument(s): `-s<name>=<value>`\r\n\r\nSpecifies parameters for serializing XQuery results.\r\n[docs](http://docs.basex.org/wiki/Serialization)\r\n\r\n#### `update`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-u`\r\n\r\nWrite updates back to original files.\r\n\r\n#### `whitespace`\r\n\r\nType: `Boolean`\r\n\r\nDefault value: `false`\r\n\r\nArgument: `-w`\r\n\r\nPreserve whitespaces from input files (`-w`).\r\n\r\n#### `java`\r\n\r\nType: `String`\r\n\r\nDefault value: `/usr/bin/env java`\r\n\r\nJava executable to use.\r\n\r\n\r\n#### `classpath`\r\n\r\nType: `String|Array`\r\n\r\nDefault value: `null`\r\n\r\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\r\n\r\nIn order for the module to work java needs access to `org.basex.BaseX` class.\r\n\r\nDownload the latest version from [here](http://files.basex.org/releases)\r\n\r\nAlternatively `org.basex.BaseX` class must be available to java system-wide \r\n(i.e. by setting the CLASSPATH environment variable).\r\n\r\nOther useful files to include to the classpath are: \r\n\r\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\r\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\r\n\r\n\r\n#### `basexpath`\r\n\r\nType: `String`\r\n\r\nDefault value: `null`\r\n\r\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\r\n\r\n> Note that all file paths in commands / script etc \r\n> remain relative to node's cwd\r\n\r\n\r\n## `basex.Job`\r\n\r\nA convenience object that generates `BaseX` [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts).\r\n\r\nAll `Job` methods except `Job.render()` are chainable.\r\n\r\n\r\n### `job.command(name, input, params), job.command(name, params)`\r\n\r\n`name`: the tagname of the command (`drop-db`)\r\n\r\nAppends a command to the script.\r\n\r\nAll command name, input, and params are validated \r\nand relevant errors are thrown.\r\n\r\n### `job.requires(module1, module2, ..., moduleN)`\r\n\r\nAdds a `REPO INSTALL <file>` command for each argument.\r\n\r\n### `job.bind(key, value), job.bind(bindings)`\r\n\r\nBinds parameters for XQuery external variables.\r\n\r\nThese bindings are collected and *prepended* to the command script \r\nbefore all other commands upon rendering.\r\n\r\n### `job.execute(command)`\r\n\r\nAppends an `EXECUTE` command. \r\nIf `command` can be a `basex.Job` instance.\r\n\r\n### `job.xquery(xquery)`\r\n\r\nAppends an `XQUERY` command.\r\n\r\n### `job.import(files, path, options), job.import(files), job.import(files, options)`\r\n\r\nImports files.\r\n\r\nIn order to specify parsing options for the files without affecting\r\nglobal options, it appends an `EXECUTE` command that executes \r\na child Command Script. Options that can be set are:\r\n\r\n#### `options.db`\r\n\r\nSpecify the database to add files to. \r\nIf not set the currently opened database will be used.\r\nIf no db is currently open or the specified database does not exist\r\nthe script will fail upon execution.\r\n\r\n#### `options.{createfilter, addarchives, skipcorrupt, addraw, parser, parseropt, htmlopt}`\r\n\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#Parsing)\r\n\r\n#### `options.{chop, intparse}`\r\nSee [Parsing Options](http://docs.basex.org/wiki/Options#XML_Parsing)\r\n\r\n\r\n### `job.set(option, value), job.set(options)`\r\n\r\n`option`: Option name to set.\r\n`value`: Value to set the option to.\r\n\r\nor \r\n\r\n`options`: Object of option/value pairs.\r\n\r\nAppends single/multiple `SET` command.\r\n\r\n### `job.export(path)`\r\n\r\nAppends an `EXPORT <path>` command.\r\n\r\n### `job.check(db)`\r\n\r\nAppends an `CHECK <db>` command.\r\n\r\n### `job.open(db)`\r\n\r\nAppends an `OPEN <db>` command.\r\n\r\n### `job.close()`\r\n\r\nAppends a `CLOSE` command.\r\n\r\n### `job.run(file)`\r\n\r\nAppends a `RUN` command.\r\n\r\n### `job.render()`\r\n\r\nRenders the xml for this Command Script.\r\n\r\n### `job.toString()`\r\n\r\nAlias of `job.render()`\r\n\r\n\r\n## Examples\r\n\r\nModify a document in-place using xquery\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/file.xml',\r\n\tupdate: true,\r\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\r\n})\r\n.then(function(data){\r\n\t// Updating xquery expressions have no output\r\n})\r\n```\r\n\r\nExecute an XQuery script file to \r\nquery a folder with multiple xml files\r\n\r\n```js\r\nbasex({\r\n\tinput: 'path/to/some/dir',\r\n\trun: 'path/to/some/script.xql'\r\n})\r\n.then(function(output){\r\n\tconsole.log(output)\r\n})\r\n```\r\n\r\nExecute a BaseX Command Script to batch-process json and xml data\r\n\r\n```xml\r\n<!-- some/command/script.bxs  -->\r\n<commands>\r\n\t<info/>\r\n\t<create-db name=\"test\"/>\r\n\t<add path=\"test.xml\">some/file.xml</add>\r\n\t<set option=\"parser\">json</set>\r\n\t<set option=\"createfilter\">*.json</set>\r\n\t<add>somedir/with/json/files</add>\r\n\t<xquery>\r\n\t<![CDATA[\r\n\t\tfor $book in //json/book\r\n\t\t\tlet $author = $book//author\r\n\t\t\tgroup by $author/@id\r\n\t\t\treturn \r\n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\r\n\r\n\t ]]>\r\n\t </xquery>\r\n\t<drop-db name=\"test\"/>\r\n<commands>\r\n```\r\n\r\n```js\r\nbasex('some/command/script.bxs', function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\nOr do the same with a `basex.Job`:\r\n\r\n```js\r\n\r\nvar job = new basex.Job()\r\n\r\njob.command('info')\r\n\t.createdb('test')\r\n\t.import('some/file.xml', 'test.xml')\r\n\t.import('somedir/with/json/files', {\r\n\t\tparser: 'json',\r\n\t\tcreatefilter: '*.json'\r\n\t})\r\n\t.xquery(\"for $book ...\")\r\n\t.dropdb('test')\r\n\r\nbasex(job, function(error, data)\r\n        if(e) throw e\r\n        else console.log(data)\r\n    })\r\n```\r\n\r\n## Release History\r\n1.2.0 - Simplify API and drop Q dependency\r\n1.1.0 - Include jar via downloading upon installation\r\n1.0.2 - fix order of required modules\r\n1.0.1 - fix multiple values for `options.classpath` \r\n1.0.0 - First Official Release\r\n\r\n## License\r\nCopyright (c) 2013 Alexandros Sigalas\r\nLicensed under the MIT license.\r\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.8","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.4.0":{"name":"basex-standalone","version":"1.4.0","keywords":["basex","xquery"],"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"_id":"basex-standalone@1.4.0","maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"dist":{"shasum":"1a1429142c8456944bac74de83e179861dccd645","tarball":"https://registry.npmjs.org/basex-standalone/-/basex-standalone-1.4.0.tgz","integrity":"sha512-DM5cgcQLvHMeZ7i+PtuJMIY0a2ALDPW5QHqwQACvhgdXk9fh4XGIIBvtsHFJ8bnDiarFJHeSf9wPJ5LARpn/EA==","signatures":[{"sig":"MEUCIDT1qaOJhFiQ9Rs2lB1LgUh3uQe6HsdFGlHgIDs46edZAiEAxiS9kEX3u5rAJ582rx5jwxIOAN0zQL2s2Di/IVB0nPo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/basex","_from":".","readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using `XQuery` with `BaseX` in standalone mode.\n\n## Getting Started\n\n\nInstall the module with: `npm install basex-standalone`\n\n```js\n\nvar basex = require('basex-standalone');\n\n// prints '1 2 3 4 5 6 7 8 9 10'\nbasex({xquery: '1 to 10'}, function(error, data){\n\tif(e) throw e\n\telse console.log(data) \n})\n```\n\nOr create a partial to set individual defaults\n\n```js\n\nvar basex = require('basex-standalone');\n\nvar b = basex.partial({\n\tdebug: true,\n\tbasexpath: '/tmp/basex'\n})\n\n// prints '/tmp/basex/data'\nb({\n\tserializer: { method: 'text' },\n\txquery: 'db:system()/mainoptions/dbpath/text()'\n}, function(error, data){\n\tif(e) throw e\n\telse console.log(data) \n})\n```\n\n## Documentation\n\n\n`BaseX` includes a fast, feature-rich XQuery processor\nthat can juggle json, xml, csv and other data easily\nand provides powerful document manipulation facilities \nby implementing the XQuery Update specification.\n\nFor more information about `BaseX`, \nwhat you can do with it, \nand how to do it,\nread through the *excellent* documentation on [docs.basex.org](http://docs.basex.org)\n\nThis module acts as a simple wrapper around `BaseX`'s\n*Standalone Mode* passing arguments via cli and reading back\nstdout/stderr output.\n\n> Tip: For better performance, prefer [Command Scripts](http://docs.basex.org/wiki/Commands#Command_Scripts)\n> over sequential invocations (ie multiple `ADD`, `SET` commands)\n\n## Usage\n\nUse buffered output by passing a callback\n\n```js\n\nvar basex = require('basex')\n\nbasex({xquery: '1 to 10', function(error, data){\n\tif(e) throw e\n\telse console.log(data) \n})\n```\n\nor directly access the `ChildProcess`:\n\n```js\n\nvar basex = require('basex')\n\nvar custom = basex.partial({classpath: 'path/to/basex.jar'})\n\nvar cp = custom({xquery: '1 to 10'})\n\ncp.stdout.pipe(process.stdout)\n```\n\n### Partials\n\nPartials are a convenience to facilitate with default options handling.\n\n```js\n\nvar basex = require('basex-standalone')\n\nvar partial = basex.partial({debug: true, newlines: true})\n\npartial('1 to 10')\npartial('test.xql')\n\n```\n\n#### `basex.partial(defaults)`\n\nReturns: `Function`\n\nReturns a partially applied function that will always use the provided options as defaults.\n\n\n#### `partial(options, callback)`\n\nReturns: `ChildProcess`\n\nCalling the partial will execute an operation.\n\n### Options\n\nOptions are converted to `BaseX` standalone arguments. \nFor better understanding of these arguments see [Startup Options](http://docs.basex.org/wiki/Startup_Options#BaseX_Standalone).\n\nOptions object is also passed on to `child_process.spawn()` [more](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\n\n#### `run`\n\nType: `String`\n\nDefault value: `''`\n\nThe actual operation to run.\n\nSimilar to `RUN` command. [docs](http://docs.basex.org/wiki/Commands#RUN)\n\n> Note: `run` argument will directly evaluate as XQuery by BaseX if it doesn't point to a file.\n> It is preferable to use the `option.xquery` in order to evaluate XQuery code.\n\n#### `commands`\n\nType: `String|Array`\n\nDefault value: `[]`\n\nArgument(s): `-c<COMMAND>`\n\nExecute commands before running the operation.\n\n#### `bind`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-b<name>=<val>`\n\nBinds external variables to XQuery expressions. \n[docs](http://docs.basex.org/wiki/Options#BINDINGS)\n\n#### `xquery`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-q<xquery>`\n\nExecutes the specified string as XQuery expression before running the operation \nand after executing the `options.commands`.\n\n#### `debug`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-d`\n\nToggles the debugging mode.\n\n\n#### `input`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-i<input>`\n\nSets file/directory to use as context.\n\n\n#### `output`\n\nType: `String`\n\nDefault value: `null`\n\nArgument: `-o<output>`\n\nSets file to write all output to.\n\n\n#### `newline`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-L`\n\nSeparates returned query items by newlines (instead of spaces) \nand appends a newline to the end of a result.\n\n#### `serializer`\n\nType: `Object`\n\nDefault value: `{}`\n\nArgument(s): `-s<name>=<value>`\n\nSpecifies parameters for serializing XQuery results.\n[docs](http://docs.basex.org/wiki/Serialization)\n\n#### `update`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-u`\n\nWrite updates back to original files.\n\n#### `whitespace`\n\nType: `Boolean`\n\nDefault value: `false`\n\nArgument: `-w`\n\nPreserve whitespaces from input files (`-w`).\n\n#### `java`\n\nType: `String`\n\nDefault value: `/usr/bin/env java`\n\nJava executable to use.\n\n\n#### `classpath`\n\nType: `String|Array`\n\nDefault value: `null`\n\n`CLASSPATH` definition to be used by Java [more](http://en.wikipedia.org/wiki/Classpath).\n\nIn order for the module to work java needs access to `org.basex.BaseX` class.\n\nDownload the latest version from [here](http://files.basex.org/releases)\n\nAlternatively `org.basex.BaseX` class must be available to java system-wide \n(i.e. by setting the CLASSPATH environment variable).\n\nOther useful files to include to the classpath are: \n\n- [tagsoup](http://ccil.org/~cowan/XML/tagsoup/) For HTML parsing\n- [saxon](http://www.saxonica.com/welcome/welcome.xml) For XSLT transforms and XSD validations\n\n\n#### `basexpath`\n\nType: `String`\n\nDefault value: `null`\n\nPath for BaseX [Home Directory](http://docs.basex.org/wiki/Configuration#Home_Directory)\n\n> Note that all file paths in commands / script etc \n> remain relative to node's cwd\n\n\n\n## Examples\n\nModify a document in-place using xquery\n\n```js\nbasex({\n\tinput: 'path/to/some/file.xml',\n\tupdate: true,\n\txquery: 'for $a in //a return replace value of node $a/@href with \"#test\"'\n})\n.then(function(data){\n\t// Updating xquery expressions have no output\n})\n```\n\nExecute an XQuery script file to \nquery a folder with multiple xml files\n\n```js\nbasex({\n\tinput: 'path/to/some/dir',\n\trun: 'path/to/some/script.xql'\n})\n.then(function(output){\n\tconsole.log(output)\n})\n```\n\nExecute a BaseX Command Script to batch-process json and xml data\n\n```xml\n<!-- some/command/script.bxs  -->\n<commands>\n\t<info/>\n\t<create-db name=\"test\"/>\n\t<add path=\"test.xml\">some/file.xml</add>\n\t<set option=\"parser\">json</set>\n\t<set option=\"createfilter\">*.json</set>\n\t<add>somedir/with/json/files</add>\n\t<xquery>\n\t<![CDATA[\n\t\tfor $book in //json/book\n\t\t\tlet $author = $book//author\n\t\t\tgroup by $author/@id\n\t\t\treturn \n\t\t\t<author books=\"{{count($book)}}\">{{$author/text()}}</author>\"\n\n\t ]]>\n\t </xquery>\n\t<drop-db name=\"test\"/>\n<commands>\n```\n\n```js\nbasex('some/command/script.bxs', function(error, data)\n        if(e) throw e\n        else console.log(data)\n    })\n```\n\n## Release History\n1.4.0 - basex.Job moved to it's own module\n1.3.0 - Lets the user handle the classpath\n1.2.0 - Simplify API and drop Q dependency\n1.1.0 - Include jar via downloading upon installation\n1.0.2 - fix order of required modules\n1.0.1 - fix multiple values for `options.classpath` \n1.0.0 - First Official Release\n\n## License\nCopyright (c) 2013 Alexandros Sigalas\nLicensed under the MIT license.\n","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"_npmUser":{"name":"alxarch","email":"alxarch@gmail.com"},"licenses":[{"url":"https://github.com/alxarch/basex-standalone/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"_npmVersion":"1.3.11","description":"Process data using XQuery with BaseX in standalone mode.","dependencies":{"lodash":"~1.3.1"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","nodeunit":"~0.8.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-watch":"~0.4.0","grunt-contrib-jshint":"~0.6.0","grunt-contrib-nodeunit":"~0.2.0"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2013-07-10T09:44:33.487Z","modified":"2024-08-07T14:41:31.510Z","0.1.0":"2013-07-10T09:44:36.956Z","0.2.0":"2013-07-10T10:10:14.579Z","0.2.2":"2013-07-10T10:50:10.738Z","0.2.3":"2013-07-10T11:04:12.725Z","0.0.1":"2013-07-10T16:59:10.503Z","0.1.0-alpha":"2013-07-10T18:36:39.182Z","0.1.1":"2013-07-13T18:43:22.941Z","1.0.0":"2013-07-18T09:57:47.542Z","1.0.1":"2013-07-23T12:14:44.890Z","1.0.2":"2013-07-23T17:33:39.466Z","1.1.0":"2013-09-24T20:29:35.349Z","1.1.1":"2013-09-24T21:48:49.847Z","1.1.2":"2013-09-26T11:00:34.010Z","1.1.3":"2013-09-26T11:07:36.887Z","1.2.0":"2013-09-27T09:44:38.759Z","1.2.1":"2013-09-29T22:58:26.019Z","1.2.2":"2013-09-30T11:31:05.425Z","1.3.0":"2013-10-01T10:43:50.289Z","1.4.0":"2013-10-02T22:26:33.450Z"},"author":{"name":"Alexandros Sigalas","email":"alxarch@gmail.com"},"repository":{"url":"git://github.com/alxarch/basex-standalone.git","type":"git"},"description":"Process data using XQuery with BaseX in standalone mode.","keywords":["basex","xquery"],"homepage":"https://github.com/alxarch/basex-standalone","bugs":{"url":"https://github.com/alxarch/basex-standalone/issues"},"maintainers":[{"name":"alxarch","email":"alxarch@gmail.com"}],"readme":"# basex-standalone [![Build Status](https://secure.travis-ci.org/alxarch/basex-standalone.png?branch=master)](http://travis-ci.org/alxarch/basex-standalone)\n\nProcess data using XQuery with BaseX in standalone mode.\n\n## Getting Started\nInstall the module with: `npm install basex-standalone`\n\n```javascript\nvar basex_standalone = require('basex-standalone');\nbasex_standalone.awesome(); // \"awesome\"\n```\n\n## Documentation\n_(Coming soon)_\n\n## Examples\n_(Coming soon)_\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 Alexandros Sigalas  \nLicensed under the MIT license.\n"}