Subject: [xsl] How to get elements in a row? From: Marko.Seppala@xxxxxxxx Date: Thu, 17 Jan 2002 12:20:24 +0200 |
Hi, 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. Wanted Output ****************************************************** sample1,item1,one,two sample1,item2,three,four ****************************************************** Current Output ****************************************************** <?xml version="1.0" encoding="UTF-8"?> sample1, item1, one, two, item2, three, four, ****************************************************** XML ****************************************************** <?xml version="1.0" encoding="UTF-8"?> <samples> <sample id = "1"> <name>sample1</name> <items> <item id = "1"> <name>item1</name> <features> <feature id = "1"> <name>one</name> </feature> <feature id = "2"> <name>two</name> </feature> </features> </item> <item id = "12"> <name>item2</name> <features> <feature id = "3"> <name>three</name> </feature> <feature id = "4"> <name>four</name> </feature> </features> </item> </items> </sample> </samples> ****************************************************** XSL ****************************************************** <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="samples"> <xsl:apply-templates select="sample"/> </xsl:template> <xsl:template match="sample"> <xsl:apply-templates select = "name"/> <xsl:apply-templates select = "items"/> </xsl:template> <xsl:template match="items"> <xsl:apply-templates select="item"/> </xsl:template> <xsl:template match="item"> <xsl:apply-templates select = "name"/> <xsl:apply-templates select = "features"/> </xsl:template> <xsl:template match="features"> <xsl:apply-templates select="feature"/> </xsl:template> <xsl:template match="feature"> <xsl:apply-templates select = "name"/> </xsl:template> <xsl:template match="name"> <xsl:value-of select = "."/>, </xsl:template> </xsl:stylesheet> ****************************************************** Thanks in advance! Marko XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] cascading tags, Jeni Tennison | Thread | RE: [xsl] How to get elements in a , Andrew Welch |
RE: [xsl] cascading tags, Bryan Rasmussen | Date | [xsl] xhtml DOCTYPE problem, Houbrechts Ivo |
Month |