[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting all the text of an element, except for one

Subject: Re: Getting all the text of an element, except for one type
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Feb 2024 14:15:26 -0000
Re:  Getting all the text of an element
> Here is my stylesheet but I am missing something in my understanding. Thanks
in advance for your help.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:math="http://www.w3.org/2005/xpath-functions/math"
>     exclude-result-prefixes="xs math"
>     version="3.0" expand-text="yes">
>
>     <xsl:output indent="yes"/>
>
>     <xsl:template match="/pub">
>         <xsl:copy>
>             <xsl:apply-templates select="section"/>
>         </xsl:copy>
>     </xsl:template>
>
>     <xsl:template match="section">
>         <entry><xsl:value-of select="title/descendant-or-self::* except
data"/></entry>
>     </xsl:template>
>
> </xsl:stylesheet>
>

What you are missing is that `<xsl:value-of
select="title/descendant-or-self::* except data"/>` concatenates the string
values of all the selected elements, including the `title` element and the
`ph` element, and the string value of an element is the concatenation of all
its descendant text nodes.

I would recommend using the recursive descent approach using template rules.
However, an alternative would be

<xsl:value-of select="title/descendant::text() except title//data/text()"
separator=""/>

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.