Hi,

    If you do want to try using Xalan-J you could also use Java classes 
to read image width, height, dpi etc. One useful class might be 
ImageInfo, available at 
http://www.geocities.com/marcoschmidt.geo/java-image-coding.html which 
supports all the common image types. This page also lists many other 
useful image libraries for Java.

    You might also be able to pre-generate the image metrics in XML and 
refer to it via document(), which will let you access a document other 
than the main source document from your stylesheet, so you could have a 
tiny XML doc associated with each image containing the metrics for each 
image. Or a larger XML doc with one element for each image with the 
metrics for that image which you reference with document() and select 
the image metrics element you require.

    Or alternatively pass the image details in as parameters to the 
stylesheet.

        Regards,

            Padraig

Rick Bullotta wrote:

>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
>>
>
>
>



Reply via email to