Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Problem with XMLType transform
I am trying to transform a simple xml node using the XMLType transform
function in Oracle 9i. However, the returned "transformed" xml is an
exact duplicate of the stylesheet. The code is below. Note: many of
the elements are optional and I only included some in the xml node.
declare
xmlNode xmltype := xmltype(
'<EIN>
<segment_id>EIN</segment_id> <earned_income_type>EIWA</earned_income_type> <employer_name>ATC TEMPE</employer_name> <earned_income_occurrence_cnt>01</earned_income_occurrence_cnt> <earned_income_amount>001360.00</earned_income_amount> <date_income_received>20050708</date_income_received> <hours_worked>000080</hours_worked> <earned_income_frequency_code>2</earned_income_frequency_code></EIN>');
xsl_ein_gross xmltype := xmltype(
'<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="EIN"> <EIN>
<xsl:copy-OF SELECT="./segment_id"/>
<xsl:copy-OF SELECT="./earned_income_data_rcvd_date"/>
<xsl:copy-OF SELECT="./last_income_update_id"/>
<xsl:copy-OF SELECT="./last_income_update_date"/>
<xsl:copy-OF SELECT="./earned_income_type"/>
<xsl:copy-OF SELECT="./employer_name"/>
<xsl:copy-OF SELECT="./employer_address_line_1"/>
<xsl:copy-OF SELECT="./employer_address_line_2"/>
<xsl:copy-OF SELECT="./employer_city"/>
<xsl:copy-OF SELECT="./employer_state"/>
<xsl:copy-OF SELECT="./employer_zip_code_base"/>
<xsl:copy-OF SELECT="./employer_zip_code_extension"/>
<xsl:copy-OF SELECT="./employer_phone_area_code"/>
<xsl:copy-OF SELECT="./employer_phone_number"/>
<xsl:copy-OF SELECT="./employer_phone_extension"/>
<xsl:copy-OF SELECT="./earned_income_occurrence_cnt"/>
<xsl:for-EACH SELECT="./earned_income_amount"> <EIN_Gross> <xsl:copy-OF SELECT="."/> </EIN_Gross>
</xsl:for-EACH>
<xsl:copy-OF SELECT="./earned_income_frequency_code"/>
</EIN> </xsl:template>
strEinNode VARCHAR2(4000);
begin
xmlNode := xmlNode.transform(xsl_Ein_Gross);
SELECT xmlNode.getstringval() AS ein_node
INTO strEinNode
FROM dual;
dbms_output.put_line(substr(strEinNode, 0, 255)); dbms_output.put_line(substr(strEinNode, 255, 255)); dbms_output.put_line(substr(strEinNode, 510, 255)); dbms_output.put_line(substr(strEinNode, 765, 255)); dbms_output.put_line(substr(strEinNode, 1020, 255)); dbms_output.put_line(substr(strEinNode, 1275, 255)); dbms_output.put_line(substr(strEinNode, 1530, 255)); dbms_output.put_line(substr(strEinNode, 1785, 255)); dbms_output.put_line(substr(strEinNode, 2040, 255));
end; Received on Tue Mar 07 2006 - 17:44:14 CST