Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XSLT - removing a tag from within text >Thread Next - Re: XSLT - removing a tag from within text Re: XSLT - removing a tag from within textTo: NULL Date: 6/17/2009 2:34:00 PM gwoodhouse@g... wrote: > Ok, so, i can't include the whole code or else my company would beat > the hell out of me. Here is a more complete and realworld snippet: > > <transcript> > <chapter> > <chapter_hitcount><![CDATA[1 hit]]></chapter_hitcount> > <start_time><![CDATA[01:11:04]]></start_time> > <end_time><![CDATA[01:<span class="hit">22</span>:45]]></end_time> > <abstract> You can see here how you would want <span > class="hit">22</span> to be displayed</abstract> > </chapter> > </transcript> > > xslt: > <xsl:template match='chapter'> > <span class="timespan"> > (<xsl:apply-templates select="start_time"/> - <xsl:apply-templates > select="end_time"/>) > </span> > <div class="abstract"> > <span class="abstractLead">Summary:</span> <xsl:apply-templates > select="abstract"/> > </div> > </xsl:template> > > In this example i would want the output to display the "abstract" > output with the span tag, i would want the "end_time" tag to display > without the <span> tag. Well that is completely different from what you posted before and in the sample above the 'abstract' element contains a 'span' element while the 'end_time' element does not contain a 'span' element, instead it contains pure text with escaped markup. The 'abstract' element can easily be solved with XSLT <xsl:template match="abstract"> <div class="{local-name()}"> <xsl:apply-templates/> </div> </xsl:template> then you need to add a template matching span that copies that <xsl:template match="span"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> The 'end_time' element is difficult. If I had a choice I would solve it with XSLT 2.0 and David Carlisle's HTML parser done in XSLT (http://www.dcarlisle.demon.co.uk/htmlparse.xsl) but I don't know whether that is an option for you. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
