13 Replies Latest reply on Nov 10, 2010 11:32 AM by yair_k

    LPX-00601: Invalid token in: err while trying to read data from xml

    yair_k
      Hey ,
      While trying to read data from xml i got err:
      LPX-00601: Invalid token in: 'path'

      the proc. i'm using to read data from the xml is:

      procedure read_xml_file_test (in_filename in varchar2)
      is
      my_dir  varchar2(20) := 'XML_DIR;
        cur_emp2 number:=0;
        l_bfile   BFILE;
        l_clob    CLOB;
        l_parser  dbms_xmlparser.Parser;
        l_doc     dbms_xmldom.DOMDocument;
        l_nl      dbms_xmldom.DOMNodeList; 
        l_nl2    dbms_xmldom.DOMNodeList; 
        l_n       dbms_xmldom.DOMNode;  
        l_n2     dbms_xmldom.DOMNode;
        l_temp    VARCHAR2(1000); 
      v_errors        internet_clients.errors%type;  
      src_csid       NUMBER := NLS_CHARSET_ID('UTF8');  
      dest_offset    INTEGER := 1;
      src_offset     INTEGER := 1;
      lang_context   INTEGER := dbms_lob.default_lang_ctx;
      warning        INTEGER;
      v_count       number := 0;   --total records
      v_count_s      number := 0;   -- sucsess record 
      v_count_f      number := 0;   -- failed record
      v_flag varchar2(1); 
      v_char2 varchar2(1);
      v_l1 VARCHAR2(255);
      v_l2 VARCHAR2(255);
      v_l3 VARCHAR2(255);
      v_l4 VARCHAR2(255);
      v_l6 VARCHAR2(255);
      
      BEGIN
        l_bfile := BFileName(my_dir, in_filename);
      
        dbms_lob.createtemporary(l_clob, cache=>FALSE);
        dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
        dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile), dest_offset,src_offset, src_csid, lang_context, warning);                         
        dbms_lob.close(l_bfile);
        -- make sure implicit date conversions are performed correctly
        dbms_session.set_nls('NLS_DATE_FORMAT','''DD/MM/RR HH24:MI:SS''');    
        -- Create a parser.
        l_parser := dbms_xmlparser.newParser;
        -- Parse the document and create a new DOM document.
          dbms_xmlparser.parseClob(l_parser, l_clob);
          l_doc := dbms_xmlparser.getDocument(l_parser); 
        -- Free resources associated with the CLOB and Parser now they are no longer needed.
        dbms_lob.freetemporary(l_clob);
        dbms_xmlparser.freeParser(l_parser);   
        -- Get a list of all the  nodes in the document using the XPATH syntax.
        l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP');
         
        -- Loop through the list and create a new record in a tble collection
        -- for each  record.
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
         l_n := dbms_xmldom.item(l_nl, cur_emp); 
      
         cur_emp2:=0;
        
         loop
           v_count := v_count + 1;
           begin
      
          -- Use XPATH syntax to assign values to he elements of the collection.
          dbms_xslprocessor.valueOf(l_n,'L1/text()',v_l1);
          dbms_xslprocessor.valueOf(l_n,'L2/text()',v_l2);
          dbms_xslprocessor.valueOf(l_n,'L3/text()',v_l3);
          dbms_xslprocessor.valueOf(l_n,'L4/text()',v_l4);
          dbms_xslprocessor.valueOf(l_n,'L6/text()',v_l6);
      
              exception
        when others then  
        null;
        end;
           
       exit when cur_emp2=dbms_xmldom.getLength(l_nl2);
        END LOOP;
        end loop;
        -- Free any resources associated with the document now it
        -- is no longer needed.
        dbms_xmldom.freeDocument(l_doc); 
        
        --remove file to another directory    
            --COMMIT;  -- do not use the commit if you want to run this proc. from within the search_dir_list proc , because it execute a select from tmp table dir_list which contain a "on commit delete rows"  clause.     
        /*EXCEPTION
        /*WHEN OTHERS THEN
         dbms_lob.freetemporary(l_clob);
          dbms_xmlparser.freeParser(l_parser);
         dbms_xmldom.freeDocument(l_doc); 
          null;
          ROLLBACK; */
      END;
      While trying to execute this i got:

      ORA-31011: XML parsing failed
      ORA-19202: Error occurred in XML processing
      LPX-00601: Invalid token in: 'soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP'
      ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 939
      ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 967
      ORA-06512: at "MARKET.READ_XML_FILE_TEST", line 51
      ORA-06512: at line 1

      i guess i mised somthing at the line

      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP');
      i attached here part of my xml:

      <?xml version="1.0" encoding="UTF-8" ?> 
      - <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      - <soap:Body>
      - <GetFieldsNameResponse xmlns="http://tempuri.org/">
      - <GetFieldsNameResult>
      - <xs:schema id="DataSet_FRM_GANERIC_PROP" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
      - <xs:element name="DataSet_FRM_GANERIC_PROP" msdata:IsDataSet="true" msdata:Locale="he-IL">
      - <xs:complexType>
      - <xs:choice minOccurs="0" maxOccurs="unbounded">
      - <xs:element name="FRM_GANERIC_PROP">
      - <xs:complexType>
      - <xs:sequence> 
      
        </xs:sequence>
        </xs:complexType>
        </xs:element>
        </xs:choice>
        </xs:complexType>
        </xs:element>
        </xs:schema>
      - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
      - <DataSet_FRM_GANERIC_PROP xmlns="">
      - <FRM_GANERIC_PROP diffgr:id="FRM_GANERIC_PROP1" msdata:rowOrder="0">
        <L1>val1</L1> 
        <L2>val2</L2> 
        <L3>val3</L3> 
        <L4>val4</L4> 
        <L6>val6</L6> 
        </FRM_GANERIC_PROP>
        </DataSet_FRM_GANERIC_PROP>
        </diffgr:diffgram>
        </GetFieldsNameResult>
        </GetFieldsNameResponse>
        </soap:Body>
        </soap:Envelope>
      I Guess it somthing that have to do with node definition ,
      but i have tried so many combinations and none ot those worked for me.
      i'm deeply stuck here.

      What do i miss here?

      THANKS yair

      Edited by: yair_k on 02:30 14/10/2010
        • 1. Re: LPX-00601: Invalid token in: err while trying to read data from xml
          Jason_(A_Non)
          You missed the evil of XML .... namespaces. ;-)

          I have a working example at
          http://anononxml.blogspot.com/2010/06/xml-parsing-with-namespaces-via-plsql.html
          in Method 1. Also, dbms_xmldom.newdomdocument accepts a CLOB so you don't need to use dbms_xmlparser to get from a clob to a DOMDocument.

          Also look at methods 3 - 5 for alternatives for parsing XML. I like this approach as it is usually easier to parse and extract info in terms of coding.
          • 2. Re: LPX-00601: Invalid token in: err while trying to read data from xml
            yair_k
            HEY THANKS,
            I,ve checked the exmple on your link and run as followes:
            procedure xml_yair_test is
            l_doc       VARCHAR2(30000);
            l_domdoc    dbms_xmldom.DOMDocument;
            l_nodelist  dbms_xmldom.DOMNodeList;
            l_node      dbms_xmldom.DOMNode;
            l_value     VARCHAR2(255);
            l_a_ns      VARCHAR2(255);
            l_both_ns   VARCHAR2(255);
            
            l_xmltype   XMLTYPE;
            l_empx      XMLTYPE;
            l_index     PLS_INTEGER := 0;
            l_col_ind   PLS_INTEGER;
            BEGIN
            l_doc := '  <?xml version="1.0" encoding="UTF-8" ?>
             <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
             <soap:Body>
             <GetFieldsNameResponse xmlns="http://tempuri.org/">
             <GetFieldsNameResult>
             <xs:schema id="DataSet_FRM_GANERIC_PROP" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
             <xs:element name="DataSet_FRM_GANERIC_PROP" msdata:IsDataSet="true" msdata:Locale="he-IL">
             <xs:complexType>
             <xs:choice minOccurs="0" maxOccurs="unbounded">
             <xs:element name="FRM_GANERIC_PROP">
             <xs:complexType>
             <xs:sequence>
              <xs:element name="L1" type="xs:string" minOccurs="0" />
              <xs:element name="L2" type="xs:string" minOccurs="0" />
              <xs:element name="L3" type="xs:string" minOccurs="0" />
              <xs:element name="L4" type="xs:string" minOccurs="0" />
              <xs:element name="L5" type="xs:string" minOccurs="0" />
              <xs:element name="L6" type="xs:string" minOccurs="0" />
              <xs:element name="L7" type="xs:string" minOccurs="0" />
              <xs:element name="L8" type="xs:string" minOccurs="0" />
              <xs:element name="L9" type="xs:string" minOccurs="0" />
              <xs:element name="L10" type="xs:string" minOccurs="0" />
              <xs:element name="L11" type="xs:string" minOccurs="0" />
              <xs:element name="L12" type="xs:string" minOccurs="0" />
              <xs:element name="L13" type="xs:string" minOccurs="0" />
              <xs:element name="L14" type="xs:string" minOccurs="0" />
              <xs:element name="L15" type="xs:string" minOccurs="0" />
              <xs:element name="L16" type="xs:string" minOccurs="0" />
              <xs:element name="L17" type="xs:string" minOccurs="0" />
              <xs:element name="L18" type="xs:string" minOccurs="0" />
              <xs:element name="L19" type="xs:string" minOccurs="0" />
              <xs:element name="L20" type="xs:string" minOccurs="0" />
              </xs:sequence>
              </xs:complexType>
              </xs:element>
              </xs:choice>
              </xs:complexType>
              </xs:element>
              </xs:schema>
             <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
             <DataSet_FRM_GANERIC_PROP xmlns="">
             <FRM_GANERIC_PROP diffgr:id="FRM_GANERIC_PROP1" msdata:rowOrder="0">
              <L1>fname</L1>
              <L2>lname</L2>
              <L3>phone</L3>
              <L4>mail</L4>
              <L6>country</L6>
              </FRM_GANERIC_PROP>
              </DataSet_FRM_GANERIC_PROP>
              </diffgr:diffgram>
              </GetFieldsNameResult>
              </GetFieldsNameResponse>
              </soap:Body>
              </soap:Envelope>';
            
            l_domdoc   := dbms_xmldom.newDomDocument(l_doc);
            l_a_ns := 'xmlns:soap="http://www.w3.org/2003/05/soap-envelope"';
            l_both_ns := l_a_ns || ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'; -- separated by a space
            
            -- Method 1
            dbms_output.put_line('Method 1');
            -- third parm for namespace info
            l_nodelist := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_domdoc),'/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP/L1');
            FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nodelist) - 1 LOOP
             l_node := dbms_xmldom.item(l_nodelist, cur_emp);
             l_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
             dbms_output.put_line('L1: '||l_value);
            END LOOP;
            
            -- Method 2
            dbms_output.new_line;
            dbms_output.put_line('Method 2');
            l_nodelist  := dbms_xmldom.getelementsbytagname(l_domdoc, 'L1');  -- This doesn't care about namespaces
            -- get first item from list, could loop as shown above
            l_node      := dbms_xmldom.item(l_nodelist, 0);
            l_value    := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
            dbms_output.put_line('L1: '||l_value);
            
            -- Done with DOMDocument examples, setup for XMLType based examples
            dbms_xmldom.freeDocument(l_domdoc);
            l_xmltype := XMLTYPE(l_doc);
            
            -- Method 3
            dbms_output.new_line;
            dbms_output.put_line('Method 3');
            l_index := 1;
            WHILE l_xmltype.Existsnode('/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP[' || To_Char(l_index) || ']', l_a_ns) > 0
            LOOP
             l_value := l_xmltype.extract('/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP[' || To_Char(l_index) || ']/a:name/text()', l_a_ns).getStringVal();
             dbms_output.put_line('L1: '||l_value);
             l_index := l_index + 1;
            END LOOP;
            
            -- Method 4
            dbms_output.new_line;
            dbms_output.put_line('Method 4');
            l_value := l_xmltype.extract('/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP[1]/L1/text()', l_a_ns).getStringVal();
            dbms_output.put_line('L1: '||l_value);
            
            -- Method 5
            dbms_output.new_line;
            dbms_output.put_line('Method 5');
            l_index := 1;
            WHILE l_xmltype.Existsnode('/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP[' || To_Char(l_index) || ']', l_a_ns) > 0
            LOOP
             l_empx := l_xmltype.extract('/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP[' || To_Char(l_index) || ']', l_a_ns);
             l_col_ind := 1;
             WHILE l_empx.Existsnode('/a:emp/b:favorites/b:color[' || To_Char(l_col_ind) || ']', l_both_ns) > 0
             LOOP
                l_value := l_empx.extract('/a:emp/b:favorites/b:color[' || To_Char(l_col_ind) || ']/text()', l_both_ns).getStringVal();
                dbms_output.put_line('Color: '||l_value);
                l_col_ind := l_col_ind + 1;
             END LOOP;
             l_index := l_index + 1;
            END LOOP;
            END;
            but got err.:

            ORA-31011: XML parsing failed
            ORA-19202: Error occurred in XML processing
            LPX-00209: PI names starting with XML are reserved
            Error at line 1
            ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 613
            ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 641
            ORA-06512: at "MARKET.XML_YAIR_TEST", line 77
            ORA-06512: at line 1

            i've checks google for LPX-00209: PI names starting with XML are reserved but got nothing..
            how can i solve it?

            thanks
            yair
            • 3. Re: LPX-00601: Invalid token in: err while trying to read data from xml
              odie_63
              Hi,

              There are extra whitespaces just before the XML prolog, remove them and it should be OK.
              • 4. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                yair_k
                Thanks,
                I've tried this and now get

                ORA-31011: XML parsing failed
                ORA-19202: Error occurred in XML processing
                LPX-00234: namespace prefix "diffgr" is not declared
                Error at line 42
                ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 613
                ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 641
                ORA-06512: at "MARKET.XML_YAIR_TEST", line 77
                ORA-06512: at line 1

                regarding line
                l_nodelist := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_domdoc),'/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP/L1');
                What does it mean?
                google search didnt helped at this case also..
                • 5. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                  Jason_(A_Non)
                  You left off the third parm from my original example for that line. It was basically
                  l_nodelist := dbms_xslprocessor.selectNodes(<node>,<xpath>, <namespace>);

                  Also you setup l_a_ns correctly but you have l_both_ns setup wrong. As I said somewhere on my blog, you only need to include namespace definitions for those prefixes which are used in the XPath. This means you should never need to include xsi: nor xsd: since you will not be accessing nodes based on those namespace in your XPath.

                  What l_both_ns should look like is
                  l_both_ns := l_a_ns || ' xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"';

                  Then you will need to change your script to use l_both_ns as the third parm instead of l_a_ns as needed.
                  • 6. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                    yair_k
                    Thanks !
                    i've tried your corrections and now i got it all run ok, but i got results only from method 2.

                    at method 1 i cant get through the loop (since dbms_xmldom.getLength(l_nodelist) = 0)
                    and if i run wiyhout the loop , just for the 1st rec :

                    l_node := dbms_xmldom.item(l_nodelist, 1);
                    l_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));

                    i got no results.

                    (i attach my current code at the bottom of the post);

                    Anothr and most important question:
                    At runtime i intend to read the xml data directly from an xml file located on a local directory, rather then put it structure hardcoded in my code as made on the example.

                    I know how to do it using the dbms_xmlparser method (whice didnt suite my spesific xml structure's reading needs).
                    unfortunely i did'nt find a way to combine the two methodes in order to read directly from the file.
                    Is there any way to do it with the above XMLTYPE methods or ithe data can be read only as hardcoded code?

                    thanks,
                    yair

                    my code (for the 1st method) is now looks like:
                    procedure xml_yair_test is
                    l_doc       VARCHAR2(30000);
                    l_domdoc    dbms_xmldom.DOMDocument;
                    l_nodelist  dbms_xmldom.DOMNodeList;
                    l_node      dbms_xmldom.DOMNode;
                    l_value     VARCHAR2(255);
                    l_a_ns      VARCHAR2(255);
                    l_both_ns   VARCHAR2(255);
                    
                    l_xmltype   XMLTYPE;
                    l_empx      XMLTYPE;
                    l_index     PLS_INTEGER := 0;
                    l_col_ind   PLS_INTEGER;
                    BEGIN
                    l_doc := '<?xml version="1.0" encoding="UTF-8" ?>
                     <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                     <soap:Body>
                     <GetFieldsNameResponse xmlns="http://tempuri.org/">
                     <GetFieldsNameResult>
                     <xs:schema id="DataSet_FRM_GANERIC_PROP" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
                     <xs:element name="DataSet_FRM_GANERIC_PROP" msdata:IsDataSet="true" msdata:Locale="he-IL">
                     <xs:complexType>
                     <xs:choice minOccurs="0" maxOccurs="unbounded">
                     <xs:element name="FRM_GANERIC_PROP">
                     <xs:complexType>
                     <xs:sequence>
                      <xs:element name="L1" type="xs:string" minOccurs="0" />
                      <xs:element name="L2" type="xs:string" minOccurs="0" />
                      <xs:element name="L3" type="xs:string" minOccurs="0" />
                      <xs:element name="L4" type="xs:string" minOccurs="0" />
                      <xs:element name="L5" type="xs:string" minOccurs="0" />
                      <xs:element name="L6" type="xs:string" minOccurs="0" />
                      <xs:element name="L7" type="xs:string" minOccurs="0" />
                      <xs:element name="L8" type="xs:string" minOccurs="0" />
                      <xs:element name="L9" type="xs:string" minOccurs="0" />
                      <xs:element name="L10" type="xs:string" minOccurs="0" />
                      <xs:element name="L11" type="xs:string" minOccurs="0" />
                      <xs:element name="L12" type="xs:string" minOccurs="0" />
                      <xs:element name="L13" type="xs:string" minOccurs="0" />
                      <xs:element name="L14" type="xs:string" minOccurs="0" />
                      <xs:element name="L15" type="xs:string" minOccurs="0" />
                      <xs:element name="L16" type="xs:string" minOccurs="0" />
                      <xs:element name="L17" type="xs:string" minOccurs="0" />
                      <xs:element name="L18" type="xs:string" minOccurs="0" />
                      <xs:element name="L19" type="xs:string" minOccurs="0" />
                      <xs:element name="L20" type="xs:string" minOccurs="0" />
                      </xs:sequence>
                      </xs:complexType>
                      </xs:element>
                      </xs:choice>
                      </xs:complexType>
                      </xs:element>
                      </xs:schema>
                     <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
                     <DataSet_FRM_GANERIC_PROP xmlns="">
                     <FRM_GANERIC_PROP diffgr:id="FRM_GANERIC_PROP1" msdata:rowOrder="0">
                     <L1>fname</L1>
                      <L2>lname</L2>
                      <L3>phone</L3>
                      <L4>mail</L4>
                      <L6>country</L6>
                      </FRM_GANERIC_PROP>
                      </DataSet_FRM_GANERIC_PROP>
                      </diffgr:diffgram>
                      </GetFieldsNameResult>
                      </GetFieldsNameResponse>
                      </soap:Body>
                      </soap:Envelope>';
                    
                    l_domdoc   := dbms_xmldom.newDomDocument(l_doc);
                    l_a_ns := 'xmlns:soap="http://www.w3.org/2003/05/soap-envelope"';
                    l_both_ns := l_a_ns || ' xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"'; -- separated by a space
                    
                    -- Method 1
                    dbms_output.put_line('Method 1');
                    -- third parm for namespace info
                    l_nodelist := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_domdoc),'/soap:Envelope/soap:Body/GetFieldsNameResponse/GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP/L1',l_both_ns);
                    FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nodelist) - 1 LOOP
                     l_node := dbms_xmldom.item(l_nodelist, cur_emp);
                     l_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
                     dbms_output.put_line('L1: '||l_value);
                    END LOOP;
                    • 7. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                      Jason_(A_Non)
                      I missed it on previous quick looks at your XML, but the reason you were not getting any responses is because of the default namespace that was set on
                      <GetFieldsNameResponse xmlns="http://tempuri.org/">
                      My preference for dealing with default namespaces (when using these methods) is to provide a namespace prefix for that namespace and use that prefix in the XPath accordingly. The important piece to remember is that the prefix itself does not have to match up between XPath and XML, only the namespace that both reference. If the namespaces match, the prefixes are considered equal.

                      So I added in this default namespace and made up a prefix of fa for it. I used it on those two nodes that reside in that namespace.

                      Normally you can get away without having to use a prefix for a default namespace, however your XPath crosses two different "default" namespaces so you need to supply a prefix for the other. If you look on
                      <DataSet_FRM_GANERIC_PROP xmlns="">
                      This resets the default namespace back to nothing. Had this not been there, then we would not have needed to use the fa prefix, though we would have needed to include xmlns="http://tempuri.org/" in our namespace variable below.

                      Confusing I know, but that's the joy of having many namespaces in a single XML document.

                      So, this will work with the XML sample you provided.
                         l_all_ns := l_a_ns || ' xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:fa="http://tempuri.org/"'; -- separated by a space
                         ...snipped...
                         l_nodelist := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_domdoc),'/soap:Envelope/soap:Body/fa:GetFieldsNameResponse/fa:GetFieldsNameResult/diffgr:diffgram/DataSet_FRM_GANERIC_PROP/FRM_GANERIC_PROP/L1',l_all_ns);
                      As for reading XML from disk, you are looking for BFILENAME. You can use this within an XMLType, as shown in {thread:id=613170} to do something like
                      l_xmlvariable := XMLTYPE(BFILENAME(...),...);
                      to read the XML directly from disk.
                      • 8. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                        yair_k
                        Hey , it's now workes ok with method 1 ,
                        and also with the XMLTYPE(BFILENAME) method for read directly from a file.

                        Thanks a lot !!!

                        yair
                        • 9. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                          yair_k
                          Hey , after got a lot of success with the xml reading part , i wonder if you
                          can help me with a problem while trying to reading that xml from a web service.

                          i use a procedure as followes:
                          FUNCTION read_from_web_service(in_username in varchar2 , in_password in varchar2)
                            RETURN CHAR
                          AS
                            l_service          UTL_DBWS.service;
                            l_call             UTL_DBWS.call;
                            l_a_ns                     VARCHAR2(32767);
                            l_wsdl_url         VARCHAR2(32767);
                            l_namespace        VARCHAR2(32767);
                            l_service_qname    UTL_DBWS.qname;
                            l_port_qname       UTL_DBWS.qname;
                            l_operation_qname  UTL_DBWS.qname;
                          
                            l_xmltype_in       SYS.XMLTYPE;
                            l_xmltype_out      SYS.XMLTYPE;
                            l_return           VARCHAR2(32767);
                          BEGIN 
                          
                          
                            
                            l_wsdl_url        := 'http://www.company.com/publisherService/ServiceGetpublisherTable.asmx?wsdl';
                            l_namespace       := 'http://tempuri.org/';
                          
                          
                            l_service_qname   := UTL_DBWS.to_qname(l_namespace, 'ServiceGetpublisherTable');
                            l_port_qname      := UTL_DBWS.to_qname(l_namespace, 'ServiceGetpublisherTableSoap');
                            l_operation_qname := UTL_DBWS.to_qname(l_namespace, 'GetFieldsName');
                          
                            
                            l_service := UTL_DBWS.create_service (
                              wsdl_document_location => URIFACTORY.getURI(l_wsdl_url),
                              service_name           => l_service_qname);
                          
                            l_call := UTL_DBWS.create_call (
                              service_handle => l_service,
                              port_name      => l_port_qname,
                              operation_name => l_operation_qname);
                              
                          
                            l_xmltype_in := SYS.XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
                              <GetFieldsName xmlns="' || l_namespace || '">
                              <user>' || in_username || '</user>
                              <password>'|| in_password || '</password>
                              </GetFieldsName>');
                              
                            l_xmltype_out := UTL_DBWS.invoke(call_Handle => l_call,
                                                             request     => l_xmltype_in);
                            
                            UTL_DBWS.release_call (call_handle => l_call);
                            UTL_DBWS.release_service (service_handle => l_service);
                          
                            l_return := l_xmltype_out.extract('//GetFieldsName/text()').getstringVal(); 
                             dbms_output.put_line(l_return);      
                            RETURN l_return;
                          END;
                          but when i run it i got message:

                          ORA-29532: Java call terminated by uncaught Java exception: javax.xml.rpc.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .

                          regarding the line:

                          l_xmltype_out := UTL_DBWS.invoke(call_Handle => l_call,
                          request => l_xmltype_in);

                          So , i deeply stuck here!

                          my web service description is:
                            <?xml version="1.0" encoding="utf-8" ?> 
                          - <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
                          - <wsdl:types>
                          - <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
                          - <s:element name="GetFieldsName">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element minOccurs="0" maxOccurs="1" name="user" type="s:string" /> 
                            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                          - <s:element name="GetFieldsNameResponse">
                          - <s:complexType>
                          - <s:sequence>
                          - <s:element minOccurs="0" maxOccurs="1" name="GetFieldsNameResult">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element ref="s:schema" /> 
                            <s:any /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                          - <s:element name="GetMSG_ByUser_Not_Readed">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element minOccurs="0" maxOccurs="1" name="user" type="s:string" /> 
                            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                          - <s:element name="GetMSG_ByUser_Not_ReadedResponse">
                          - <s:complexType>
                          - <s:sequence>
                          - <s:element minOccurs="0" maxOccurs="1" name="GetMSG_ByUser_Not_ReadedResult">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element ref="s:schema" /> 
                            <s:any /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                          - <s:element name="SetMSG_ByUser_Not_Readed_As_Readed">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element minOccurs="0" maxOccurs="1" name="user" type="s:string" /> 
                            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" /> 
                            <s:element minOccurs="0" maxOccurs="1" name="Rec_Id" type="s:string" /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                          - <s:element name="SetMSG_ByUser_Not_Readed_As_ReadedResponse">
                          - <s:complexType>
                          - <s:sequence>
                            <s:element minOccurs="1" maxOccurs="1" name="SetMSG_ByUser_Not_Readed_As_ReadedResult" type="s:boolean" /> 
                            </s:sequence>
                            </s:complexType>
                            </s:element>
                            </s:schema>
                            </wsdl:types>
                          - <wsdl:message name="GetFieldsNameSoapIn">
                            <wsdl:part name="parameters" element="tns:GetFieldsName" /> 
                            </wsdl:message>
                          - <wsdl:message name="GetFieldsNameSoapOut">
                            <wsdl:part name="parameters" element="tns:GetFieldsNameResponse" /> 
                            </wsdl:message>
                          - <wsdl:message name="GetMSG_ByUser_Not_ReadedSoapIn">
                            <wsdl:part name="parameters" element="tns:GetMSG_ByUser_Not_Readed" /> 
                            </wsdl:message>
                          - <wsdl:message name="GetMSG_ByUser_Not_ReadedSoapOut">
                            <wsdl:part name="parameters" element="tns:GetMSG_ByUser_Not_ReadedResponse" /> 
                            </wsdl:message>
                          - <wsdl:message name="SetMSG_ByUser_Not_Readed_As_ReadedSoapIn">
                            <wsdl:part name="parameters" element="tns:SetMSG_ByUser_Not_Readed_As_Readed" /> 
                            </wsdl:message>
                          - <wsdl:message name="SetMSG_ByUser_Not_Readed_As_ReadedSoapOut">
                            <wsdl:part name="parameters" element="tns:SetMSG_ByUser_Not_Readed_As_ReadedResponse" /> 
                            </wsdl:message>
                          - <wsdl:portType name="ServiceGetpublisherTableSoap">
                          - <wsdl:operation name="GetFieldsName">
                            <wsdl:input message="tns:GetFieldsNameSoapIn" /> 
                            <wsdl:output message="tns:GetFieldsNameSoapOut" /> 
                            </wsdl:operation>
                          - <wsdl:operation name="GetMSG_ByUser_Not_Readed">
                            <wsdl:input message="tns:GetMSG_ByUser_Not_ReadedSoapIn" /> 
                            <wsdl:output message="tns:GetMSG_ByUser_Not_ReadedSoapOut" /> 
                            </wsdl:operation>
                          - <wsdl:operation name="SetMSG_ByUser_Not_Readed_As_Readed">
                            <wsdl:input message="tns:SetMSG_ByUser_Not_Readed_As_ReadedSoapIn" /> 
                            <wsdl:output message="tns:SetMSG_ByUser_Not_Readed_As_ReadedSoapOut" /> 
                            </wsdl:operation>
                            </wsdl:portType>
                          - <wsdl:binding name="ServiceGetpublisherTableSoap" type="tns:ServiceGetpublisherTableSoap">
                            <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
                          - <wsdl:operation name="GetFieldsName">
                            <soap:operation soapAction="http://tempuri.org/GetFieldsName" style="document" /> 
                          - <wsdl:input>
                            <soap:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                          - <wsdl:operation name="GetMSG_ByUser_Not_Readed">
                            <soap:operation soapAction="http://tempuri.org/GetMSG_ByUser_Not_Readed" style="document" /> 
                          - <wsdl:input>
                            <soap:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                          - <wsdl:operation name="SetMSG_ByUser_Not_Readed_As_Readed">
                            <soap:operation soapAction="http://tempuri.org/SetMSG_ByUser_Not_Readed_As_Readed" style="document" /> 
                          - <wsdl:input>
                            <soap:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                            </wsdl:binding>
                          - <wsdl:binding name="ServiceGetpublisherTableSoap12" type="tns:ServiceGetpublisherTableSoap">
                            <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
                          - <wsdl:operation name="GetFieldsName">
                            <soap12:operation soapAction="http://tempuri.org/GetFieldsName" style="document" /> 
                          - <wsdl:input>
                            <soap12:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap12:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                          - <wsdl:operation name="GetMSG_ByUser_Not_Readed">
                            <soap12:operation soapAction="http://tempuri.org/GetMSG_ByUser_Not_Readed" style="document" /> 
                          - <wsdl:input>
                            <soap12:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap12:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                          - <wsdl:operation name="SetMSG_ByUser_Not_Readed_As_Readed">
                            <soap12:operation soapAction="http://tempuri.org/SetMSG_ByUser_Not_Readed_As_Readed" style="document" /> 
                          - <wsdl:input>
                            <soap12:body use="literal" /> 
                            </wsdl:input>
                          - <wsdl:output>
                            <soap12:body use="literal" /> 
                            </wsdl:output>
                            </wsdl:operation>
                            </wsdl:binding>
                          - <wsdl:service name="ServiceGetpublisherTable">
                          - <wsdl:port name="ServiceGetpublisherTableSoap" binding="tns:ServiceGetpublisherTableSoap">
                            <soap:address location="http://www.company.com/publisherService/ServiceGetpublisherTable.asmx" /> 
                            </wsdl:port>
                          - <wsdl:port name="ServiceGetpublisherTableSoap12" binding="tns:ServiceGetpublisherTableSoap12">
                            <soap12:address location="http://www.company.com/publisherService/ServiceGetpublisherTable.asmx" /> 
                            </wsdl:port>
                            </wsdl:service>
                            </wsdl:definitions>
                          also i have to mention that i have changed publisher references inside the code , and i also canot
                          supply username and password , so i guess you canot test it. still i not shure if my definitions (namespace est.) inside my code defined correctly.

                          hope you can help me with this.

                          regards

                          yair
                          • 10. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                            Jason_(A_Non)
                            I've never used UTL_DBWS but if I get the chance I'll look into it. I've used UTL_HTTP for WS calls though.

                            Have you tried googling
                            ORA-29532 Server did not recognize the value of HTTP Header SOAPAction
                            to see if any of those hits provide help?
                            • 11. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                              yair_k
                              utl.http helped me before to call some url services ,but not in this case.
                              because we dealing here with wsdl , as far as i've checked it , utl_dbws is the apropriate approach.

                              regarding the ORA-29532 err message , i did checked up on google and oracle forums , but none of the
                              posts and solution i found didn't help.
                              • 12. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                                Jason_(A_Non)
                                Actually you can use UTL_HTTP to call web services based on WSDLs. You just have to manually build up the outgoing SOAP message instead of letting UTL_DBWS do it for you.

                                I'm assuming you used http://www.oracle-base.com/articles/10g/utl_dbws10g.php as the basis for building your code? They look similar to me and I didn't really see anything wrong with what you have, given how little I understand UTL_DBWS right now.

                                Have you looked at the documentation for UTL_DBWS (10.2) http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_dbws.htm#CHDIDGJH

                                I'm wondering if you need to set the SOAPACTION_USE property to TRUE since the default is FALSE. Seems to go along with the error message but I'm just guessing. You may have better luck with this question in another forum, such as the ones you've seen the other UTL_DBWS errors in. That or you may want to start it up as a new question since this one doesn't really go with the original problem in this thread.
                                • 13. Re: LPX-00601: Invalid token in: err while trying to read data from xml
                                  yair_k
                                  hey,
                                  i finnaly solve it!
                                  a lot of this made with help from the post
                                  http://www.orafaq.com/forum/t/99528/2/

                                  i demonstraite my code below,
                                  thanks a lot for help and inspiration

                                  regards , yair

                                  my code:
                                  CREATE OR REPLACE
                                  FUNCTION read_from_web_service(in_username in varchar2 , in_password in varchar2)
                                    RETURN CHAR
                                  AS
                                    l_service          UTL_DBWS.service;
                                    l_call             UTL_DBWS.call;
                                    l_a_ns                     VARCHAR2(32767);
                                    l_wsdl_url         VARCHAR2(32767);
                                    l_namespace        VARCHAR2(32767);
                                    l_service_qname    UTL_DBWS.qname;
                                    l_port_qname       UTL_DBWS.qname;
                                    l_operation_qname  UTL_DBWS.qname;
                                    string_type_qname1     sys.utl_dbws.qname;
                                    string_type_qname2     sys.utl_dbws.qname;
                                  
                                    l_xmltype_in       SYS.XMLTYPE;
                                    l_xmltype_out      SYS.XMLTYPE;
                                    l_return           clob;
                                  BEGIN 
                                  
                                  
                                    
                                    l_wsdl_url        := 'http://www.company.com/Service/ServiceGetserviceTable.asmx?wsdl';
                                    l_namespace       := 'http://tempuri.org/';
                                    l_service_qname   := UTL_DBWS.to_qname(l_namespace, 'ServiceGetserviceTable');
                                    l_port_qname      := UTL_DBWS.to_qname(l_namespace, 'ServiceGetserviceTableSoap');
                                    l_operation_qname := UTL_DBWS.to_qname(l_namespace, 'GetFieldsName');
                                    l_service := UTL_DBWS.create_service (
                                      wsdl_document_location => URIFACTORY.getURI(l_wsdl_url),
                                      service_name           => l_service_qname);
                                  
                                    l_call := UTL_DBWS.create_call (
                                      service_handle => l_service,
                                      port_name      => l_port_qname,
                                      operation_name => l_operation_qname);
                                      
                                    sys.utl_dbws.set_property(l_call, 'SOAPACTION_USE', 'TRUE');
                                    sys.utl_dbws.set_property(l_call, 'SOAPACTION_URI', 'http://tempuri.org/GetFieldsName'); 
                                    sys.utl_dbws.set_property(l_call, 'ENCODINGSTYLE_URI', 'http://schemas.xmlsoap.org/soap/encoding/');
                                    sys.utl_dbws.set_property(l_call, 'ENCODINGSTYLE_URI', 'http://schemas.xmlsoap.org/soap/encoding/');
                                    sys.utl_dbws.set_property(l_call, 'OPERATION_STYLE', 'document');
                                    string_type_qname1 := sys.utl_dbws.to_qname('http://www.w3.org/2001/XMLSchema', 'string');
                                    string_type_qname2 := sys.utl_dbws.to_qname('http://www.w3.org/2001/XMLSchema', 'string');
                                    sys.utl_dbws.add_parameter(l_call, 'user', string_type_qname1, 'ParameterMode.IN');
                                    sys.utl_dbws.add_parameter(l_call, 'password', string_type_qname2, 'ParameterMode.IN');
                                    sys.utl_dbws.set_return_type(l_call, string_type_qname1);
                                    sys.utl_dbws.set_return_type(l_call, string_type_qname2);
                                  
                                      
                                  
                                    l_xmltype_in := SYS.XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
                                      <GetFieldsName xmlns="' || l_namespace || '">
                                      <user>' || in_username || '</user>
                                      <password>'|| in_password || '</password>
                                      </GetFieldsName>');
                                      
                                    l_xmltype_out := UTL_DBWS.invoke(call_Handle => l_call,
                                                                     request     => l_xmltype_in);
                                    if  l_xmltype_out.extract('/*') is not null then
                                    l_return := l_xmltype_out.extract('/*').getstringval();
                                  
                                    else
                                    l_return := null;
                                    end if;
                                    -- dbms_output.put_line(l_return); 
                                     
                                      UTL_DBWS.release_call (call_handle => l_call);
                                    UTL_DBWS.release_service (service_handle => l_service);     
                                    RETURN (l_return);
                                  
                                  END;
                                  /