<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic XPATH with CL_XSLT_PROCESSOR-&amp;gt;set_expression( ... ) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xpath-with-cl-xslt-processor-gt-set-expression/m-p/7549370#M1563232</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem by using the method cl_xslt_processor-&amp;gt;set_expression( expression = ... nsdeclarations = ... ). I want to use this method to get some nodes by using Xpath.&lt;/P&gt;&lt;P&gt;My problem is the parameter 'nsdeclarations' which should be filled like 'prefix1 URI1 prefix2 URI2 ...'. But my xml document has no prefix. It looks like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ROOT xmlns="http://uri"&amp;gt;....&amp;lt;/ROOT&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After getting a node collection I create a iterator und try to get the first element ( lr_element ?= lr_iterator-&amp;gt;get_next( ). )&lt;/P&gt;&lt;P&gt;But lr_element is always initial. I tried to call the method without the parameter 'nsdeclarations' (is optional) but it didn't work, as well as passing only the uri.&lt;/P&gt;&lt;P&gt;If I put a prefix into my xml and my namespace parameter it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have an idea what has to be passed in my case (no namespace prefix)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards &lt;/P&gt;&lt;P&gt;Guenter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Jan 2011 09:19:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-01-28T09:19:58Z</dc:date>
    <item>
      <title>XPATH with CL_XSLT_PROCESSOR-&gt;set_expression( ... )</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xpath-with-cl-xslt-processor-gt-set-expression/m-p/7549370#M1563232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem by using the method cl_xslt_processor-&amp;gt;set_expression( expression = ... nsdeclarations = ... ). I want to use this method to get some nodes by using Xpath.&lt;/P&gt;&lt;P&gt;My problem is the parameter 'nsdeclarations' which should be filled like 'prefix1 URI1 prefix2 URI2 ...'. But my xml document has no prefix. It looks like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ROOT xmlns="http://uri"&amp;gt;....&amp;lt;/ROOT&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After getting a node collection I create a iterator und try to get the first element ( lr_element ?= lr_iterator-&amp;gt;get_next( ). )&lt;/P&gt;&lt;P&gt;But lr_element is always initial. I tried to call the method without the parameter 'nsdeclarations' (is optional) but it didn't work, as well as passing only the uri.&lt;/P&gt;&lt;P&gt;If I put a prefix into my xml and my namespace parameter it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have an idea what has to be passed in my case (no namespace prefix)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards &lt;/P&gt;&lt;P&gt;Guenter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 09:19:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xpath-with-cl-xslt-processor-gt-set-expression/m-p/7549370#M1563232</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-28T09:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: XPATH with CL_XSLT_PROCESSOR-&gt;set_expression( ... )</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xpath-with-cl-xslt-processor-gt-set-expression/m-p/7549371#M1563233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to map default namespance to your own prefix and the use it in the XPath.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See example where I declare 'my' prefix&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA l_xslt TYPE REF TO cl_xslt_processor.
DATA: nodes TYPE REF TO if_ixml_node_collection.

CREATE OBJECT l_xslt TYPE cl_xslt_processor.
l_xslt-&amp;gt;set_source_string(
    '&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt;' &amp;amp;
    '&amp;lt;a xmlns="http://uri.com"&amp;gt;' &amp;amp;
    '&amp;lt;foo&amp;gt;bar&amp;lt;/foo&amp;gt;' &amp;amp;
    '&amp;lt;/a&amp;gt;' ).

l_xslt-&amp;gt;set_expression(
  expression = 'my:a/my:foo'
  nsdeclarations = 'my http://uri.com'
).

l_xslt-&amp;gt;run( '' ).

nodes = l_xslt-&amp;gt;get_nodes( ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 10:12:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xpath-with-cl-xslt-processor-gt-set-expression/m-p/7549371#M1563233</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2011-01-28T10:12:45Z</dc:date>
    </item>
  </channel>
</rss>

