Dave,

Well I've just learned a lot ... thanks! See comments
below ...

> Hi Corinna,
> 
> This is a case where you might use an extension function, but you might
> want to consider other approaches.  You say you're going to have to "parse"
> this image file.  Is it an xml file?  If it is, you could pre-parse it and
> pass it in as a param.  Or, you could have your extension function parse
> the file once, then cache the result and return the bits that were asked
> for.

Of course ... that's what I'll do!

> Repeatedly constructing fragments to return to the caller is very
> expensive, and is only necessary when the information is not already
> available as XML, or its value depends on another variable.  It's usually
> better to consider a solution where the data can be returned as strings or
> numbers, depending on its proper type.  If information is returned as a
> fragment, it must be returned as string values, which means the end user
> will need to search the fragment for the appropriate information, then
> perhaps convert it to a number.  That sort of thing can be very expensive.
> For example, your "imageWidth" function would probably want to return a
> number, so you can construct a variable that contains a number :

Well golly gosh (as we say in England - not), I thought that this:

>    <xsl:variable name="width" select="external:imageWidth(@file)"/>

was exactly what I was doing with this:

>    <xsl:variable name="width">
>        <xsl:value-of select="external:imageWidth(@file)"/>
>    </xsl:variable>

... but now I see it wasn't. Realisation dawns ...

> Is there any reason why your extension function can't cache enough
> information to make repeated lookups more efficient?  

No, absolutely none that I can think of ... now. 8)

> If you could elaborate more on the format of your data, it would help.

FWIW the image files are GIF,TIFF,EPS,JPEG format ... the usual
suspects in short.

I've bounced your email around the office and we're all 
awe-inspired by the excellence of your help.

So, must dash - got a spot of programming to do 8)

Thanks again,

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