ricksj
Technical User
- Sep 2, 2009
- 3
I'm trying to simply select the title text of my XML, but it's pickup all the text following the title element, which includes remarks and index items. Can someone help code the XSLT so that it only includes the main text?
XML...
XSLT...
XML...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<book>
<title id="w95002834">Book title</title>
<chapter id="v28950049">
<title id="v28950054">Introduction<remark>Topic code 123</remark></title>
<section id="w73443828">
<title id="w73443829">New Features<indexterm>
<primary>introduction</primary>
<secondary>new features</secondary>
</indexterm>
<indexterm>
<primary>What's New</primary>
</indexterm>
</title>
<para>text text</para>
</section>
<section id="w73482843">
<title id="w73443829">Fixes from the previous release<indexterm>
<primary>fixes</primary>
<secondary>new release</secondary>
</indexterm>
</title>
<para>text text</para>
</section>
</chapter>
</book>
XSLT...
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
<xsl:for-each select="book/chapter">
<xsl:value-of select="title" /><br />
<xsl:for-each select="section">
<xsl:value-of select="title" /><xsl:text> (</xsl:text><xsl:value-of select="@id" /><xsl:text>) </xsl:text><br />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>