Hi,
I'm having some difficulty using the for-each-group element in the XMLTransform PL/SQL function on an XMLType.
According to the documentation (and this thread here
505445 ), the XSL features supported are those given in
XSL Transformations (XSLT) Version 2.0
W3C Working Draft 15 November 2002
(see [http://www.w3.org/TR/2002/WD-xslt20-20021115/] )
The OTN thread above also points to this article demonstrating the use of some XSLT 2.0 features [http://www.oracle.com/technology/pub/articles/wang_xslt.html] and the use of for-each-group is shown amongst them.
However, I can't seem to get this to work. Here's the full text of my attempt (which is different from the example in the OTN article which BTW just looks plain wrong to me!):
select xmltype('
<FC_DATA_SET>
<FC_DATA>
<SD>2008-08-01</SD>
<SP>4</SP>
<FD>2008-08-01 23:14</FD>
<FV>-31318.000</FV>
<FT>INDDEM</FT>
</FC_DATA>
<FC_DATA>
<SD>2008-08-01</SD>
<SP>5</SP>
<FD>2008-08-01 23:44</FD>
<FV>-31554.000</FV>
<FT>INDDEM</FT>
</FC_DATA>
<FC_DATA>
<SD>2008-08-01</SD>
<SP>4</SP>
<FD>2008-08-01 23:14</FD>
<FV>-31318.000</FV>
<FT>INDGEN</FT>
</FC_DATA>
<FC_DATA>
<SD>2008-08-01</SD>
<SP>5</SP>
<FD>2008-08-01 23:44</FD>
<FV>-31554.000</FV>
<FT>INDGEN</FT>
</FC_DATA>
</FC_DATA_SET>
').transform(XMLType('
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:for-each-group select="FC_DATA_SET//FC_DATA" group-by="SD">
<xsl:sort select="SD"/>
<SD SD="{SD}">
<xsl:for-each-group select="current-group()" group-by="SP">
<xsl:sort select="SP"/>
<SP SP="{SP}">
<DATA type="{FT}"/>
</SP>
</xsl:for-each-group>
</SD>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
')) as result from dual
When this runs, Oracle says "LPX-00602: Invalid child element 'for-each-group' of element 'template'." It would seem that it doesn't understand the "for-each-group" element. Doesn't the line:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
tell Oracle that this is an XSLT 2.0 stylesheet where that element is valid?
Any help on this would be much appreciated since I have found that using Meunchian grouping under XSLT 1.0 is too slow for my needs and I'm hoping that the grouping in XSLT 2.0 willl be much better.
Thanks,
Andy