Subject: Re: [xsl] Need to output an opening or closing tag by itself From: David Frey <dpfrey@xxxxxxx> Date: Wed, 25 Jun 2008 07:10:49 -0700 |
This looks like what I need. Thanks for all of the responses. David On Wednesday 25 June 2008 12:28:48 am Mukul Gandhi wrote: > 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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need to output an opening, Mukul Gandhi | Thread | RE: [xsl] Need to output an opening, Michael Kay |
RE: [xsl] XML to PDF (XSL:FO), Pankaj Chaturvedi | Date | Re: AW: [xsl] XML to PDF (XSL:FO), Wendell Piez |
Month |