xsl-list
[Top] [All Lists]

Re: Grouping and numbering in XSLT 2.0,

2005-11-15 07:14:29
Hi,

 Thanks for your reply, that solution worked well.

 However I have encountered a problem when i tried to apply the
 solution to more than one "<vendors>". The iteration becoms wrong. I
have added an XML  and
 an XSLT that shows the problem.

 I would be very pleased if some of you could take a look at it and
propose a solution.

You just need to adjust your paths from absolute to relative:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
       <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
        <vendors>
                <xsl:apply-templates/>
        </vendors>
</xsl:template>

       <xsl:template match="component">
               <component>
                       <xsl:apply-templates select="cell[(_at_)name
='Company']/value"/>
               </component>
       </xsl:template>

       <xsl:template match="cell[(_at_)name = 'Company']/value">
               <vendor>
                       <cell name="Company">
                               <xsl:copy-of select="."/>
                       </cell>
                       <xsl:variable name="pos" select="position()"/>
                       <xsl:apply-templates select="../../cell[(_at_)name
='Cage']/value1[$pos]"/>
                       <xsl:apply-templates select="../../cell[(_at_)name
='Address']/value2[$pos]"/>
               </vendor>
       </xsl:template>

       <xsl:template match="cell[(_at_)name = 'Cage']/value1">
               <cell name="Cage">
                       <xsl:copy-of select="."/>
               </cell>

       </xsl:template>
       <xsl:template match="cell[(_at_)name = 'Address']/value2">
               <cell name="Address">
                       <xsl:copy-of select="."/>
               </cell>
       </xsl:template>
</xsl:stylesheet>

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