using XSLT to combine several subject tags into one list

John Fitzgibbon jfitzgibbon at
Mon Mar 1 15:18:27 EST 2004


I have an XML document which is a catalogue of books. In the document, each book has three separate subject tags. For ease of explication, I will refer to them as subject1, subject2 and subject3. I wish to retrieve all subjects beginning with the letter 'F' irrespective of tag. This is how I try to do it.

<xsl:for-each select="(subject1 | subject2 | subject3)[starts-with(text(), 'F']">
<xsl:sort select="."/>

This retrieves an empty set. I suspect that the XSLT processor is stopping after subject1.

Secondly, if I can manage to retrieve all subjects beginning with the letter 'F', how do I eliminate duplicates? For example, the subject 'Fiction' can ocurr in any of the three subject categories in two separate books. This word will appear twice in my list. I need to avoid this.

Any help would be much appreciated.


More information about the xml4lib mailing list