[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to get elements in a row?

Subject: RE: How to get elements in a row?
From: "Elovirta Jarno (NBI/Espoo)" <Jarno.Elovirta@xxxxxxxxx>
Date: Thu, 17 Jan 2002 13:21:04 +0200
nbi comma format
> 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>&#xA;</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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.