RE: [xsl] Re: Inserting File Attributes Into XSLT Output

Subject: RE: [xsl] Re: Inserting File Attributes Into XSLT Output
From: Michele R Combs <mrrothen@xxxxxxx>
Date: Wed, 12 Dec 2012 22:14:49 +0000
Interesting.  Yeah, it probably is in the PDF's metadata but it's also right
there on the file system.  You could use a simple dir + a script to generate a
lookup table that lists file names and sizes, then look up the information
during processing (see for example ).

But I wonder if you really need/want that data embedded in the finding aid.  I
mean, what if the file size changes after you've created your finding aid, do
you want to have to re-run it?  I think you might be better off writing a
separate function (in, say, php or something) that retrieves the file size and
pops up a dialog asking "File size is ginormous, do you want to continue? Y/N"
?  You could make it more sophisticated by, say, automatically passing through
file sizes smaller than xxx so people aren't annoyed by having to say YES a
bunch of times.

Then all your link in the finding aid has to do is call that script and pass
it the file name, for example:

<a href="checkfilesize.php?filename=ms0778.01.07.pdf" target="_blank"
title="Personal. 1916-1965.">[Digital Archival Object]</a>

You could also customize your XSL to only add the checkfilesize.php? part into
the href if it points to a PDF file.

I'm no php expert but there's probably somebody on the code4Lib list who's
done this.  A super simple version is here: .


-----Original Message-----
From: Nathan Tallman [mailto:ntallman@xxxxxxxxx]
Sent: Wednesday, December 12, 2012 4:19 PM
To: xsl-list
Subject: [xsl] Re: Inserting File Attributes Into XSLT Output

@Wendell -- At the present, I'm transforming XML to HTML locally, then posting
the HTML (and any dependent files) online. I am using Oxygen to edit the XML
and perform the transform. Within Oxygen, I can use several processors,
including Saxon. So, maybe a Java call is the way to go? We don't create a
directory listing in XML, but if it's fairly easy, perhaps that method is
possible. Any advice on how to proceed for either method?

@Michele -- Yes, it's the "2.5 MB" I'm looking to include. As we digitize
collections, the PDFs can be quite large, even after a lot of compression. Was
trying to find a way to inform the user of the linked PDF file size, so they
can download instead of opening in the browser, if they so choose. And no,
it's not in the XML or metadata. Although, it might be in the PDF's metadata,
just don't know an easy way to get at it.


On Wed, Dec 12, 2012 at 1:33 PM, Nathan Tallman <ntallman@xxxxxxxxx> wrote:
> Using XSLT 1.0, is it possible to insert linked file attributes during
> a transformation?
> For example:
> My XML:
> <dao linktype="simple" href="ms0778.01.07.pdf" actuate="onrequest"
> show="new"/>
> My XSLT:
> <xsl:template match="dao">
> <xsl:variable name="dao_title"
> select="preceding-sibling::unittitle/."/>
> <xsl:choose>
> <xsl:when test="self::dao[@role='bio']"> <img class="bio"
> src="{@href}" title="{@title}" width="180px" height="225px"/>
> </xsl:when>
> <!-- Default handling, loads object in a new window -->
> <xsl:otherwise> <a href="{@href}" target="_blank"
> title="{$dao_title}">[Digital Archival Object]</a> </xsl:otherwise>
> </xsl:choose> </xsl:template>
> XSLT Output:
> <a href="ms0778.01.07.pdf" target="_blank" title="Personal.
> 1916-1965.">[Digital Archival Object]</a>
> Desired XSLT Output:
> <a href="ms0778.01.07.pdf" target="_blank" title="Personal.
> 1916-1965.">[Digital Archival Object, 2.5 MB]</a>
> Many thanks,
> Nathan

Current Thread