Re: [xsl] Can I change variable contents.

Subject: Re: [xsl] Can I change variable contents.
From: Mukul Gandhi <mukulgandhi2003@xxxxxxxxxxx>
Date: Thu, 8 Apr 2004 15:59:25 +0100 (BST)
Hi Vikram,
  Please try the XSL -

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" version="1.0"
encoding="UTF-8" indent="yes"/>
	
<xsl:key name="x" match="/root/Tag"
use="substring-before(@value, ':')" />
	
<xsl:template match="/root">
   <xsl:for-each select="Tag">
       <xsl:if test="generate-id(.) =
generate-id(key('x', substring-before(@value,
':'))[1])">
            <xsl:for-each select="key('x',
substring-before(@value, ':'))">
              <xsl:value-of
select="substring-after(@value, ':')" /><xsl:text>
</xsl:text>
            </xsl:for-each> from <xsl:value-of
select="substring-before(./@value, ':')" />
       </xsl:if>
   </xsl:for-each>
</xsl:template>
	
</xsl:stylesheet>

It uses Muenchian method for grouping as suggested by
David Carlisle. 

Regards,
Mukul

 --- Vikram Barate <vikram@xxxxxxxxxx> wrote: > I'm
trying to explain my problem in following
> example.
> I've following kind of xml
> 
> <Tag value="grade:1">
>     .....
> </Tag>
> <Tag value="sub:B">
> ....
> </Tag>
> <Tag value="grade:2">
>     .....
> </Tag>
> <Tag value="grade:3">
> ...
> </Tag>
> <Tag value="sub:A">
> ...
> </Tag>
> 
> and I want to generate output in text format as
> follows:
> 
> 1 2 3 from grade
> A B from sub
> 
> values attribute of Tag1 node can contain anything
> in fomat "X:Y", and 
> I've to print all values of the Ys for all the Xs in
> above shown format.
> I tried appling some logics but I could not achieve
> this yet. Can anyone 
> suggest me simple logic in xsl to achieve this.
> 
> One general Question: If we can't change
> xsl:variable, then why it is 
> named variable? is should be xsl:constant.
> 
> Thanx,
> Vikram.
> 
> cknell@xxxxxxxxxx wrote:
> 
> >> -----Original Message-----
> >> From:     Vikram Barate <vikram@xxxxxxxxxx>
> >>
> >>
> >> Can I change value of variable declared using
> <xsl:variable> tag.
> >
> >
> > No
> >
> >> If no then is there any other way i can create
> VARIABLES and update 
> >> those.
> >
> >
> > No
> >
> > As has been said here before many times, tell us
> what you need to 
> > accomplish, not how you wish to accomplish it, and
> we can help.
>  

________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/

Current Thread