xsl-list
[Top] [All Lists]

Re: Can I change variable contents.

2004-04-08 07:59:25
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(_at_)kenati(_dot_)com> 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(_at_)onebox(_dot_)com wrote:

-----Original Message-----
From:     Vikram Barate <vikram(_at_)kenati(_dot_)com>


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.





--+------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
 

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