Subject: Re: Put a wrapper around a series of elements From: Miloslav Nic <nicmila@xxxxxxxxx> Date: Thu, 09 Nov 2000 08:57:59 +0100 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="a"> <a> <xsl:apply-templates select="*"/> </a> </xsl:template> <xsl:template match="b"> <xsl:if test="not(name(preceding-sibling::*[1])='b')"> <bset> <xsl:copy-of select="."/> <xsl:apply-templates select="following-sibling::*[1]" mode="set"/> </bset> </xsl:if> </xsl:template> <xsl:template match="b" mode="set"> <xsl:copy-of select="."/> <xsl:apply-templates select="following-sibling::*[1]" mode="set"/> </xsl:template> <xsl:template match="*" mode="set"/> <xsl:template match="*"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> It needs some more work to make it really general, but I hope it will give you some ideas. Hal Stanley wrote: > > This seems like it should be easy but I'm stumped. I > tried FAQ, books. . . > > Have > > <a> > <b>some text</b> > <b>some more text</b> > <b>some other text</b> > <b>some last text</b> > <c>some c text</c> > </a> > > Want > > <a> > <bset> > <b>some text</b> > <b>some more text</b> > <b>some other text</b> > <b>some last text</b> > </bset> > <c>some c text</c> > </a> > > I successfully tested for the first and last <b>, but > couldn't output unmatched elements. . . > > Is there a better way? > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- ****************************************** <firstName> Miloslav </firstName> <surname> Nic </surname> <mail> nicmila@xxxxxxxxx </mail> <support> http://www.zvon.org </support> <zvonMailingList> http://www.zvon.org/index.php?nav_id=4 </zvonMailingList> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Put a wrapper around a series of el, Hal Stanley | Thread | RE: Put a wrapper around a series o, Kay Michael |
Global Variables referencing each o, Steve Brown | Date | Re: Global Variables referencing ea, Ovidiu Predescu |
Month |