cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conal Tuohy" <Conal.Tu...@vuw.ac.nz>
Subject RE: Getting access to SVG image metrics [was RE: document() function in Saxon 8.3 under Cocoon 2.1.7]
Date Wed, 20 Apr 2005 00:39:52 GMT
Wendell Piez wrote:

> >Otherwise, there's also a more long-winded but more flexible 
> way, where 
> >you transform the result of the DirectoryGenerator to produce 
> >xi:include elements pointing at a pipeline which extracts 
> image metrics 
> >from a file, and use the xinclude transformer to perform the 
> >inclusions, thereby calling that extraction pipeline once 
> for each file.
> 
> I assume I can do the same with the result of an Image 
> Directory generator, which (contrary to the docs) is listing 
> all my files, not just images (though height and width are 
> included with images).
> 
> But I need more details on how to do this. Can anyone direct 
> me further or provide me an example? (In the meantime I'll be 
> ferreting into the
> documentation.)

You need a pipeline something like this:

<map:match pattern="image-folder">
   <map:generate type="imagedirectory" ... />
   <map:transform src="convert-svg-file-to-xinclude.xsl">
      <map:parameter name="base-url"
value="cocoon:/extract-svg-metrics/"/>
   </map:transform>
   <map:transform type="xinclude"/>
   <map:serialize type="xml"/>
</map:match>

The stylesheet "convert-svg-file-to-xinclude.xsl" would transform
<dir:file> elements into <xi:include> elements:

<xsl:param name="base-url"/>
<xsl:template match="dir:file">
   <xi:include href="{concat($base-url,@name)}"/>
</xsl:template>

The next stage in the pipeline (xinclude) will then resolve these links
and call a pipeline for extracting metrics from an individual svg,
something like this:

<map:match pattern="extract-svg-metrics/*.svg">
	<map:generate src="{1}.svg"/>
	<map:transform src="extract-svg-metrics.xsl"/>
	<map:serialize type="xml"/>
</map:match>

NB the use of "cocoon:/" as the protocol just represents a call back to
the same sitemap.

HTH!!


> Given that SVGs are (sort of) images, maybe the Image 
> Directory generator ought to report the dimensions of SVGs 
> out of the box ... then I wouldn't even need any of the fancy stuff.

Good point! That would be a far cleaner solution. How's your Java
skills? :-)


Con

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message