Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT select problem 1

Status
Not open for further replies.

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...
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&apos;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>
 
><xsl:value-of select="title" />
[tt]<xsl:value-of select="title[red]/text()[/red]" />[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top