Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Problem with XMLType transform

Problem with XMLType transform

From: zogg <zogg1432_at_mail.com>
Date: 7 Mar 2006 15:44:14 -0800
Message-ID: <1141775054.173875.318540@i40g2000cwc.googlegroups.com>


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>

    </xsl:stylesheet>');

    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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US