|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: write text using XSLT
> 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.
|
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
|

Cart








