This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]