Re: [xsl] Getting all the text of an element, except for one type

Subject: Re: [xsl] Getting all the text of an element, except for one type
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Feb 2024 14:03:33 -0000
On 09/02/2024 14:57, rick@xxxxxxxxxxxxxx wrote:
>
> Hi All. Here is my input:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <pub>
>
> B B B  <section>
>
> B B B B B B B  <title>This is my clever title with <ph>a phrase</ph> and
some
>
> data.<data>12345</data></title>
>
> B B B B B B B  <p>A plain paragraph.</p>
>
> B B B  </section>
>
> B B B  <section>
>
> B B B B B B B  <title>Another title without any children.</title>
>
> B B B B B B B  <p>Another plain paragraph.</p>
>
> B B B  </section>
>
> </pub>
>
> I want to get all of the text from the <title> elements are its
> children, except for <data> elements:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <pub>
>
> B B  <entry>This is my clever title with a phrase and some data. </entry>
>
> B B  <entry>Another title without any children.</entry>
>
> </pub>
>

I might use


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 B  version="3.0"
 B  xmlns:xs="http://www.w3.org/2001/XMLSchema";
 B  exclude-result-prefixes="#all">

 B  <xsl:output method="xml" indent="no"/>

 B  <xsl:mode on-no-match="shallow-copy"/>

 B  <xsl:template match="section">
 B B B  <entry>
 B B B B B  <xsl:apply-templates select="title" mode="text-without-data"/>
 B B B  </entry>
 B  </xsl:template>

 B  <xsl:mode name="text-without-data"/>

 B  <xsl:template mode="text-without-data" match="title//data"/>

</xsl:stylesheet>

Current Thread