e2ebridge / xslt4node Goto Github PK
View Code? Open in Web Editor NEWA XSLT package wrapping the XSLT interface of the Java API for XML Processing (JAXP)
License: Other
A XSLT package wrapping the XSLT interface of the Java API for XML Processing (JAXP)
License: Other
I'm using xslt4node in one of my project but after that im not able to run nyc or c8 code coverage testing.
my sample code : https://github.com/Krishman23/xslt4node-client-nyc-test-coverage
raised stackoverflow for same:
https://stackoverflow.com/questions/72208287/node-nyc-code-coverage-failing-while-using-xslt4node-and-mocha-testing
Hi
I am trying to process a very large (1.8GB) XML file, with an XSLT to JSON style sheet.
The process works fine with up to 5K records, however when I try to feed the full file with ~180K records - the system runs out of memory (even when I specify -Xmx=4096m)
I have split the XML file into 5K record chunks using an excellent https://github.com/remuslazar/node-xmlsplit package. Now I am able to process all 35 (or so) chunks one time - great!
However at the end of the transformation my node.js process would be sitting at around 4 GB in memory size. When I try the transformation again (it's supposed to be a daily process) - it will run out of memory.
So my question is - is there a way to release all memory resources after I am done with my XSLT processing?
Right now I am using a pretty ugly workaround - calling process.exit() and PM2 restarts my program. However I would like to see if there is a more civilized approach.
LINK : fatal error LNK1181: cannot open input file " ■/.obj" [C:\Work\SqnfmIniToWebConfig\node_modules
java\build\nodejavabridge_bindings.vcxproj]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/a">
<header>Header</header>
</xsl:template>
<xsl:include href="./src/template/a/a.xsl" />
<xsl:template match="/b">
<footer>Footer</footer>
</xsl:template>
</xsl:stylesheet>
code in my own node.js module (copied it from 1 of your tests as a starting point):
var ORDER = '<order><book ISBN="10-861003-324"><title>The Handmaid\'s Tale</title><price>19.95</price></book><cd ISBN="2-3631-4"><title>Americana</title><price>16.95</price></cd></order>';
var DISCOUNT = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:param name="discount"/><xsl:template match="/"><order><xsl:variable name="sub-total" select="sum(//price)"/><total><xsl:value-of select="$sub-total"/></total>15% discount if paid by: <xsl:value-of select="$discount"/></order></xsl:template></xsl:stylesheet>';
var RESULT = '<?xml version="1.0" encoding="UTF-8"?><order><total>36.9</total>15% discount if paid by: 1972/01/01</order>';
var config = {
xslt: DISCOUNT,
source: ORDER,
result: String,
params: {
discount: '1972/01/01'
}
};
xslt4node.transform(config, function (err, result) {
if (!err) {
console.log(">>RESULT:");
console.log(result);
}else{
console.log(">>ERROR:");
console.log(err);
}
});
On execution of this code I will get in the console:
Segmentation fault: 11
And the node app stops running. No line with >>ERROR:
either so it didn't go into callback. Memory access violation issue?
OSX 10.9.5
Java 1.8.0_45
Python 2.7.5
The first time I call transform it returns the following error:
[Error: Index: 0, Size: 0]
Subsequent calls are successful... something blocking on initialisation? It seems to only happen when I call transforms with either params or props set in the config which makes me suspect its something todo with the addTask function
function addTask(taskName, tasks, props, setter) {
tasks[taskName] = ['transformer', function (callback, results) {
async.forEach(Object.keys(props), function (p, callback) {
results.transformer[setter](p, props[p], callback);
}, callback);
}];
tasks.transform.unshift(taskName);
}
you can repeat it with the following test:
var xslt = require('xslt4node');
var transform = xslt.transform;
var ORDER = '<order><book ISBN="10-861003-324"><title>The Handmaid\'s Tale</title><price>19.95</price></book><cd ISBN="2-3631-4"><title>Americana</title><price>16.95</price></cd></order>';
var DISCOUNT = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:param name="discount"/><xsl:template match="/"><order><xsl:variable name="sub-total" select="sum(//price)"/><total><xsl:value-of select="$sub-total"/></total>15% discount if paid by: <xsl:value-of select="$discount"/></order></xsl:template></xsl:stylesheet>';
var config = {
xslt: DISCOUNT,
source: ORDER,
result: String,
params : {
hmmmm: 'laaa',
laaa: 'jaaa',
blaa: 'kaaa',
hmmm: 'daaa'
},
};
transform(config, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res);
}
});
I have managed to install it on an old mac running Yosemite but when I deploy my app to heroku it fails when tries to install xslt4node.
The first error I get is when the following command is issued:
node-gyp rebuild
Any clues
TIA
jcr
Hi, sorry if this is a noobish question, but i'm tying to get the result as the 2nd parameter of the transform() callback. I'm unsure what is meant by 'provide {function} String as argument for config.result property'. Again, i'm a noob so I apologize...
a quick code example would clear this up for me and teach me for the future.
Thanks
Is there a specific Java version need to run this on OSX 10.10?
Ran nodeunit test and was asked to install java, however I have 1.8.0_45-b14
installed.
$ nodeunit test/test.js
test.js
✔ configuration - ambiguous xslt
✔ configuration - ambiguous source
✔ configuration - source missing
✔ configuration - result missing
No Java runtime present, requesting install.
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Hi, here is how dependencies looks like in package.json file after I install xslt4node using npm:
"dependencies": { "java": ">=0.3.1", "async": ">=0.4.0" }
I am able to use transformSync() but having issues with transform(). On both Windows and Linux I'm getting TypeError: null is not a function message. Obviously there is a problem with a version of async dependency. When I edit this dependency in node_modules/xslt4node/package.json file to "async": "~=1.5.2"
everything works fine.
I would be very grateful if you could fix this as I use this package a lot and it's bit frustrating to manually edit package.json each time I build an application.
Thank you!
First, thank you for this module. I very much need it to move from an IIS/ISAPI approach to node.js
In my current templates, I use the following successfully. With this transformer, I get an error that the included template can't be found and it's listed in the error as being relative to my node project folder (which is 2 folders higher than the original xslt and not referenced in this code anywhere).
<xsl:include href="RptHeader.xslt"/>
I've also tried:
<xsl:include href="./RptHeader.xslt"/>
The structure is:
/project
/xml
/xslt
myTemplate.xslt (this includes "RptHeader.xslt")
RptHeader.xslt
The error indicates that /project/RptHeader.xslt
does not exist though. How do I fix this reference? My primary template shouldn't need a full path (and that would be a problem for our platform anyway as it's being migrated from another parser).
I am having a hard time trying to npm install this package on my machine. This is the stack trace below:
npm i xslt4node
[email protected] install /projects/new-platform-prototype/node_modules/java
node-gyp rebuildCXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaObject.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaScope.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/utils.o
SOLINK_MODULE(target) Release/nodejavabridge_bindings.node
ld: warning: directory not found for option '-L/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/jre/lib/server'ld: library not found for -ljvm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/nodejavabridge_bindings.node] Error 1
gyp ERR! build error
gyp ERR! stack Error:make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /projects/new-platform-prototype/node_modules/java
gyp ERR! node -v v8.6.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.
What is -ljvm
? I looked on Google and Stack Overflow but couldn't find anything.
I'm on El Captain, with Java 9.0.1 npm 5.0.6 and I have JDK installed correctly.
Would it be possible to add a function set java options like maximum heap size for JVM, etc ?
It looks like our transformation process is running out of heap memory when dealing with huge files.
node-java allows to set JVM parameters using something like
java.options.push('-Xmx1024m');
It would be great to have an API method similar to one that adds a particular XSLT library to classpath?
is it possible to run xslt4node.transform(config) synchronously?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.