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.

Similar Messages

  • I lost my iphone and i would like to know how would i be able to back up the things that are on my phone with out me having the phone

    I would like to know how would I be able to back up my phone with out me having the phone with me ?

    sherrickia21 wrote:
    I had my contacts and everything else back up
    Then you can restore from that backup with the new iPhone.
    iOS: How to back up and restore your content
    http://support.apple.com/kb/ht1766

  • Stop the viewer having the ability to click/touch anywhere on the page and it going to the next page

    I have created a PDF with links to various pages so that it can be used on a touch screen. I need to be able to stop the viewer having the ability to click/touch anywhere on the page and it going to the next page. In Keynote you select a check box that says : "Hyperlinks only" is their something similar in PDF?

    You can upload it to a file-sharing website (Acrobat.com, DropBox, etc.)
    and post the link here, or you can send it to me privately at
    [email protected] .

  • Is it possible to find out the program having the paramters?

    Is it possible to find out the program having the paramters? if possible can you give the query

    Search the forum/Google and you should get many hits (like the ones below).
    Write a QUERY of Concurrent Program
    Write a QUERY of Concurrent Program
    Query to get Concurrent program name and its parameter
    http://sureshvaishya.blogspot.com/2008/07/query-to-get-concurrent-program-name.html
    Query to list concurrent program details with its parameter, values set and default value/type
    http://www.knoworacle.com/2010/12/query-to-list-concurrent-program.html
    Thanks,
    Hussein

  • Difference between the XML for the "Initial System Data" in the module ERM

    Hello,
    I wan to know what's the difference between the XML for the "Initial System Data" in the module ERM of SAP GRC AC 5.3.
    RE_init_clean_and_insert_data.xml
    RE_init_append_data.xml
    RE_init_methodology_data.xml
    And what "Initial System Data" do I have to put?? the rule set?
    I'm new in SAP GRC.
    Thank you very much.
    Pablo Mortera.

    Pablo,
        I am sorry but I am not able to get the question so I will explain as per my understanding. All of these three xml files contain necessary out of the box data which is required for ERM to function. Without this data, your ERM would not work so this is the first thing you want to do in ERM after successful installation.
    After that, you will have to create connector and landscape and then synchronize transaction code, auth objects, fields, values etc by running through each background job one by one.
    Regards,
    Alpesh

  • What are the advanteges and disadvanteges of using pl/sql over hibernate

    i knwo that pl/sql are well structure and provide a lot of functionalities with oracle databse , but my question is the hibernate might give some advnateges of scalability over pl/sql.
    so what are the advanteges and disadvanteges of using pl/sql over hibernate?
    and does oracle recommend using hibernate for connecting JSP with oracle 11i , or it is better to connect the JSP pages with oracle databse using pl/sql ?

    812643 wrote:
    but if i search for the diferencess then there are a lot of opinions about this ..., specially when they say that with hibernate you can integrate with any DB , and it provides object printed architecture, etc.All databases are not equal. This is a basic and fundamental fact. SQL-Server is not Oracle. Oracle is not SQL-Server. As it is the case with Sybase, Ingres, DB2 and other database products. They are all different. And there are some very core differences between them.
    So how would a product like Hibernate treat these database products with their differences? By using the lowest common denominator. Which means your expensive database product is dumbed down - and even MS Access will likely have better and more features.
    You also need to decide what is the "permanent" part in your architecture. What is going to the core? What is the expensive part? The app server (with Hibernate)? Or the database server?
    What are you likely to change next year? The app server server? Or the database server?
    In the vast majority of cases, the core is the database server. That is your biggest expense and investment. As it should be - as it holds that which is most precious to business, data. You want to ensure the integrity of that data. The accuracy of that data. Make sure that it can be easily backed up and recovered. Is flexible to use. Etc. Etc.
    The database server is the core - and that is where you need to realise your return on investment. By using the database server to its full extent.
    Hibernate does not do that. And in that respect, it is junk.
    Why does it not do that? Because many Java developers are totally and fully clueless about what database servers are and how to use them. And want to use them as little plug-in black boxes - bit buckets that are only there to provide a data persistence layer. Instead of using the database server to its full extent, they instead use Hibernate, and try to do their own "+database thing+" in the app layer - and do it poorly and with utter lack of any scalability. (and no, only ignorant Java heads think that scalability means throwing more money and h/w at it)
    My largest database processes billions of rows per day, every day, 356 days a year (between 350 to 450 million new inserts into a single table per day). And have been for several years now. It does so using PL/SQL. Using Oracle to its full extent. Then there are Java heads that cannot even design and code an app that effectively process 1% of this volume... and grasp at straws like Hibernate and other Java cr@p to "fix" this - when the actual problem is their total lack of ignorance in how to use and scale the database server.
    Hibernate is trash - and a symptom of Java developers's ignorance of database technology.

  • How to change the password of a schema using Oracle SQL Developer

    Hi need to change the password of a schema using Oracle SQL Developer how do i do it?

    Hi
    alter user username identified by password

  • Sync a phone with 2 Macs (having the same name)

    Hi,
    The question is on the title:
    is there a problem to use 2 Macs HAVING THE SAME NAME (I.E. my name) with a single phone ?
    I hope a clearly asked my question (my frenchy english is sometimes clumsy).
    Where can I find a omplete documentation of iSync.
    Thank you all

    Welcome to Apple Discussions.
    The short answer is yes, this approach is problematic and can result in severe data corruption on not only your mobile handset, but on both computers. The name of each computer is immaterial: iSync is not intended to support the use of a device as a 'data storage' go-between to equalize the contents of contact, calendaring and tasks records on two or more Macintosh desktop or portable computers.
    Instead, you should synchronize multiple Macintosh computers using:
    • .Mac Sync with a .Mac account
    • MySync from MildMannered Industries (technology acquired by Mark/Space)
    • the not-yet released SyncTogether from Mark/Space
    More information about these options is available here:
    http://www.mildmanneredindustries.com/mysync
    http://www.markspace.com/synctogether.php

  • Since last update, cursor has a mind of its own and friends with Firefox are having the same problem.

    About three weeks ago I dowsnloaded an update from you. Since then, whenever I type in MSWORD or in my Yahoo email account, the dursor jumps all over. In the beginning I did not have any idea what could be wrong. At a meeting the other evening, I mentioned the problem I was having and learned that several other people were having the same problem. The only thing that all the computers had in common was the Firefox down load. While typing this the cursor has jumped 14 times.

    Sometimes it is such as when I am working on emails. Other times it is not as when I am working with my word processor. Also, for your information I am running a Dell laptop INSPIRON 1521 with Windows Vista Home Premium.

  • Issues with Lion, anyone having the same ones?

    I'm having several of issues with Lion (mostly with Safari).   Wondering if anyone else has these problems.  I'm hoping/assuming these will be bugs that Apple will fix with a software update?   Or if therres any fix for them?
    1.   Zoom while in Safari,  the 2 finger pinch and zoom feature stops working after a while usually.  I used to like the zoom in snow leopard where on a webpage it would zoom you in while keeping the page contents within the screen.  You can still accomplish this by doing the command + shortcut.  But I really liked the touchpad feature.  I don't mind the way the zoom works on safari (zooming in wihtout keeping the page in the screen).   But my problem is it stops working after a certain amount of time.
    2.  Safari freezing up.   Yes, my safari is freezing and I'm needing to force quit every now and then.   Never really had that problem with snow leopard.
    3.  Swiping to go to my desktop.   When I try to 4 finger swipe to get to my desktop or something (going to the left always),  My launchpad keeps coming up.  Thats HORRIBLY annoying.   I have to go to my icons and manually turn launchpad off.    This might be my most annoying problem.
    4.  Getting mission control up with the four fingers swiping up usually takes 2 or 3 swipes,   and also when I'm in mission control and I want to go to something on my desktop (if I have 2 or 3 things open while having mail and safari on full screen), it takes 2 or 3 clicks to select whatever I want to go to.
    Overall I really DO like lion.  Just don't like those glitches Ive seen so far.   Anyone having the same problems?

    Tmilless wrote:
    1.   Zoom while in Safari,  the 2 finger pinch and zoom feature stops working after a while usually.  I used to like the zoom in snow leopard where on a webpage it would zoom you in while keeping the page contents within the screen.  You can still accomplish this by doing the command + shortcut.  But I really liked the touchpad feature.  I don't mind the way the zoom works on safari (zooming in wihtout keeping the page in the screen).   But my problem is it stops working after a certain amount of time.
    2.  Safari freezing up.   Yes, my safari is freezing and I'm needing to force quit every now and then.   Never really had that problem with snow leopard.
    Yes! I see the same! Extremely annoying. And as long as the pinch-zoom works, it's very unstable, and sometimes seems to freeze Safari with a "fuzzy" picture. It doesn't really freeze it, though, I can still use otheropen tabs, and usually a double-tap zoom "wakes" the "frozen tab".

  • Need Suggestion on the xml parser to be used in weblogic env.

    Hi All,
    1. I would like to know what is the parser suggested to be used when our application is running in the weblogic env. We have xerces parser already shipped in along with jdk and oracle's xdk parser is also available in the env.
    Kindly let me know what is the suggested one to use?
    2. In one of our applications, jaxp factory (javax.xml.parsers.DocumentBuilderFactory) is explicitly set to xerces's (com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl).
    Now when we changed it to use oracle xdk parser (oracle.xml.jaxp.JXDocumentBuilderFactory), We are running in to issues like 'IllegalArgumentException :not able to set Schema in setAttribute()' as a File Type.
    Previously, we used to set the Schema as File Type when xerces parser is used and that used to work fine.
    Kindly let me know the way which is accepted by both the parsers.
    Thanks
    Rajesh

    Use the default parser.
    By default, WebLogic Server is configured to use the default parser and transformer to parse and transform XML documents. The default parser and transformer are those included in the JDK 5.0.
    The built-in WebLogic Server DOM factory implementation class is com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.
    The DocumentBuilderFactory.newInstance method returns the built-in parser.
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

  • Not able to validate the xml document against DTD using SAX

    Hi ,
    i am not able to validate xml document against its DTD using SAX parser even after setting setValidating = true. even if the file is not correct according to DTD , it is not throwing any exception. what could be the reason.? please help..
    kranthi
    this is the code sample i used.
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(true);
         try {
    factory.newSAXParser().parse(new File("sample.xml"), handler);
         } catch (SAXException e) {
         e.printStackTrace();                         System.exit(2);
         } catch (ParserConfigurationException e) {
    e.printStackTrace();
    }

    Hi karthik
    Thanks for your response
    Actually iam a beginner in java coding hence struggling to come up with the things
    I tried putting your code and onserver side i see it is returning 09:12:17,234 INFO [STDOUT] [root: null]
    actually the same program i wrote in java
    and the same method i was calling from the main
    and it is working fine and the xml document is getting displayed one important thing to be noted here is that the factory.newDocumentBuilder().parse(new File(filename));is returing XmlDocument
    and the printing takes place
    but the in same method public static Document parseXMLFile(String filename, boolean b) in servlet
    the line factory.newDocumentBuilder().parse(new File(filename)); is returning DeferredDocumentImpl
    and this creating problem , had it returned XmlDocument
    i would have printed the elements one one
    but as it is returning deferredimpl
    iam unable to print the elements
    could you please tell me why factory.newDocumentBuilder().parse(new File(filename)); is returning DeferredDocumentImpl
    in servlets but in plain java pogram it is returing XmlDocument
    Thanks
    Bhanu

  • Can we reduce the size of the disk having the Log files for a Dag Database

    There is an issue with disk space filling up for 4 databases part of the same DAG, each having 1 non lagged passive copy.
    The Disks containing the log files are from the VSphere Storage. The Disk size was temporarily expanded to avoid any outages.
    There is a full backup running currently, which is expected to clear the transaction logs on completion and that should be reducing the disk space utilized.
    The storage guys want to know whether they can reclaim the temporarily expanded disk size. i.e reduce the disk space from the storage containing Log Files without affecting anything.
    I couldn't find any documentation on this specific requirement, and want to confirm

    There is an issue with disk space filling up for 4 databases part of the same DAG, each having 1 non lagged passive copy.
    The Disks containing the log files are from the VSphere Storage. The Disk size was temporarily expanded to avoid any outages.
    There is a full backup running currently, which is expected to clear the transaction logs on completion and that should be reducing the disk space utilized.
    The storage guys want to know whether they can reclaim the temporarily expanded disk size. i.e reduce the disk space from the storage containing Log Files without affecting anything.
    I couldn't find any documentation on this specific requirement, and want to confirm
    I dont see why not. Once the logs are cleared, Exchange doesnt care.
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • Parsing the XML on the client

    Hi ,
    we are on 10g. The db is on unix and client is windows.
    we have to accept the xml file name in the oracle form, parse it and store it in the db. All should happen on the client as the user is not very comfortable with the FTP solution. All the examples I have seen, need the xml file to be on the server.
    Any idea how to achieve this?
    TIA

    Using Webutil you can read the File line by line.
    Hope this helps to find a solution
    Peter

  • How to overwrite  the xml file by  flash using Php

    Hi
    i am creating getting data from the xml file ... and i am
    doing some Alteration in the xml file by flash after that flash
    producing the xml file i finished upto this process...
    nw i neeed to overwrite the xml file.... using Php.....
    can any one give me some idea ... to solve this issue
    ~~SK

    Flash Player cannot write XML files at all. but using
    php+flash we could do it .

Maybe you are looking for