XPATH with CL_XSLT_PROCESSOR- set_expression( ... )

Hi all,
I have a problem by using the method cl_xslt_processor->set_expression( expression = ... nsdeclarations = ... ). I want to use this method to get some nodes by using Xpath.
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
<ROOT xmlns="http://uri">....</ROOT>
After getting a node collection I create a iterator und try to get the first element ( lr_element ?= lr_iterator->get_next( ). )
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.
If I put a prefix into my xml and my namespace parameter it works.
Does anybody have an idea what has to be passed in my case (no namespace prefix)?
Thanks in advance.
Best regards
Guenter

Hi,
You have to map default namespance to your own prefix and the use it in the XPath.
See example where I declare 'my' prefix
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->set_source_string(
    '<?xml version="1.0" encoding="ISO-8859-1"?>' &
    '<a xmlns="http://uri.com">' &
    '<foo>bar</foo>' &
    '</a>' ).
l_xslt->set_expression(
  expression = 'my:a/my:foo'
  nsdeclarations = 'my http://uri.com'
l_xslt->run( '' ).
nodes = l_xslt->get_nodes( ).

Similar Messages

  • Is there any possibility to combine XPath with SAX in Java?

    HI Gentlemen,
    I have an XML instance to parse. One solution works with XPath and Document builder. However, the tree in memory is too big so that I can not build it in my storage (8 GB). Does anyone of you know a method where I use an XPath expression (Java) to select a node but with a better parser (e g SAX) which is not so space hungry? Direct access of nodes is obligatory.
    Thanks, kind regards from
    Miklos HERBOLY

    As SAX  parsers do not build a DOM structure and XPath requires a DOM structure to select elements from, XPath is not usable with SAX, but some analysers support setting the XPath expressions to analyse before invoking the SAX parser and provide the result for XPath expressions.
    Refer
    https://code.google.com/p/xpath4sax/

  • Building XPath with the XML having the Namespace using PL SQL

    While trying to build the path of each node, when the XML has no namespace in it , the below code works fine providing the result
    1~/
    2~/person/
    3~/person/age/
    4~/person/homecity/
    5~/person/name/
    6~/person/homecity/lat/
    7~/person/homecity/name/
    8~/person/homecity/long/
    But when the xml is changed to
    <person xmlns="urn:person" xmlns:lat="urn:lat">
    <name>Rob</name>
    <age>37</age>
    <homecity>
        <name>London</name>
        <lat>123.000</lat>
        <long>0.00</long>
    </homecity>
    </person>"
    The result on executing the below code is resulting into only into below result
    1~/
    2~/person/
    In the XML provided above, XML name space is not constant and it may vary for every XML. My requirement is to parse the complete XML, where i can read the XML with namespace and get the result as mentioned below
    1~/
    2~/person/
    3~/person/age/
    4~/person/homecity/
    5~/person/name/
    6~/person/homecity/lat:lat/
    7~/person/homecity/name/
    8~/person/homecity/long/
    Can you please help me resolving the issue mentioned. Thanks in advance. --Code Snippet below :
    DECLARE
      l_File VARCHAR2(32000) := '<person>
    <name>Rob</name>
    <age>37</age>
    <homecity>
        <name>London</name>
        <lat>123.000</lat>
        <long>0.00</long>
    </homecity>
    </person>';
    l_Where_Clause VARCHAR2(100) := '/*';
    l_Append_Var   VARCHAR2(100) := '/';
    TYPE Ty_Paths IS TABLE OF VARCHAR2(1000) INDEX BY PLS_INTEGER;
    l_Ty_Paths      Ty_Paths;
    l_Ty_Paths_Temp Ty_Paths;
    TYPE Ty_Verifier IS TABLE OF VARCHAR2(1000) INDEX BY VARCHAR2(1000);
    l_Ty_Varifier Ty_Verifier;
    l_Prev_Query_Rec VARCHAR2(100);
    l_Index_Num      NUMBER := 0;
    l_Cur_Exec_Row   NUMBER := 0;
    BEGIN
    l_Ty_Paths(Nvl(l_Ty_Paths.COUNT, 0) + 1) := l_Append_Var;
    l_Cur_Exec_Row := 1;
    --Dbms_Output.put_line('Before entering the loop');
    LOOP
       l_Ty_Paths_Temp.DELETE;
      SELECT DISTINCT REPLACE(l_Append_Var || '/' || t.Xml || '/', '//', '/') BULK COLLECT
       INTO   l_Ty_Paths_Temp
      FROM   (SELECT Xmltype(Extract(VALUE(e), '/').Getstringval()) .Getrootelement() AS Xml
               FROM   TABLE(Xmlsequence(Extract(Xmltype(l_File), l_Where_Clause))) e) t;
      l_Ty_Varifier(Nvl(l_Ty_Varifier.COUNT, 0) + 1) := l_Append_Var;
      --Dbms_Output.put_line('L_TY_PATHS_TEMP.Count::'||L_TY_PATHS_TEMP.Count);
      IF l_Ty_Paths_Temp.COUNT > 0 THEN
         l_Index_Num := Nvl(l_Ty_Paths.COUNT, 0) + 1;
         FOR i IN l_Ty_Paths_Temp.FIRST .. l_Ty_Paths_Temp.LAST LOOP
            l_Ty_Paths(l_Index_Num) := l_Ty_Paths_Temp(i);
            --Dbms_Output.put_line('L_INDEX_NUM::'||L_INDEX_NUM);
            --Dbms_Output.put_line('L_TY_PATHS(L_INDEX_NUM)::'||L_TY_PATHS(L_INDEX_NUM));
            l_Index_Num := l_Index_Num + 1;
         END LOOP;
      END IF;
      --Dbms_Output.put_line('L_TY_PATHS.Count::'||L_TY_PATHS.Count);
      --Dbms_Output.put_line('L_TY_PATHS.Count::'||L_CUR_EXEC_ROW);
      IF (NOT l_Ty_Paths.EXISTS(l_Cur_Exec_Row + 1)) OR (l_Cur_Exec_Row = l_Ty_Paths.COUNT) THEN
         --Dbms_Output.put_line('Exiting');
         EXIT;
      ELSE
         --Dbms_Output.put_line('Inside the Else part');
         l_Cur_Exec_Row := l_Cur_Exec_Row + 1;
         l_Append_Var   := l_Ty_Paths(l_Cur_Exec_Row);
         l_Where_Clause := l_Ty_Paths(l_Cur_Exec_Row) || '*';
      END IF;
      --To Display the record:
         --Dbms_Output.put_line(L_TY_PATHS.Count);
      END LOOP;
      IF l_Ty_Paths.COUNT > 0 THEN
        FOR i IN l_Ty_Paths.FIRST .. l_Ty_Paths.LAST LOOP
          Dbms_Output.Put_Line(i || ' record is ' || l_Ty_Paths(i));
       END LOOP;
    END IF;
    END;

    Hi,
    Thanks for the reply.
    Please find the details :
    1) What's your database version ?
    Database version  :
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    2) What's the practical use of extracting all the paths like this, what are you trying to achieve, besides a purely academic exercise ?
    The XML provided was for sample XML.
    The practical use being ,I wanted to parse the SEPA messages using the below code snippet dynamically.
    create table data_table (
         data xmltype
        xmltype column data store as securefile binary xml
    insert into data_table values (
        xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <SCTScfBlkCredTrf xmlns="urn:S2SCTScf:xsd:$SCTScfBlkCredTrf">
      <SndgInst>CMCIFRPPXXX</SndgInst>
      <RcvgInst>RLBBAT2E083</RcvgInst>
      <FileRef>006FRID2516PH712</FileRef>
      <SrvcId>SCT</SrvcId>
      <TstCode>T</TstCode>
      <FType>SCF</FType>
      <FDtTm>2012-11-01T01:12:22</FDtTm>
      <NumCTBlk>1</NumCTBlk>
      <NumPCRBlk>0</NumPCRBlk>
      <NumRFRBlk>0</NumRFRBlk>
      <NumROIBlk>0</NumROIBlk>
    <FIToFICstmrCdtTrf xmlns="urn:iso:std:iso:20022:tech:xsd:sct:pacs.008.001.02">
      <GrpHdr>
        <MsgId>006MSID12511PH712</MsgId>
        <CreDtTm>2012-11-01T08:09:14</CreDtTm>
        <NbOfTxs>1</NbOfTxs>
        <TtlIntrBkSttlmAmt Ccy="EUR">20000</TtlIntrBkSttlmAmt>
        <IntrBkSttlmDt>2012-11-01</IntrBkSttlmDt>
        <SttlmInf>
          <SttlmMtd>INGA</SttlmMtd>
          <ClrSys>
            <Prtry></Prtry>
          </ClrSys>
        </SttlmInf>
        <InstgAgt>
          <FinInstnId>
            <BIC>RLBBAT2E083</BIC>
          </FinInstnId>
        </InstgAgt>
        <InstdAgt>
          <FinInstnId>
            <BIC>HELADEF1XXX</BIC>
          </FinInstnId>
        </InstdAgt>
      </GrpHdr>
      <CdtTrfTxInf>
        <PmtId>
          <EndToEndId>006SEOP23END1712</EndToEndId>
          <TxId>006SEOP231PH1712</TxId>
        </PmtId>
        <PmtTpInf>
          <SvcLvl>
            <Cd>SEPA</Cd>
          </SvcLvl>
        </PmtTpInf>
        <IntrBkSttlmAmt Ccy="EUR">20000</IntrBkSttlmAmt>
        <AccptncDtTm>2012-11-01T12:00:00</AccptncDtTm>
        <ChrgBr>SLEV</ChrgBr>
        <Dbtr>
          <Nm>Mrinmoy Sahu</Nm>
          <PstlAdr>
            <Ctry>FR</Ctry>     
            <AdrLine>6</AdrLine>
            <AdrLine>Bangalore</AdrLine>
          </PstlAdr>
          <Id>
            <PrvtId>
              <Othr>
                <Id>E20809</Id>
                <SchmeNm></SchmeNm>
                <Issr>ORACLE CORP</Issr>
              </Othr>
            </PrvtId>
          </Id>
        </Dbtr>
        <DbtrAcct>
          <Id>
            <IBAN>FR7030087330086000000000591</IBAN>
          </Id>
        </DbtrAcct>
        <DbtrAgt>
          <FinInstnId>
            <BIC>CMCIFRPPXXX</BIC>
          </FinInstnId>
        </DbtrAgt>
        <CdtrAgt>
          <FinInstnId>
            <BIC>RLBBAT2E083</BIC>
          </FinInstnId>
        </CdtrAgt>
        <Cdtr>
          <Nm>Mrinmoy Sahu</Nm>
          <PstlAdr>
            <Ctry>FR</Ctry>     
            <AdrLine>22 </AdrLine>
          </PstlAdr>
          <Id>
            <PrvtId>
              <Othr>
                <Id>F676869</Id>
                <SchmeNm></SchmeNm>
                <Issr>GOVT OF INDIA</Issr>
              </Othr>
            </PrvtId>
          </Id>
        </Cdtr>
        <CdtrAcct>
          <Id>
            <IBAN>FR7630087330086000000004266</IBAN>
          </Id>
        </CdtrAcct>
        <RmtInf>
            <Ustrd>abc</Ustrd>
          </RmtInf>
      </CdtTrfTxInf>   
      </FIToFICstmrCdtTrf>
    </SCTScfBlkCredTrf>
    alter session set nls_numeric_characters = ".,";
          SELECT Msgid, Msgid1, Sttlmmtd
       FROM   data_table t,Xmltable(Xmlnamespaces('urn:S2SCTScf:xsd:$SCTScfBlkCredTrf' AS "A", 'urn:iso:std:iso:20022:tech:xsd:sct:pacs.008.001.02' AS "B")
                        ,'/A:SCTScfBlkCredTrf/B:FIToFICstmrCdtTrf' Passing t.data Columns
                        Msgid Path 'A:SndgInst'
                        ,Msgid1 Path 'B:GrpHdr/B:MsgId'
                        ,Sttlmmtd Path 'B:GrpHdr/B:SttlmInf/B:SttlmMtd');
    MSGID             ;MSGID1           ;STTLMMTD         ;
                     ;006MSID12511PH712;INGA             ;
    The idea was to :
    1). Map the Column Names for the XPath built using the previous code.
    2). Build the Select statement shown above dynamically based on the Xpath built in the previous code using a PLSQL block, and to process the data by doing a bulk collect on the XML.
    The above XML may contain multiple <FIToFICstmrCdtTrf></FIToFICstmrCdtTrf> nodes.
    Since the name space in the XML varies for each version of the SEPA messages , i need to get the names spaces ALSO to be picked up dynamically and parse the XML data based on the select statement as shown above.
    Could you please guide me with
    1). Is the approach taken appropriate?
    2). Any alternative approach should be looked for ?
    3). How to extract the name spaces available in the XML?
    Thanks.

  • XPath with XML Schema

    Is there any way of finding out the namespace prefix if there is one, from a DOMParser instance or a XMLDocument instance?
    I have a DOMParser instance and I don't know whether there is a namespace specification in it. If there is, I need to know what it is so I can update my XPath expressions to use the appropriate prefix.
    I have tried the XMLDocument.getNamespace function but it doesn't seem to be implemented (or it is depricated).
    Any help would be greatly appreciated.

    You're right on track with the namespaces hunch.
    XPath 1.0 does not provide the ability to search on the default namespace.
    That is, even if you document looks like this:<foo xmlns="urn:bar"/>you cannot use any compliant XPath 1.0 implementation to find the <foo> element with the pattern /foo, since in XPath 1.0 /foo finds the <foo> element that is the child of the root with a null namespace URI.
    In the example above, the namespace uri of the <foo> element is urn:bar, so in particular it's not null.
    With XPath 1.0, you need to specifically qualify the foo element with a namespace prefix that is bound to the same namespace URI as your default namespace.
    So, your XPath would need to look like /xxx:foo where xxx is an arbitrary namespace prefix associated with the urn:bar namespace URI.
    The selectNodes, selectSingleNode, and valueOf methods all have an overloading which takes an instance of the oracle.xml.parser.v2.NSResolver interface as the 2nd argument. This argument is used to resolve what namespace prefixes found in the XPath search string map to.
    To implement the NSResolver interface, you need only implement a single method:
    String resolveNamespacePrefix(String prefix);
    In the example above, this method would return the string "urn:bar" when passed the prefix string "xxx" so that the XPath of /xxx:foo would match the <foo> element with urn:bar namespace uri in the example document above.
    Steve Muench
    Development Lead, Oracle XSQL Pages Framework
    Lead Product Manager for BC4J and Lead XML Evangelist, Oracle Corp
    Author, Building Oracle XML Applications
    null

  • Problems using XPath with underscore (10g)

    I'm trying to extract an attribute called OrderID from XML, normally I'd expect this to work with //Node/@OrderID, but instead I get "LPX-00601: Invalid token in:... " complaining about the underscore in the attribute name.
    Is there anyway to get around this (apart from renaming the attribute)?
    Thanks

    What I tried to say is that you could try to escape it...
    I am not sure (and I don't have the energy to look it up), but if an underscore is correct regarding XPath syntax then it should be handled as a bug and you should file a service request for it on http://metalink.oracle.com.
    Message was edited by:
    mgralike

  • JDeveloper v.11.1.1.3.0 How to search in XML with XPath with NameSpace ?

    Hello!
    In JDeveloper v.11.1.1.3.0 i try to serch xpath expression, but i cant find where to type a NameSpace aliases ?
    Becose a NameSpace can by very long its good to be an alias somewhere ...\

    HI Satish,
    Your question is not able to understand. i guess you are looking for  building project with ant tool for deployment.
    plz find the below links
    Building Projects with Ant
    Using Maven In JDeveloper 11.1.2: Build ADF application with Maven using Ant ojdeploy
    One size doesn't fit all: Using ojdeploy and Ant for creating ADF library JARs
    Thanks
    Nitesh

  • How to use XPath with XMLBean?

    Hi all,
    I'm using xmlbean for a new project now, and everything was great until I tried
    to use a XPath selection.
    I got a "java.lang.UnsupportedOperationException: This operation requires xqrl.jar"
    exception, but I could not find this jar anywhere.
    I'm using the stand alone version of XMLBena. This is a small project and there
    is no need for an App Server, therefore no full WebLogic 8.1
    Any ideas?
    Thanks,
    Silvio

    Hello Silvio -- Are you working with XMLBeans as downloaded from Apache?
    XPath support in the standalone implementation of XMLBeans is limited to
    simple expressions. The more sophisticated support available via xqrl.jar is
    included with XMLBeans as it ships with WebLogic Platform 8.1.
    Steve
    "Silvio deMorais" <[email protected]> wrote in message
    news:3ff9b696$[email protected]..
    >
    Hi all,
    I'm using xmlbean for a new project now, and everything was great until Itried
    to use a XPath selection.
    I got a "java.lang.UnsupportedOperationException: This operation requiresxqrl.jar"
    exception, but I could not find this jar anywhere.
    I'm using the stand alone version of XMLBena. This is a small project andthere
    is no need for an App Server, therefore no full WebLogic 8.1
    Any ideas?
    Thanks,
    Silvio

  • Use of Xpather with OATS.

    We have been using Selenium.
    Now we are learning OATS. Can we use the "XPather',FireBug with OATS.
    I assume we can use the isTextPresent, asserEquals etc with OATS tool.
    Is this correct.
    Regards

    Thanks for the reply Alex.
    I would like to know whether or not we can use Firebug,XPather tool (these attach to Firefox browser only). These are not related to OpenScript directly, though, the IDE/Interface is eclipse, it seems.
    Regards

  • How to use XPath with Namespaces in the xml ?

    Hi all,
    I need to reference a certain Node in a Document using XPath notation.
    The problem is the the XML Document contains Namespaces inside it
    f.e.
    <xn:SubNetwork id="JRANM">
        <xn:VsDataContainer id="1">
           <xn:vsDataType>vsDataAreas</xn:vsDataType>
        </xn:VsDataContainer>
    </xn:SubNetwork >Using DOMXPath (from weblogic.xml.xpath)
      DOMXPath xPath = new DOMXPath("xn:SubNetwork/*");
      Set nodeset = xPath.evaluateAsNodeset(this.xmlRootElement);When I Iterate through the Set I can see it's empty.
    (On the other hand without namespaces everything is fine.)
    So how can I reference a Node that contains a namespace in it ?
    Thanks a lot
    Francesco

    We use the following class to perform XPath Queries on our XmlBean objects.
    Hope this helps,
    Craig
    import java.util.Set;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.apache.xmlbeans.XmlException;
    import org.w3c.dom.Document;
    import weblogic.xml.util.StringInputStream;
    import weblogic.xml.xpath.DOMXPath;
    * Class to encapsulate API specific (i.e. weblogic) XML functions
    public class XmlUtil {
         * Returns a set containing objects of type reflected in the query.<br/>
         * e.g.<br/>
         * /saur:tree/saur:treeNode[@label='My Reports']<br/>
         * Returns a Set of TreeNode objects<br/>
         * Sample Code: <br/>
         * <code>
         * Set set = XmlUtil.executeXPathQuery( myQuery, tree.xmlText());
         * for( Iterator iter = set.iterator(); iter.hasNext();) {
         *     TreeNode node = TreeNode.Factory.parse((Node)iter.next());
         *     // Do whatever...
         * </code>
         * @param query
         * @param xml
         * @return
        public static Set executeXPathSetQuery( String query, String xml) throws XmlException {
            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();   
                factory.setNamespaceAware(true);
                DocumentBuilder builder = factory.newDocumentBuilder();
                StringInputStream in = new StringInputStream(xml);
                Document doc = builder.parse(in);
                DOMXPath xQuery =  new DOMXPath(query);
                return xQuery.evaluateAsNodeset(doc);
            catch(Exception x) {
                throw new XmlException("Error running XPath query", x);
    }

  • Using XPath with SQL to extract XML data

    Given data such as this one:
    <?xml version="1.0"?>
    <ExtendedData>
       <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
    </ExtendedData>I normally use extractValue function as shown below for example to extract the value for the last parameter in the data above, e.g:
    select extractValue(extended_data,'/ExtendedData/Parameter[@name="RealProv"]/BooleanValue') "my_column_alias" from tableAny ideas on how I may return the value of the parameter xsi:nil from this node:
    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>I'd like to extract the true in xsi:nil="true"...
    Thanks,
    Edited by: HouseofHunger on May 15, 2012 2:13 PM
    Edited by: HouseofHunger on May 15, 2012 2:13 PM

    Extractvalue() has a third parameter we can use to declare namespace mappings :
    SQL> with sample_data as (
      2    select xmltype('<?xml version="1.0"?>
      3  <ExtendedData>
      4    <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      5    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      6    <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      7    <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
      8  </ExtendedData>') doc
      9    from dual
    10  )
    11  select extractvalue(
    12           doc
    13         , '/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
    14         , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
    15         )
    16  from sample_data
    17  ;
    EXTRACTVALUE(DOC,'/EXTENDEDDAT
    true
    If you're on 11.2.0.2 and up, extractvalue() is deprecated.
    One should use XMLCast/XMLQuery instead :
    SQL> with sample_data as (
      2    select xmltype('<?xml version="1.0"?>
      3  <ExtendedData>
      4    <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      5    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      6    <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      7    <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
      8  </ExtendedData>') doc
      9    from dual
    10  )
    11  select xmlcast(
    12           xmlquery('/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
    13            passing doc
    14            returning content
    15           ) as varchar2(5)
    16         )
    17  from sample_data
    18  ;
    XMLCAST(XMLQUERY('/EXTENDEDDAT
    true
    Note : the xsi prefix is predefined when using Oracle XQuery, so in this case we don't have to declare it explicitly.
    Edited by: odie_63 on 15 mai 2012 15:23

  • Xpath with another xpath between single quotes

    Hello,
    Im using an xpath expression to find a node in a xml variable. In this xpath I need to equal the text part of the resolved node to the value returned from the xpath from another xml variable. The value returned from the second xpath needs to be between single quotes in the first xpath, but it is not working. I already tried this:
    /path_to_xml1/root_node/node[text = '/path_to_xml2/root_node/node']
    string(/path_to_xml1/root_node/node[text = '/path_to_xml2/root_node/node'])
    string(/path_to_xml1/root_node/node[text = 'string(/path_to_xml2/root_node/node')])
    thank you

    When you say : "...I need to equal the text part of the resolved node", are you talking about a text attribute of the node or just the value of that node?
    If it's just the value of the node then you should just use /path_to_xml1/root_node/node /path_to_xml2/root_node/node
    Jasmin

  • Xpath with unknown namespace prefix

    Given XML that looks like this
       <nnn:XXX>
         <mmm:YYY>value</mmm:YYY>
       </nnn:XXX>
    And in the above the 'mmm' can vary but the 'YYY' doesn't.
    Can one construct an XPath expression that explicity returns the node-set for the inner element block using 'YYY'?
    I am not looking for a first node or indexed solution but rather one that explicitly uses 'YYY' and not 'mmm' in some way.
    I tried several variations (guesses) using the function Contains but that did nothing but produce syntax errors.

    The namespace prefix is meaningless, it's only the namespace URI that is significant, so there's no XPath way of searching given a namespace prefix. But fortunately you have the opposite problem, you don't care about the namespace at all. The XPath function local-name() returns the local part of the name of a node, in your example the "YYY" part of the element name.

  • Using XPath with the XML DOM

    I have just started to use the XML DOM API. One thing I cannot see yet is an easy way to use XPath to get the value of an element.
    What I would like to do is pass an XPath expression like this:
    \EDIFACT\ORDERS\NAD[2]\NAD01\NAD0102
    into a method, and get the value of the element returned to me.
    Does anybody know if there is a method of one of the DOM interfaces that would provide that kind of functionality, or am I going to have to traverse the nodes of the DOM tree manually to do this?
    BR,
    Tony.

    Hi Tony,
    I read your posted question - I have the same problem.
    I think that the method find_from_path_ns (or find_from_path) is the only "xpath"-like way to get a value.
    BUT the syntax is very limited so you cannot use all good features of xpath
    To traverse the nodes manually is (in my problem) unpractible - the xml-structures are different and it's horrible to traverse the tree.
    I need xpaths like ' //x/y[3]/z[a='MS']' . I know, the performance is not very good but for small XML-messages fast enough
    Do you have any solutions?
    regards
    Wolfgang Hummel

  • Reading more than one value with XPath and java 1.5

    Hello, I'm using XPath with Java 1.5 and I've some problems.
    I do these things:
    File xmlDocument = new File("c:/test.xml");
    InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
    XPathFactory factory = XPathFactory.newInstance();
    XPath xPath = factory.newXPath();
    int replication = Integer.parseInt(xPath.evaluate("/simulation/setup/replication", inputSource));
    System.out.println(replication); // THIS WORKS!
    warmuptime = Integer.parseInt(xPath.evaluate("/simulation/setup/warmuptime", inputSource));
    System.out.println(warmuptime); // THIS DON'T WORK: javax.xml.xpath.XPathExpressionException
    As I had written in the comments, the first time I call ".evaluate", it works, the second time it raises an exception.
    The Xml is correct! The string "/simulation/setup/warmuptime" is correct!
    I tryed to place a:
    xPath.reset()
    between the two "evaluate", but still doesn't work.
    Can you give me an help? or suggest me an url where these things are explained in a simple way?
    I just need to get some data from an XML file and XPath seems to be the quickest and easiest way.
    Thanks for the help.

    Are all the files in one directory? If so you can make a File object of the directory, get an array of all files in that directory (File has a method to do this). Then loop over your array and call a method that reads the File that you pass as a parameter.

  • XSLT Processor, set_expression

    hello,
    in the last few days i´ve posted several questions about xslt, xslt processor, ixml etc., but nobody could give me an answer. i think all my attempts to solve my problem gone to the wrong path.
    now, this will be my last question to this topic.
    is it possible to use xsl functions such like concat, count, etc. with the set_expression method in class cl_xslt_processor  (see below).
    it tested it with different xpath-expression.
    i guess it is not possible. only logical path expression seems to work. when i call method "get_nodes" the result is empty, also the result of method "output_string" and "output_stream".
    okay, i see why get_nodes do not return a ixml_node_collection, but i hoped a result would be return by an other method or attribute.
    i would be very happy, if someone could approve my attempts or knows a workaround.
    kind regards
    sebastian
      DATA: lr_xslt                  TYPE REF TO cl_xslt_processor,
                lr_node_collection TYPE REF TO if_ixml_node_collection,
      CREATE OBJECT lr_xslt.
      CALL METHOD ori_xslt->set_expression
            EXPORTING
              expression = 'concat(//Child/@attribute,''1'')'. 
      CALL METHOD lr_xslt->run
            EXPORTING
              progname = ' '
            RECEIVING
              rval     = lv_subrc.
          lr_node_collection = ori_xslt->get_nodes( ).
          lr_node_collection = "*** illegal reference ***
    Message was edited by:
    Has nobody an answer or estimation to my attempts?
    Thanks and kind regards
    S.
            Sebastian Rasp

    I come to the conclusion that it´s not possible to use any xsl-function such as concat, substring etc.

Maybe you are looking for

  • Unable to deploy from Eclipse - Runner class cannot be initialized

    Hello two days ago, I installed the newest versions of Glassfish Tools together with the newest Eclipse Luna SR1 when trying to deploy, I am getting the following error message: org.glassfish.tools.ide.admin.CommandException: Cannot initialize Runner

  • Custom faces component not rendering at runtime

    I'm new to the JSF Framework. So I thought that starting a custom component/tag library would be a good start to jump in and get familiar with it. My goal is to have a project separate from my web-apps that I could compile into a jar which I could in

  • EJB"s as webservices

    Hi, we are supposed to build an service from scratch using web services. so i suggested, to build the service using ejb3 and then deploy it as a web service. But now few questions are pondering me: 1) If ejb has some hashmap and hashtable datatype in

  • Snow Leopard, World of Warcraft & iTunes Crash

    Was searching through these and other forums, but haven't seen anyone else with this issue. Upgraded to Snow Leopard. WoW runs great. iTunes runs great. Everything seems to run very fast... However, when I have an iTunes video window open while playi

  • In RZ70-----_SLD_RFC Active check box

    Hi In TC-----RZ70 Under Data Collection Programs Program name:  SLDRFC Active check box  is not checked. 1. What is its significance ? 2. Does it need to be checked ? Thanks, srinivas