RE: Oracle XPATH question

  • From: "Davey, Alan" <ddavey@xxxxxxxxxx>
  • To: "Christian Antognini" <Christian.Antognini@xxxxxxxxxxxx>
  • Date: Fri, 17 Mar 2006 13:21:51 -0500

Christian and others,

Thank you for the feedback.  This may not be the best solution, but by
using XSLT I can  get the results I was looking for:

SELECT XMLTRANSFORM
          (xmltype(a.xml_content),
           XMLTYPE
              ('<?xml version="1.0" ?>
             <xsl:stylesheet version="1.0"
 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
               <xsl:template match="/">
<xsl:for-each select="TAM/SI">
                 <posn><xsl:value-of select="position()"/></posn>
                 <station><xsl:value-of select="station"/></station>
                 <program><xsl:value-of select="programname"/></program>
                 ...
</xsl:for-each>
               </xsl:template>
              </xsl:stylesheet>'
              )
          )
  FROM BR_GTT_AVAIL_IMPORT a

The output of this can then be wrapped with another select statement to
produce the records and columns I was originally after.  The beauty of
this approach is that since I have to deal with two radically different
XML files containing similar data, I can dynamically choose the correct
template at run time and the outer select statement will still return
the correct result set.

The only possible flaw I can see with this approach would be if the
xsl:for-each didn't process nodes sequentially.  This seems unlikely,
but if someone knows otherwise, please let me know.

Regards,

Alan Davey

-----Original Message-----
From: Christian Antognini [mailto:Christian.Antognini@xxxxxxxxxxxx] 
Sent: Thursday, March 16, 2006 5:25 PM
To: Davey, Alan
Cc: oracle-l@xxxxxxxxxxxxx
Subject: RE: Oracle XPATH question

Alan

<snip>

If you find a good solution, please, let me know.

Regards,
Chris

PS: 3 years ago I posted a very similar answer... (see
http://forums.oracle.com/forums/thread.jspa?messageID=406376&#406376)
eventually in 3 years I'll know how to do it.
--
//www.freelists.org/webpage/oracle-l


Other related posts: