Subject: Re: [xsl] write text using XSLT From: Will McCutchen <mccutchen@xxxxxxxxx> Date: Mon, 22 Aug 2005 17:16:37 -0500 |
> In the above stylesheet I want > product_number,product_id,quantity,size to be written > into the text format only once. But for each product > row I get the above names written. Kindly suggest me > how to solve the above problem. It would be easier to answer your question if you included at least part of your XML source document. Without that, here is my (untested, quick) suggestion, which might serve as a sort of outline (it's also attached, to preserve formatting): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:template match="/"> <xsl:text>product_number,product,quantity,size</xsl:text> <xsl:call-template name="br" /> <xsl:apply-templates /> </xsl:template> <xsl:template match="..."> <xsl:value-of select="description/@product_number"/>,<xsl:value-of select="description"/>,<xsl:value-of select="quantity"/>,<xsl:value-of select="size"/> <xsl:call-template name="br" /> </xsl:template> <!-- this template just inserts a line break, so it's called after each line --> <xsl:template name="br"><xsl:text> </xsl:text></xsl:template> </xsl:stylesheet> I don't know what element the second template should match, since you didn't provide some example XML source, so you'll need to fill that in on your own. I added a template named br, which is something I have found useful when using XSL to output plain text. In my real "br" template, there's an <xsl:choose> block which outputs platform-specific line breaks based on an $output-platform parameter. Hope this helps, Will.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] write text using XSLT, Jon Gorman | Thread | RE: [xsl] write text using XSLT, Ross, Douglas |
Re: [xsl] xsl:sort clarification, David Carlisle | Date | RE: [xsl] xsl:sort clarification, Michael Kay |
Month |