xsl-list
[Top] [All Lists]

Re: Problem with generating references.

2005-07-05 05:48:41
Tempore 14:57:07, die 07/05/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Lakshmi narayana <lchintala(_at_)osi-tech(_dot_)com>:

for each element so that I can identify each element uniquely).

1. Divide the elements into groups.
2. While dividing, create the references to the elements in the current
group which are going to be placed in another group.

This stylesheet generates the ouput from your sample. It will need some adaption though, to work in a real situation.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="element" match="*" use="substring(local-name(),1,1)"/>

<xsl:template match="/">
<xsl:for-each select="//*[generate-id()=generate-id(key('element',substring(local-name(),1,1)))]">
                <xsl:element name="{substring(local-name(),1,1)}-group">
                        <xsl:for-each 
select="key('element',substring(local-name(),1,1))">
                                <xsl:copy>
                                        <xsl:for-each select="*">
<reference><xsl:attribute name="id"><xsl:number count="*" level="any"/></xsl:attribute></reference>
                                        </xsl:for-each>
                                </xsl:copy>
                        </xsl:for-each>
                </xsl:element>
        </xsl:for-each>
</xsl:template>

</xsl:stylesheet>


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Spread the wiki (http://www.wikipedia.org)

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>