[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to get elements in a row?
> How I can get elements in a comma separated row without last comma and > header line? > Each item should have its features (one, two, three, four) > but also its > parent (sample1). > I am using xalan java processor 2.2.d13. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="ISO-8859-1" /> <xsl:template match="/"> <xsl:apply-templates select="samples/sample/items/item" /> </xsl:template> <xsl:template match="item"> <xsl:value-of select="../../name" />,<xsl:text /> <xsl:value-of select="name" />,<xsl:text /> <xsl:apply-templates select="features/feature" /> <xsl:if test="not(position() = last())"> <xsl:text>
</xsl:text> </xsl:if> </xsl:template> <xsl:template match="feature"> <xsl:apply-templates select="name" /> <xsl:if test="not(position() = last())">,</xsl:if> </xsl:template> </xsl:stylesheet> Hope I didn't change your stylesheet too much - if the structure is as you presented, you might want to consider writing the whole thing using xsl:for-each, i.e. pull-approach. Santtu 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
|