Subject: [xsl] transforming from flat to hierarchical "grouping" From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx (by way of Mulberry Technologies List Owner) Date: Wed, 18 Apr 2001 08:42:10 -0400 |
Subject: help: transforming from flat to hierarchical "grouping" To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Date: Tue, 17 Apr 2001 21:29:39 -0400 Message-ID: <OFA0E7C551.C9E2D17E-ON85256A32.00048401@xxxxxxxxxxxxxx> X-MIMETrack: Serialize by Router on Pan/PercWeb(Release 5.0.5 |September 22, 2000) at 04/17/2001 09:31:52 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii I want to transform this source XML (fragment): <article category="news">foo1</article> <article category="news">foo2</article> <article category="sports">foo3</article> <article category="news">foo4</article> <article category="sports">foo5</article> <article category="local">foo6</article> to this ouput XML: <news> <article>foo1</article> <article>foo2</article> <article>foo4</article> </news> <sports> <article>foo3</article> <article>foo5</article> </sports> <local> <article>foo6</article> </local> Nowhere are the possible values of the "category" attribute defined. Each source XML is allowed to use any number of category values (and have any number of articles) but each article has only one category attribute value. I can get pretty close with this XSL: <xsl:template match="/"> ... <xsl:apply-templates select="descendant::article"/> ... </xsl:template> <xsl:template match="article"> <xsl:element name="{@category}"> <article> <xsl:apply-templates /> </article> </xsl:element> </xsl:template> But the output I get now is not "grouped" properly. It is: <news><article>foo1</article></news> <news><article>foo2</article></news> <sports><article>foo3</article></sports> <news><article>foo4</article></news> <sports><article>foo5</article></sports> <local><article>foo6</article></local> The sorting does not matter, just that there can only be one <news> element, one <sports> element, and so on for each category. I'm using XT. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] how can I compare two xml fil, Tom Belich | Thread | RE: [xsl] transforming from flat to, Jarno Elovirta |
[xsl] how can I compare two xml fil, Mengel Andre (FV/SLM | Date | [xsl] xml too big, CONTE Silvia |
Month |