Retrieve records based on condition from xml using XPATH

Hi all,
I have a table form_content where there are two columns - form_content_id (numeric) and xml_content (clob). The structure of xml_content is
<RAF xmlns="http://www.abnamro.com/WCS/GCEG/KRT">
<XBorderRAF>
<ClientProfile isBranch="1" isBusinessAddressDifferent="1" isSubsidiary="0" regDate="2009-09-01">
<RegisteredAddress city="test" country="GB" nameOfContactPerson="3454545" street1="test" telephoneNumber="34534545"/>
</ClientProfile>
</XBorderRAF>
</RAF>
I want to retrive all form_contant_id from form_content table where country is 'GB' inside RegisteredAddress tag.
I am able to retrive all form_content_id with country value using below query,
SELECT form_content_id,
extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
as registerAddress
from
form_content
but I am finding it difficult to reterive records based on any condition..
SELECT form_content_id,
extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
as registerAddress
from
form_content
where
(extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')='GB'
Please help me to resolve this problem. ....
Thanks

Ok, thaks to all who looked this query, I found the answer
select form_content_id
from xmltest
where existsnode(xmltype(xml_content), '/RAF/XBorderRAF/ClientProfile/RegisteredAddress[@country="GB"]','xmlns="http://www.abnamro.com/WCS/GCEG/KRT"') = 1;

Similar Messages

  • How to remove elements/attributes from XML using Xpath in XSLT ??

    Hello ,
    Is there anyway or method of Xpath from which I can delete the elements and attributes from XML at runtime ??
    Like I have such XML and I have to remove per attribute highlighted below
    <person per="and">
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    And want a result like this
    <person>
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    Thanks

    To achieve this you can use the bpelx:remove function: http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm#CIHJBJFD
    your assign will look like:
    <bpel:assign>
    <bpelx:remove>
    <target variable="person" query="/person/@per" />
    </bpelx:remove>
    </bpel:assign>
    Regards,
    Melvin

  • Extracting from table based on conditions from two internal tables

    Hi,
         i to have select few records from  a table based on conditions from two different internal tables. How can I achieve this.?
    ex:
          select objid from HRVPAD25 into table t_pad25
                                                    where PLVAR = 01
                                                                OTYPE = E
                                                                OBJID = itab1-sobid
                                                                sobid = itab2-pernr.
    How can this be written? can i use "for all entries..." addition with 2 tables?

    Hi Maansi_SAP,
    you can use exactly one internal table in the FOR ALL ENTRIES clause. Consider this alternative:
    data:
      itab_sobid_hash like itab1 with unique key sobid,
      ls_pad25  like line of  t_pad25.
    sort itab1.
    delete adjacend duplicates from itab1 comparing sobid.
    itab_sobid_hash = itab1.
    select objid
      into ls_pad25
      from HRVPAD25
      for all entries in itab2
      where PLVAR = '01'
        and OTYPE = E
        and sobid = itab2-pernr..
    read table itab_sobid_hash with table key sobid = ls_pad25-objid.
    check sy-subrc = 0.
    append ls_pad25 to t_pad25.
    endselect.
    You may decide if itab1 or itab2 is better used as hashed table. Make a performance test.
    The critics will tell you that SELECT ... ENDSELECT is not performant. That was very true, back in last milleniums's 90ies
    Regards,
    Clemens

  • Error when reading data from XML using JAXB?

    Hi all,
    I get the error message when reading data from XML using JAXB.
    [org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.]
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException
    (AbstractUnmarshallerImpl.java:315)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:481)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:199)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142)
    I don't find the reason, please help!
    Thanks in advance!

    The problem is sovled.

  • Count multiple nodes in XML using xPath

    Hi',
    How to count the CUSTSERIAL node in the below XML using xPath.
    <missingICCRec>
    <MissingField xmlns="http://www.Google.com/MissingFields/v1.0">
    <CUSTSERIAL xmlns="http://Google.com/InboundService">23809002RN</CUSTSERIAL>
    <CUSTSERIAL xmlns="http://Google.com/InboundService">23809003RN</CUSTSERIAL>
    <CUSTSERIAL xmlns="http://Google.com/InboundService">23809004RN</CUSTSERIAL>
    </MissingField>
    </missingICCRec>
    Thanks
    Yatan

    Yatan,
    I created a simple BPEL with assign to count the node. Using ora:countNodes() function is throwing exception but when i tried with count() it works.
    XSD seems to be valid. Only you need to have the function as below.
    count(bpws:getVariableData('inputVariable','payload','/client:process/client:missingICCRec/client:MissingField/client:CUSTSERIAL'))
    XSD Used:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema attributeFormDefault="unqualified" elementFormDefault="qualified"
    targetNamespace="http://xmlns.oracle.com/PIMtoRPASAmendment/BPLENodeCount/BPLENodeCount"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="process">
    <complexType>
    <sequence>
    <element name="missingICCRec">
    <complexType>
    <sequence>
    <element name="MissingField">
    <complexType>
    <sequence>
    <element name="CUSTSERIAL" maxOccurs="unbounded" type="string"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    <element name="processResponse">
    <complexType>
    <sequence>
    <element name="result" type="string"/>
    </sequence>
    </complexType>
    </element>
    </schema>
    This works !!!
    Please let me know if this helps.
    Thanks,
    Vijay

  • Write XML using XPath

    Hi,
    I have a problem. I need to WRITE a XML using XPath.
    Supose that XPath String : "/clients/client/name"
    Equivalent XML :
    <clients>
    <client>
    <name></name>
    </client>
    <clients>
    Please, helpme ...
    The XPath Strings are dinamic, there are lot of combinations.
    Is there an API (free ?) that support this ?
    Thankz

    Normally XPath is used for searching existing XML documents, not for creating new ones. So it's unlikely that anything exists to do what you ask. But not impossible, people do the strangest things. Have you searched Google?
    Of course you realize you can't use arbitrary XPath expressions here, for example what would you do with a predicate?

  • Delete duplicate records based on condition

    Hi Friends,
    I am scratching my head as how to select one record from a group of duplicate records based upon column condition.
    Let's say I have a table with following data :
    ID   START_DATE   END_DATE    ITEM_ID     MULT    RETAIL            |                      RETAIL / MULT
    1     10/17/2008   1/1/2009     83     3     7                 |                            2.3333
    2     10/17/2008   1/1/2009     83     2     4                 |                            2
    3     10/17/2008   1/1/2009     83     2     4                 |                            2
    4     10/31/2008   1/1/2009     89     3     6                 |                            2
    5     10/31/2008   1/1/2009     89     4     10                |                            2.5
    6     10/31/2008   1/1/2009     89     4     10                |                            2.5
    7     10/31/2008   1/1/2009     89     6     6                 |                            1
    8     10/17/2008   10/23/2008     124     3     6                 |                            2From the above records the rule to identify duplicates is based on START_DATE,+END_DATE+,+ITEM_ID+.
    Hence the duplicate sets are {1,2,3} and {4,5,6,7}.
    Now I want to keep one record from each duplicate set which has lowest value for retail/mult(retail divided by mult) and delete rest.
    So from the above table data, for duplicate set {1,2,3}, the min(retail/mult) is 2. But records 2 & 3 have same value i.e. 2
    In that case pick either of those records and delete the records 1,2 (or 3).
    All this while it was pretty straight forward for which I was using the below delete statement.
    DELETE FROM table_x a
          WHERE ROWID >
                   (SELECT MIN (ROWID)
                      FROM table_x b
                     WHERE a.ID = b.ID
                       AND a.start_date = b.start_date
                       AND a.end_date = b.end_date
                       AND a.item_id = b.item_id);Due to sudden requirement changes I need to change my SQL.
    So, experts please throw some light on how to get away from this hurdle.
    Thanks,
    Raj.

    Well, it was my mistake that I forgot to mention one more point in my earlier post.
    Sentinel,
    Your UPDATE perfectly works if I am updating only NEW_ID column.
    But I have to update the STATUS_ID as well for these duplicate records.
    ID   START_DATE   END_DATE    ITEM_ID     MULT    RETAIL    NEW_ID   STATUS_ID |   RETAIL / MULT
    1     10/17/2008   1/1/2009     83     3     7         2         1      |     2.3333
    2     10/17/2008   1/1/2009     83     2     4                                |     2
    3     10/17/2008   1/1/2009     83     2     4           2         1      |     2
    4     10/31/2008   1/1/2009     89     3     6           7         1      |     2
    5     10/31/2008   1/1/2009     89     4     10          7         1      |     2.5
    6     10/31/2008   1/1/2009     89     4     10          7         1      |     2.5
    7     10/31/2008   1/1/2009     89     6     6                            |     1
    8     10/17/2008   10/23/2008     124     3     6                            |     2So if I have to update the status_id then there must be a where clause in the update statement.
    WHERE ROW_NUM = 1
      AND t2.id != t1.id
      AND t2.START_DATE = t1.START_DATE
      AND t2.END_DATE = t1.END_DATE
      AND t2.ITEM_ID = t1.ITEM_IDInfact the entire where_ clause in the inner select statement must be in the update where clause, which makes it totally impossible as T2 is persistent only with in the first select statement.
    Any thoughts please ?
    I appreciate your efforts.
    Definitely this is a very good learning curve. In all my experience I was always writing straight forward Update statements but not like this one. Very interesting.
    Thanks,
    Raj.

  • Retrive records based on condition

    HI,
    Need some clarification on getting the records based on the condition given.
    Here is my requirement. I have developed a function module to search the records based on some input given. For suppose i get some around 10000 records for this condition. Now i need the output records in multiples.
    Like first i execute the FM based on the some condition and i should get 100 records as output and the second time i execute the FM with the same search condition i need to get the records from 101 to 200 and the third time i execute and so on.
    Is there any way of fetching the records in multiles for the same search criteria. If so can anyone let me know hot to do the same.
    Thanks in advance.
    Regards,
    Ram

    HI Ram
    Please check this example to get some idea:
    tables: vbak.
    data: it_vbak type table of vbak,
          wa_vbak1 type vbak,
          wa_vbak2 type vbak.
    data: lin type i.
    select-options: s_erdat for vbak-erdat obligatory.
    select * into table it_vbak from vbak
           package size 10
           where erdat in s_erdat.
           describe table it_vbak lines lin.
           read table it_vbak into wa_vbak1 index 1.
           read table it_vbak into wa_vbak2 index lin.
           break-point.
    endselect.
    Check the entries in IT_VBAK whenever the break-point is reached. You will have a fresh set of entries for every collection.
    Hope this gives you some idea.
    Kind Regards
    Eswar

  • Remove element from xml using dom.

    i want to remove an element from an xml file using dom.
    i remove the element but the whole content of the file is also deleted.
    how can i rewrite the file.

    vij_ay wrote:
    subject :Remove element from xml,but if empty element in input file then output should be <tag></tag>, not like <tag.xml/>I assume you mean <tag/> but why do you want this? Any application that will not accept this valid XML construct is flawed and a bug report should be raised against it.

  • Set XML attribute from SetValue using Xpath

    Is there a trick to assigning a value to an attribute of an element in an XML variable using XPATH inside a setValue activity?  When I try something like
    Location
    /process_var/xml_var/test/@ID
    Expression:
    /process_var/test_value
    it complains about the @ sign in the location assignment.  I seem to be able to retrieve attributes just fine.

    Still having this issue.
    If I have an XML process variable which currently contains
    <Document>
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it fails.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    Try this, it works.
    Location: /process_data/xml/Document/ID
    Expression: 54
    Now, alter the XML by adding an ID attribute
    <Document ID="">
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it works, where it failed earlier.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    It appears to me, you can ADD a new node, but you can't ADD an attribute

  • How to read xml-stylesheet Processing Instruction from XML using DOM Parser

    Hi,
    I am trying to read an xml that contains xsl stylesheet PI using DOMParser. The parse() method reads the entire contents of the XML except the PI instruction. Below is the XML I am using to read
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet href="../../../lang/en-us/style0/usc_profile.xsl" type="text/xsl"?>
    <Oblix oblang="en-us" xmlns="http://www.oblix.com/" xmlns:oblix="http://www.oblix.com/">
    <ObProfile>
    </ObProfile>
    </Oblix>
    Can anyone let me know if there are any propery settings to be done for the DOM parser before parsing?. If so, what is the property to be set?.
    Thanks in Advance
    Muthu

    A COTS product builds the XML and inserts the respective xsl (xml:stylesheet) file name to be used for transforming the xml. I am trying to interrupt this xml and make some updations on an element and finally send the updated xml to the stream.
    For the above process, I parse the input XML using DOMParser and update the elements (some internal elements). While I view the final XML that would be passed to the stream, I found the <?xml-stylesheet... PI is missing.
    I somehow managed using a temp fix by doing the below. I manually pulled the PI using document.getFirstChild().getNodeValue() and reconstructed the PI and inserted it to the outgoing XML. This needs to be done every time. This might run into problems when more than one PI is used in the XML.
    If the parsed XML could get the PI along with it the above problem could be resolved.
    Is there any property that could be set on the parser (prior to parsing) to resolve the issue?.

  • Read xml using xpath in java

    Hi ALL,
    I have a xml as follows:
    <AAA>
    <BBB>
    <CCC>xyz</CCC>
    <DDD>abc</DDD>
    </BBB>
    </AAA>
    Now using any of the java class, i just need read the value of "CCC" as follows:
    (i.e using xpath i need to read the value)
    String val = x.somemethod("/AAA/BBB/CCC");
    Thanks!

    In case you're curious - here's the dom4j equivalent of dvohra09's sample code.
    SAXReader saxReader = new SAXReader("org.apache.xerces.parsers.SAXParser");
    Document doc = saxReader.read(source); //Where source is your file, input source, input stream, reader, or url
    String value = doc.valueOf("//AAA/BBB/CCC"); //Result given the xml from OP = 'xyz'OK - not much difference with this simple example but if you haven't settled on an API, dom4j is worth looking at (IMHO).
    &#8734; brewman &#8734;

  • Creating New XML using xPath

    Hi,
    I wanted to know if an XML Document created in the Database using xPaths. I mean, I don't want to creat any XML file on the OS in the first place. I want to create an XML using a table containing xPaths. Can this be done in XDB ?
    Thanks in Advance,
    Piyush

    Hi Piyush
    I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
    Chris

  • Creating XML using XPath

    Hello,
    I want to creat XML document using Dom and XPath, as per my knowledge goes I can't create it using XPath {I may b wrong, if I am then pls tell me know :-) }.
    If there doesn't exists any thing like this I am thinkin of wrapping a class {say its XPathProcesserDom} which takes the XPath querry and internaly creates XML Document and returns on request. Is this a good idea :-)
    waiting for comments :-)....
    thanks and regards,
    MaheshPujari

    Hi Piyush
    I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
    Chris

  • How to retrieve information from XML using servlets

    Hi
    I have a scenario like this
    File-->XI-->J2ee application(HTTP Receiver adapter)
    I want to know how XI sends xml file as a query string file name?
    What ever may be the case i just need to retrieve the information from Request object and display the same in browser(JSP).How to do that, I am totally confused, please anyone help me!
    Code help is highly rewarded.
    Thanx

    Hi Rajesh!
    I have tried your code. But some where i went wrong. Please correct me: I am using NWDS2.0.9
    my web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                             "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <display-name>WEB APP</display-name>
        <description>WEB APP description</description>
        <servlet>
            <servlet-name>DisplayRes</servlet-name>
            <servlet-class>com.quinnox.DisplayRes</servlet-class>
        </servlet>
        <servlet-mapping>
              <servlet-name>DisplayRes</servlet-name>
              <url-pattern>/DisplayRes/*</url-pattern>
         </servlet-mapping>
    </web-app>
    my application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
                                 "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
        <display-name>ReceiverEntpr</display-name>
        <description>EAR description</description>
        <module>
            <web>
                <web-uri>HttpReceiver.war</web-uri>
                <context-root>/HttpReceiver</context-root>
            </web>
        </module>
    </application>
    and my servlet code:
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.io.Writer;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.xml.sax.EntityResolver;
    import org.xml.sax.SAXException;
    import com.sun.java_cup.internal.parser;
    import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl;
    public class DisplayRes extends HttpServlet {
         public void doGet(HttpServletRequest requset, HttpServletResponse response) throws ServletException, IOException
              doWork(requset, response);
         public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
              doWork(req, resp);
         private void doWork(HttpServletRequest req, HttpServletResponse resp) throws IOException
              String path = null;
              PrintWriter out = null;
              PrintWriter p2=resp.getWriter();     
              try
                   resp.setContentType("text/xml");
                   out = resp.getWriter();
                   out.println("hi");
                   path = req.getPathInfo();
                   if(req.getContentLength() != -1){
                   outputURI(req.getInputStream(), out);
              } catch (IOException ioe) {     return;     
         //private void outputURI(InputStream resultStream, Writer out) {
              private void outputURI(InputStream resultStream, PrintWriter out) {
              if (resultStream == null) {
    //             no default file
    //            logger.error("No File to return");
              return;
              try {
              DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    //            Class clazz = loader.loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    //            DocumentBuilderFactoryImpl factory = (DocumentBuilderFactoryImpl) clazz.newInstance();
    //            DocumentBuilder parser = factory.newDocumentBuilder();
              parser.setEntityResolver(new ClassPathEntityResolver());
              printXML(parser.parse(resultStream), out);
              resultStream.close();
              } catch (Exception e) {
    //            logger.error("Trying to parse the output " , e);
         //private void printXML(Document document, Writer writer) throws Exception {
              private void printXML(Document document, PrintWriter writer) throws Exception {
              Transformer transformer = TransformerFactory.newInstance().newTransformer();
              Source source = new DOMSource(document);
              Result output = new StreamResult(System.out);
              transformer.transform(source, output);
    //             Write as XML so that entity references can be resolved.
              if (writer != null) {
              transformer.transform(source, new StreamResult(writer));
    Please tell me how to display in servlet.
    If it is better to display in a browser. Please send me the code.
    Thanks

Maybe you are looking for

  • F-43 Withholding tax error

    Hi, I posted correctly in F-43 using WHT, but while saving the error arise: <b>Error</b> Could not determine the year for TDS certificate number range Message no. 8I017 <b>Diagnosis</b> The excise year could not be determined for generating the numbe

  • Looking for Coldfusion Classes in-person

    I am looking for Coldfusion classes in Springfield, Massachusetts.  Any help?

  • No icon for aiprplay

    I was watching a movie last night on airplay from my mini iPad 2 and the  airplay signal just disappeared 12 min before end of movie. ?

  • Convert standby to read only

    Hi, Oracle 11gR2 / Unix I want to convert standby database (2 node rac) currently (which is in mount mode) to open read only mode. Can someone please help me steps to be done? Thanks

  • Database version dependancies

    What other components of ApEx 2.2 are database version dependant where functionality is either altered, hindered, or disabled? I am on 9iR2, so the current ones that I know are - Database Account authentication scheme (altered) - Regular Expression i