Dave-

I am still struggling with the concept, most likely because I started in
Xalan-J.  From my perspective, it appears the implemetations are
considerably different.  The vendor product I'm using makes the Xalan-C++
library call to do the stylesheet transformation.  I unfortunately have no
control over the application referencing the Xalan-C++ library.  All I have
control over is the XSLT, which I make the function extension call from.  In
Xalan-J, not a problem because the Xalan.jar file knows that Rhino is
available to handle my javascript and do the file read.

So correct me on this thought process for Xalan-C++:

No doubt I can create a C++ function extension to read the file but if I
can't embed it in the application referencing the Xalan-C++ library to do
the stylesheet transformation, then I'm out of luck?  Or is there a way for
me to create this function extension as a stand-alone DLL that gets called
when the Xalan-C++ library, called by the vendor application, comes across
the function call in my XSLT.

Still confused about the sequence of events...I've read the example on
apache.org about 100 times but it is still not sinking in.

Thank you for your patience with a new learner.

Regards,
Brad




David Bertoni wrote:
> 
> On 2/20/2010 11:53 AM, bradley.peder...@gmail.com wrote:
>> 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’m a 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.
> You don't need to rebuild Xalan-C, but you need to make sure you're 
> using the same version of Visual Studio (including service pack level) 
> as the vendor.
> 
>> 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))"/>
> This is easy to do with an extension function. Take a look at the 
> ExtensionFunction sample application for more information on how to 
> write and install extension functions.
> 
> You will also need to know the encoding of the input file you'll be 
> reading, so you'll need to ask your vendor about that. Once you know 
> that information, it should be very straightforward to read the data 
> from the file using your favorite C/C++ library function, transcode the 
> data from the source encoding to UTF-16 using a transcoder from 
> Xerces-C, then append the data to a XalanDOMString instance. Take a look 
> at the class FunctionAsctime in the ExternalFunction sample, for an
> example.
> 
> Dave
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Xalan-C%2B%2B-Funciton-Extension-Help---Example-tp27669823p27670770.html
Sent from the Xalan - C - Users mailing list archive at Nabble.com.

Reply via email to