Corinna: Could you use Xalan-J instead of Xalan-C? It would be fairly straightforward to write a Java class that called, via JNI, your C libraries. This class could then be used from with Xalan-J.
- Rick -----Original Message----- From: Corinna Kinchin [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 1:38 PM To: [EMAIL PROTECTED] Subject: Re: Help! Extension functions ... Dave, Thanks for your feedback, as always. It's really appreciated. To give a bit more background on why I believe an extension function is necessary: we have a home grown `C' library of functions which will pull out image file metadata, such as image width, height, aspect ratio, no of pics and dpi. What we're trying to do is to give our users the ability to get at this image data via a Xalan-C++ XSLT extension function. As a test, I've adapted the ExternalFunction example to create an imageWidth extension function which returns the width of a given image file, so something like: <xsl:variable name="width"> <xsl:value-of select="external:imageWidth(@file)"/> </xsl:variable> will assign the image width to the variable named `width'. In principle I could define a whole set of extensions, one for each item of image meta data ... but the overhead of repeatedly parsing the (possibly huge) image file makes this unworkable. So - I read somewhere that an extension function could return a nodeset, and thought that this could be a neat solution: returning an <ImageMetaData ..> element, for example, with the width and height given as attribute values. But in the meantime perhaps the result tree fragment could be the way to go? Thanks for your patience, and thank you for your great help. It's been wonderful. Corinna ... Corinna Kinchin email: [EMAIL PROTECTED] Datazone Ltd. Tel: +44-(0)20-7221 8026 133 Notting Hill Gate Fax: +44-(0)20-7727 6045 London W11 3LB, England. URL: http://www.miramo.com Datazone - makers of `Miramo', the automated publishing tool > Hi Corinna, > > This is a bit tricky in Xalan-C++ as we don't really have a public > interface for creating fragments. One thing you can do is to look at the > code to see how we create things internally, then copy that code into your > function. Other ways include generating the element and attributes using > xsl:element and xsl:attribute, or creating a result tree fragment and use > the nodeset extension function to convert it into a nodeset. Those are > easier than writing an extension function, provided you have a way to get > the data from the Width and Height attributes. > > Extension functions can be dangerous if they have any side-effects. They > also require that you install the function into the run-time. A result > tree fragment requires no extra support, aside from the already-supplied > nodeset extension function. Also, when moving to XSLT 2.0, there will no > longer be any need for the nodeset function, so your stylesheet can be > quickly modified to be portable, rather than proprietary > > If you can describe more about the source for the data you'll be using to > create the element and attributes, perhaps someone can illustrate how you > can accomplish what you want to do without resorting to an extension > function. > > Dave > > > Hi all, > > I'm trying to write an extension function which > creates a new `Dim' element with `Width' and `Height' > attributes set to numeric values, and which returns the > `Dim' element as a node-set. More generally, I want > to return a set of values from an extension function, > rather than just a string or number (which is beautifully > illustrated in the ExternalFunction example). > > Being new to this area, I can't for the life of me > figure out how to do this yet ... I can create > a node set but how to add an element (node?) to it?? > (haven't quite got a grip on the terminology yet). > > If anyone has any pointers (eg code snippets which might > give me some ideas, they don't have to be complete or perfect), > I'd really appreciate your feedback. > > Thanks! > > Yours flummoxedley, > > > Corinna ... > > Corinna Kinchin email: [EMAIL PROTECTED] > Datazone Ltd. Tel: +44-(0)20-7221 8026 > 133 Notting Hill Gate Fax: +44-(0)20-7727 6045 > London W11 3LB, England. URL: http://www.miramo.com > > Datazone - makers of `Miramo', the automated publishing tool >
