[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
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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|