File: Data.xml
<chapter>
<title>The Chapter</title>
<sect1>
<title>First Section</title>
<figure>
<title>First picture in book</title>
<graphic fileref="pic1.jpg" />
</figure>
</sect1>
<sect1>
<title>Second Section</title>
<sect2>
<title>Second Section, First Subsection</title>
<figure>
<title>Second picture in book</title>
<graphic fileref="pic2.jpg" />
</figure>
</sect2>
<sect2>
<title>Second Section, Second Subsection</title>
<para>This one has no figure.</para>
</sect2>
<sect2>
<title>Second Section, Third Subsection</title>
<figure>
<title>Fourth picture in book</title>
<graphic fileref="pic3.jpg" />
</figure>
</sect2>
</sect1>
</chapter>
File: Transform.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" />
<xsl:strip-space elements="*" />
<xsl:template match="figure">
[
<xsl:apply-templates />
]
</xsl:template>
<xsl:template
match="para | chapter/title | sect1/title | sect2/title " />
</xsl:stylesheet>
Output:
[
First picture in book
]
[
Second picture in book
]
[
Fourth picture in book
]
|