[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Processing only certain nodes in a document fragme
This is simply a suggestion: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="foreach"> <xsl:for-each select="./in/item"> <xsl:call-template name="output"> <xsl:with-param name="cdata" select="text()"/> <xsl:with-param name="do-sect" select="/foreach/do/*"/> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="output"> <xsl:param name="cdata"/> <xsl:param name="do-sect"/> <xsl:for-each select="$do-sect"> <xsl:choose> <xsl:when test="name() ='var'"> <xsl:value-of select="$cdata"/> </xsl:when> <xsl:otherwise> <xsl:element name="{name()}"> <xsl:copy-of select="@*"/> <xsl:call-template name="output"> <xsl:with-param name="do-sect" select="./*" /> <xsl:with-param name="cdata" select="$cdata"/> </xsl:call-template> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet> Hope this helps.. Rui On Wed, 2004-02-18 at 21:26, Glenn MacGregor wrote: > Hi All, > > Thanks for all the help so far! I am having a problem with the following > document fragment: > > <foreach> > <in> > <item>test1</item> > <item>test2</item> > <item>test3</item> > <item>test4</item> > <item>test5</item> > </in> > <do> > <tr><td><var/></td><td><var/></td></tr> > <tr><td><var/> Test</td><td><var/> Test</td></tr> > </do> > </foreach> > > I need a template which will loop through all the <item> tags and replace the > "<var/>" tag in the <do> section with CDATA of the current item tag echoing all > the rest of the do tag to the result (without the <do> tag). > > Is this possible? If there is a better way to handle this please let me know I > have complete control the document, I can put any structure or XML in there. > > Thanks > > > > > Glenn MacGregor > HighStreet Networks > > ------------------------------------------------- > This mail sent through IMP: http://horde.org/imp/ > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- Rui Alberto L. Gonçalves <rui-l-goncalves@xxxxxxxxxxxxx> PT Inovação 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
|