Subject: Re: [xsl] Need to output an opening or closing tag by itself From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Wed, 25 Jun 2008 12:58:48 +0530 |
As you have discovered, your stylesheet is not a well-formed XML so it cannot work through the XML parser. This looks to me a positional grouping problem, which can be solved efficiently in XSLT 1.0 with the "sibling recursion" technique. Below is the stylesheet for the same. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/root"> <root> <xsl:for-each select="e[@t = 'a']"> <e> <xsl:apply-templates select="following-sibling::*[1]" /> </e> </xsl:for-each> </root> </xsl:template> <xsl:template match="*"> <xsl:if test="not(self::e[@t = 'b'])"> <xsl:copy-of select="." /> <xsl:apply-templates select="following-sibling::*[1]" /> </xsl:if> </xsl:template> </xsl:stylesheet> On 6/25/08, David Frey <dpfrey@xxxxxxx> wrote: > I have a simple XSLT problem for the gurus. > > > This is my input document: > <root> > <e t="a"/> > <f/> > <f/> > <e t="b"/> > </root> > > > This is the output document I want to produce: > <root> > <e> > <f/> > <f/> > </e> > </root> -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need to output an opening, David Carlisle | Thread | Re: [xsl] Need to output an opening, David Frey |
Re: [xsl] Need to output an opening, Luke Stedman | Date | RE: [xsl] Need to output an opening, Hofman, Peter |
Month |