Subject: Re: [xsl] Grouping the elements From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 14 Sep 2006 14:34:25 +0200 |
<xsl:template match="Root"> <xsl:copy> <xsl:apply-templates select="year[position() = last()]" /> <xsl:apply-templates select="month[position() = last()]" /> <xsl:apply-templates select="week[position() = last()]" /> <xsl:apply-templates select="day[position() = last()]" /> </xsl:copy> </xsl:template>
<xsl:template match="*"> <xsl:variable name="curName" select="name()" /> <xsl:if test="count(../*[name() = $curName]) > 1"> <xsl:element name="{local-name(.)}List"> <xsl:copy-of select="../*[name() = $curName]" /> </xsl:element> </xsl:if> <xsl:if test="count(../*[name() = $curName]) = 1"> <xsl:copy-of select="." /> </xsl:if> </xsl:template>
Best regards, Abel Braaksma http://abelleba.metacarpus.com
Hi,
I have the following xml for my input..
<?xml version="1.0" encoding="UTF-8"?> <Root> <year>2006</year> <year>2007</year> <year>2008</year> <week>1</week> <day>01</day> <day>02</day> </Root>
My expected output is
<Root> <yearList> <year>2006</year> <year>2007</year> <year>2008</year> <yearList> <week>1</week> <dayList> <day>01</day> <day>02</day> </dayList> </Root>
I want to group the element using xslt 1.0 and here element name is not fixed..it will be varied. when we have the same element then we need a parent element which have the element's name with List (i.e., yearList)
Is it possible to grouping in xslt1.0?
regards, raj
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Grouping the elements, Arulraj | Thread | Re: [xsl] Grouping the elements, Mukul Gandhi |
[xsl] SSI echo as an attribute valu, tom tom | Date | Re: [xsl] How to View Entity Refere, Abel Braaksma |
Month |