|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Put a wrapper around a series of elements
<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
|
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
|

Cart








