To all-
Earlier this week, I was able to read a file in XSLT using Xalan-J function
extensions (XJ 2.7, BSF 2.4, Rhino 1.7). The mechanism is very simple
JavaScript with Java Class calls. It works very elegantly (simple) as shown
below. However, I learned that the vendor software that will run the
transformation uses Xalan C++ (v1.9 with Xerces 2.6) and now I have to
rewrite using function extensions in C++. I suppose I'm ignorant for not
checking up front.
However, proceeding with Xalan-C++, my primary question is: In order to use
custom function extensions in Xalan C++, do I have to rebuild the Xalan C++
library or is there a way to install an extension function without rebuild?
As noted, I'm using a vendor instance of Xalan C++ which they themselves
may have built, thus rebuilding may not be an option since I don't have
their source. I guess I'ma little stuck on how the installation of
extension functions work and really could use a step by step flow/example.
If I have to rebuild, I'll be using VS2005.
Here is what I'm trying to convert from Xalan-J to Xalan-C++ in case
someone has a snippet for Xalan-C++ that they would like to offer, all help
would be greatly appreciated. It worked so beautifully in Xalan-J, need to
get the same functionality in Xalan-C++.
SCRIPT FOR XALAN-J TO READ FILE
<xalan:component prefix="javascript" elements="" functions="readFile">
<xalan:script lang="javascript">
function readFile ( filename ) {
var text = '';
var filechar;
var i=0;
var file = new java.io.File(filename);
var FileReader = new java.io.FileReader(file);
var BuffReader = new java.io.BufferedReader(FileReader);
fileline = BuffReader.readLine();
while (fileline != null) {
text = text + fileline + '\n';
fileline = BuffReader.readLine();
}
BuffReader.close();
return text;
}
</xalan:script>
</xalan:component >
CALLED
<xsl:value-of select="javascript:readFile(string($LongTextFile))"/>
Regards,
Brad