Next in thread → Next in month →

Re: [docbook-apps] XSL - Extracting a list of images

From
Paul A. Hoadley <>
Date
2004-11-24T00:17:24+00:00
ID
Thread
Re: [docbook-apps] XSL - Extracting a list of images
On Tue, Nov 23, 2004 at 07:36:43PM +0000, Phil Weston wrote:

> ie. I have a number of ...<imagedata fileref="myfile1.png"/>... type
> elements spread liberally through my docbook XML and I want to
> produce a list that's like:
>
> myfile1.png
> myfile2.png
> myfile3.png

Use <xsl:output method="text"/> to make a text list, and then you want
two templates: match="imagedata" which prints the value of the
'fileref' attribute, and match="node()|@*" which does nothing but
apply-templates in order to ignore everything else.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output method="text"/>

  <xsl:template match="imagedata">
    <xsl:value-of select="@fileref"/>
    <xsl:text>&#10;</xsl:text>
  </xsl:template>

  <xsl:template match="node()|@*">
    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

&#10; is a linefeed.


-- 
Paul.

w  http://logicsquad.net/
h  http://paul.hoadley.name/
Next in thread → Next in month →