[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Inserting File Attributes Into XSLT Output


Subject: Re: [xsl] Inserting File Attributes Into XSLT Output
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
Date: Wed, 12 Dec 2012 14:39:05 -0500

Nathan,

XSLT 1.0 won't do this by itself, as it has no way of querying the
file system to get (in this case) the file size.

In general, there are two ways to do it. First, depending on your
processor you may be able to use an extension. For example, some
processors let you call functions in Java, which you could use to get
the info. More commonly, however, we'd do this by making the
information available in a form XSLT can use. For example, if you have
a directory listing in XML, you can query it easily from your XSLT
using the document() function.

So, the best answer depends on your environment and the means
available to you to acquire or generate the info. There are shell
applications that will create directory listings in XML (such as
XMLStarlet or xmlsh); also many XML/XSLT platforms such as Apache
Cocoon can give one to you (if you know how to ask).

Assuming your data does not change very frequently you can even do it
by hand (although I wouldn't).

Cheers,
Wendell




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
>



-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^


Current Thread
Keywords