Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSLT 2.0 feature "for-each-group" within 10.2.0.3 RDBMS

681638Jan 26 2009
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2009
Added on Jan 26 2009
0 comments
2,091 views