0

我有一个 XSL 文件,它是为与 XSLT 2.0 转换器一起使用而编写的,但现在我需要更改文件以使其与 XSLT 1.0 一起使用。我知道for-each-group-command 是 XSLT 2.0 的一个特性,但是所有其他的东西呢?我将如何更改我的文件以使其适用于 1.0?

这是 XSL 文件:

<xsl:template match="ROWSET">

    <ROWSET>
        <xsl:for-each-group select="ROW" group-by="UKID">
            <UEBERKUNDE>
                <NAME><xsl:value-of select="UEBERKUNDE" /></NAME>
                <xsl:copy-of select="UKID" />
                <xsl:for-each-group select="current-group()" group-by="KUNDENNR">
                    <KUNDE>
                        <xsl:copy-of select="KUNDENNR" />
                        <xsl:copy-of select="KNAME1" />
                        <xsl:copy-of select="KNAME2" />
                        <xsl:copy-of select="KNAME3" />
                        <xsl:copy-of select="LAND" />
                        <xsl:copy-of select="PLZ" />
                        <xsl:copy-of select="ORT" />
                        <xsl:copy-of select="ADM" />
                        <xsl:copy-of select="KUNDENKLASSE" />
                        <xsl:copy-of select="MITARBEITER" />
                        <xsl:copy-of select="BELEGART" />
                        <EFAKTURA><xsl:value-of select="normalize-space(EFAKTURA)" /></EFAKTURA>
                        <WEBSTATUS><xsl:value-of select="normalize-space(WEBSTATUS)" /></WEBSTATUS>
                        <ZAHLUNGSBEDINGUNG><xsl:value-of select="normalize-space(ZAHLUNGSBEDINUNG)" /></ZAHLUNGSBEDINGUNG>

                        <xsl:for-each select="current-group()[count(. | key('rowsByMonth', concat(MONAT,'+',JAHR,'+',KUNDENNR))[1]) = 1]">
                            <ROW>
                                <xsl:copy-of select="JAHR" />
                                <xsl:copy-of select="MONAT" />
                                <xsl:copy-of select="HANDLING" />
                                <xsl:copy-of select="SOLLFRACHT" />
                                <xsl:for-each select="key('rowsByMonth', concat(MONAT,'+',JAHR,'+',KUNDENNR))">
                                    <WARENGRUPPE>
                                        <xsl:copy-of select="HGNAME" />
                                        <xsl:copy-of select="HGID" />
                                        <xsl:copy-of select="DG_BASIS" />
                                        <xsl:copy-of select="EKECHT" />
                                        <xsl:copy-of select="DB_BASIS" />
                                        <xsl:copy-of select="NETTO" />
                                    </WARENGRUPPE>
                                </xsl:for-each>
                            </ROW>
                        </xsl:for-each>
                    </KUNDE>
                </xsl:for-each-group>
            </UEBERKUNDE>
        </xsl:for-each-group>
    </ROWSET>
</xsl:template></xsl:stylesheet>

提前致谢!

4

1 回答 1

0

If you want to do grouping in XSLT 1.0 then see http://www.jenitennison.com/xslt/grouping/muenchian.xml for simply "group by" and http://www.biglist.com/lists/xsl-list/archives/200101/msg00070.html for nested grouping.

So

<ROWSET>
    <xsl:for-each-group select="ROW" group-by="UKID">
        <UEBERKUNDE>
            <NAME><xsl:value-of select="UEBERKUNDE" /></NAME>
            <xsl:copy-of select="UKID" />
            <xsl:for-each-group select="current-group()" group-by="KUNDENNR">

roughly translate into two keys

<xsl:key name="by-ukid" match="ROW" use="UKID"/>

<xsl:key name="by-nr" match="ROW" use="concat(UKID, '|', KUNDENNR)"/>

and

<ROWSET>
    <xsl:for-each select="ROW[generate-id() = generate-id(key('by-ukid',UKID)[1])]">
        <UEBERKUNDE>
            <NAME><xsl:value-of select="UEBERKUNDE" /></NAME>
            <xsl:copy-of select="UKID" />
            <xsl:for-each select="key('by-ukid', UKID)[generate-id() = generate-id(key('by-nr', concat(UKID, '|', KUNDENNR))[1])]">

If you have further nested grouping you need more keys with concatenated key values.

于 2013-07-02T14:41:49.740 回答