Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dbms_xslprocessor.selectSingleNode can't select a node

ys123May 5 2015 — edited May 6 2015

DECLARE

  l_xml  xmltype;

  l_ele  dbms_xmldom.DOMElement;

  l_dom  dbms_xmldom.DOMDocument;

  l_root dbms_xmldom.DOMNode;

  l_node dbms_xmldom.DOMNode;

  --

  PROCEDURE msg(p_msg IN VARCHAR2) IS

  BEGIN

    dbms_output.put_line(p_msg);

  END;

BEGIN

  l_xml  := xmltype.createxml(xmlData => bfilename('TMPDIR', 'test.xml'),

                              csid    => 0,

                              schema  => null);

  l_dom  := dbms_xmldom.newDOMDocument(l_xml);

  l_root := dbms_xmldom.makeNode(l_dom);

  l_node := dbms_xslprocessor.selectSingleNode(l_root,

                                               '/root/name[@val="test2"]/leaf');

  IF dbms_xmldom.isNull(l_node) THEN

    msg('NULL');

  END IF;

END;

test.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<c:root xmlns:c="http://www.example.com/test">

  <c:name val="test">

  <c:leaf val="leaf"/>

  </c:name>

  <c:name val="test2">

  <c:leaf val="leaf"/>

  </c:name>

</c:root>

test2.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<root>

  <name val="test">

  <leaf val="leaf"/>

  </name>

  <name val="test2">

  <leaf val="leaf2"/>

  </name>

</root>

when the file is test2.xml selectSingleNode will succeed to select a node , but when the file is test.xml , no node was selected , why ? many thanks !!!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2015
Added on May 5 2015
1 comment
390 views