[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: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Feb 2024 14:03:33 -0000
Re:  Getting all the text of an element
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

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.