xsl-list
[Top] [All Lists]

Re: Grouping and numbering in XSLT 2.0,

2005-11-14 03:04:43
The v2.0 solution to this problem, could be nice to see. So, If someone
of you could show me, I would appreciate that.

I don't think you need any grouping or 2.0 featuers here, you just
need to apply-templates to the <value> elements of the company cell,
then to the others in the same position:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
        <vendors>
                <xsl:apply-templates select="/vendors/cell[(_at_)name = 
'Company']/value"/>
        </vendors>
</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="/vendors/cell[(_at_)name = 
'Cage']/value[$pos]"/>
                <xsl:apply-templates select="/vendors/cell[(_at_)name = 
'Address']/value[$pos]"/>
        </vendor>
</xsl:template>

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

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

</xsl:stylesheet>

produces:

<?xml version="1.0" encoding="utf-8"?>
<vendors>
        <vendor>
                <cell name="Company">
                        <value>AMPHENOL AEROSPACE OPERATIONS</value>
                </cell>
                <cell name="Cage">
                        <value>77820</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>ITT CANNON</value>
                </cell>
                <cell name="Cage">
                        <value>71468</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>SOURIAU CONNECTION TECHNOLOGY (FCI)</value>
                </cell>
                <cell name="Cage">
                        <value>F0225</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>DEUTSCH ECD</value>
                </cell>
                <cell name="Cage">
                        <value>11139</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>AERO ELECTRIC CONNECTOR INC</value>
                </cell>
                <cell name="Cage">
                        <value>59976</value>
                </cell>
                <cell name="Address">
                        <value>TORRANCE</value>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>AMPHENOL CORPORATION</value>
                </cell>
                <cell name="Cage">
                        <value>74868</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
        <vendor>
                <cell name="Company">
                        <value>TEC ELECTRICAL COMPONENTS LTD</value>
                </cell>
                <cell name="Cage">
                        <value>K0690</value>
                </cell>
                <cell name="Address">
                        <value/>
                </cell>
        </vendor>
</vendors>


cheers
andrew

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