[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: file manipulation with recursion
Hi Rick, > Thanks for all your help. I have a little twist to this file > however. Under each category node there could be zero, one or many > product nodes. I want to just display the id and name of the product > node as well, and they can appear under any category node. The > initial file format would be of the following... Then apply templates to the product elements as well as the category elements, and have a template for the product elements that creates a product element with the name and id inside: <xsl:template match="category"> <xsl:copy> <xsl:copy-of select="id" /> <xsl:copy-of select="name" /> <xsl:apply-templates select="category | product" /> </xsl:copy> </xsl:template> <xsl:template match="product"> <xsl:copy> <xsl:copy-of select="id" /> <xsl:copy-of select="name" /> </xsl:copy> </xsl:template> (You could probably actually combine these templates into: <xsl:template match="category | product"> <xsl:copy> <xsl:copy-of select="id" /> <xsl:copy-of select="name" /> <xsl:apply-templates select="category | product" /> </xsl:copy> </xsl:template> if you wanted.) The general pattern in XSLT is that for each element in your XML you have a template that shows how to map from that element to the element that you want to create in the result. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|