4 Replies Latest reply: Nov 20, 2012 12:40 PM by frank1018 RSS

    Oracle dbms_xmldom.ISNULL what's the difference in 10G and 11G?

    frank1018
      For the code below, in Oracle 10g, it says the node is empty, in 11g, it's not empty. There is a newline character in side the tag .

      If there is a space inside, the result is the same for both version.

      Once nothing inside, both two version will not have the output.

      Why does this happen ?

      DECLARE
      v_doc dbms_xmldom.DOMDocument;
      v_elem dbms_xmldom.DOMElement;
      v_nelem dbms_xmldom.DOMNode;
      BEGIN
      -- create the DOMDocument
      v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA>
      </XMLDATA>'));
      v_nelem := DBMS_XMLDOM.MAKENODE(v_doc);
      v_nelem := DBMS_XSLPROCESSOR.SELECTSINGLENODE(v_nelem,'XMLDATA/text()');
      IF NOT(dbms_xmldom.ISNULL(v_nelem)) THEN
      DBMS_OUTPUT.PUT_LINE('The node is not empty');
      END IF;
      END;
      /

      Edited by: 972302 on Nov 20, 2012 10:35 AM
        • 1. Re: Oracle dbms_xmldom.ISNULL what's the difference in 10G and 11G?
          Solomon Yakobson
          Post exact version numbers. I can't reproduce it:
          SQL> select  *
            2    from  v$version
            3  /
          
          BANNER
          ----------------------------------------------------------------
          Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
          PL/SQL Release 10.2.0.5.0 - Production
          CORE    10.2.0.5.0      Production
          TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
          NLSRTL Version 10.2.0.5.0 - Production
          
          SQL> DECLARE
            2  v_doc dbms_xmldom.DOMDocument;
            3  v_elem dbms_xmldom.DOMElement;
            4  v_nelem dbms_xmldom.DOMNode; 
            5  BEGIN
            6  -- create the DOMDocument
            7  v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA>
            8  </XMLDATA>'));
            9  v_nelem := DBMS_XMLDOM.MAKENODE(v_doc);
           10  v_nelem := DBMS_XSLPROCESSOR.SELECTSINGLENODE(v_nelem,'XMLDATA/text()');
           11  IF NOT(dbms_xmldom.ISNULL(v_nelem)) THEN 
           12  DBMS_OUTPUT.PUT_LINE('The node is not empty');
           13  END IF; 
           14  END;
           15  / 
          The node is not empty
          
          PL/SQL procedure successfully completed.
          
          SQL>  
          SQL> select  *
            2    from  v$version
            3  /
          
          BANNER
          --------------------------------------------------------------------------------
          Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
          PL/SQL Release 11.2.0.3.0 - Production
          CORE    11.2.0.3.0      Production
          TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
          NLSRTL Version 11.2.0.3.0 - Production
          
          SQL> DECLARE
            2  v_doc dbms_xmldom.DOMDocument;
            3  v_elem dbms_xmldom.DOMElement;
            4  v_nelem dbms_xmldom.DOMNode; 
            5  BEGIN
            6  -- create the DOMDocument
            7  v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA>
            8  </XMLDATA>'));
            9  v_nelem := DBMS_XMLDOM.MAKENODE(v_doc);
           10  v_nelem := DBMS_XSLPROCESSOR.SELECTSINGLENODE(v_nelem,'XMLDATA/text()');
           11  IF NOT(dbms_xmldom.ISNULL(v_nelem)) THEN 
           12  DBMS_OUTPUT.PUT_LINE('The node is not empty');
           13  END IF; 
           14  END;
           15  / 
          The node is not empty
          
          PL/SQL procedure successfully completed.
          
          SQL> 
          SY.
          • 2. Re: Oracle dbms_xmldom.ISNULL what's the difference in 10G and 11G?
            Solomon Yakobson
            Most likely in one case you have:
            v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA>
            </XMLDATA>'));
            and in other case:
            v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA></XMLDATA>'));
            See the difference:
            SQL> DECLARE
              2  v_doc dbms_xmldom.DOMDocument;
              3  v_elem dbms_xmldom.DOMElement;
              4  v_nelem dbms_xmldom.DOMNode; 
              5  BEGIN
              6  -- create the DOMDocument
              7  v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA>
              8  </XMLDATA>'));
              9  v_nelem := DBMS_XMLDOM.MAKENODE(v_doc);
             10  v_nelem := DBMS_XSLPROCESSOR.SELECTSINGLENODE(v_nelem,'XMLDATA/text()');
             11  IF NOT(dbms_xmldom.ISNULL(v_nelem)) THEN 
             12  DBMS_OUTPUT.PUT_LINE('The node is not NULL');
             13  ELSE
             14  DBMS_OUTPUT.PUT_LINE('The node is NULL');
             15  END IF; 
             16  END;
             17  /
            The node is not NULL
            
            PL/SQL procedure successfully completed.
            
            SQL> DECLARE
              2  v_doc dbms_xmldom.DOMDocument;
              3  v_elem dbms_xmldom.DOMElement;
              4  v_nelem dbms_xmldom.DOMNode; 
              5  BEGIN
              6  -- create the DOMDocument
              7  v_doc := dbms_xmldom.newDOMDocument(xmlType('<XMLDATA></XMLDATA>'));
              8  v_nelem := DBMS_XMLDOM.MAKENODE(v_doc);
              9  v_nelem := DBMS_XSLPROCESSOR.SELECTSINGLENODE(v_nelem,'XMLDATA/text()');
             10  IF NOT(dbms_xmldom.ISNULL(v_nelem)) THEN 
             11  DBMS_OUTPUT.PUT_LINE('The node is not NULL');
             12  ELSE
             13  DBMS_OUTPUT.PUT_LINE('The node is NULL');
             14  END IF; 
             15  END;
             16  /
            The node is NULL
            
            PL/SQL procedure successfully completed.
            
            SQL> 
            SY.
            • 3. Re: Oracle dbms_xmldom.ISNULL what's the difference in 10G and 11G?
              frank1018
              Oracle Database 10g Release 10.2.0.4.0 - Production
              PL/SQL Release 10.2.0.4.0 - Production

              and


              Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
              PL/SQL Release 11.2.0.3.0 - Production
              • 4. Re: Oracle dbms_xmldom.ISNULL what's the difference in 10G and 11G?
                frank1018
                You should try the same code(first version, with a new line character inside the tag.) in 10g and 11g. The result will be different