Oracle XPATH question 2006-03-17 - By Davey, Alan
Oh, and for anyone trying to follow this at home, make sure your xsl template text is correct. I experienced numerous ORA-03113 (See ORA-03113.ora-code.com) errors while learning its syntax :-)
Alan
-- --Original Message-- -- From: oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] On Behalf Of Davey, Alan Sent: Friday, March 17, 2006 1:22 PM To: Christian Antognini Cc: oracle-l@(protected) Subject: RE: Oracle XPATH question
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@(protected)] Sent: Thursday, March 16, 2006 5:25 PM To: Davey, Alan Cc: oracle-l@(protected) 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񣍨) eventually in 3 years I'll know how to do it. -- http://www.freelists.org/webpage/oracle-l
-- http://www.freelists.org/webpage/oracle-l
|
|