Extracting records from an XML

Hi All,
I have an XML in this format.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<pm testval="1" xmlns:xsi="http://urltest">
<mid>15</mid>
<mname>Info</mname>
<mrid>145</mrid>
<fs id="11">
<fd>
<fd-id>73</fd-id>
<pfd>23</pfd>
<pfn>Test descr1</pfn>
<pft>Type1</pft>
<z>
<pfzd/>
<pfzn>67.7</pfzn>
<pfx>4444</pfx>
</z>
</fd>
<fd>
<fd-id>88</fd-id>
<pfd>552</pfd>
<pfn>Test Descr2</pfn>
<pft>Type3</pft>
<z>
<pfzd>523</pfzd>
<pfzn>532</pfzn>
<pfx>555</pfx>
</z>
</fd>
</fs>
<fs id="22">
<fd>
<fd-id>73</fd-id>
<pfd>23</pfd>
<pfn>Test descr1</pfn>
<pft>Type1</pft>
<z>
<pfzd/>
<pfzn>67.7</pfzn>
<pfx>4444</pfx>
</z>
</fd>
<fd>
<fd-id>88</fd-id>
<pfd>552</pfd>
<pfn>Test Descr2</pfn>
<pft>Type3</pft>
<z>
<pfzd>523</pfzd>
<pfzn>532</pfzn>
<pfx>555</pfx>
</z>
</fd>
</fd>
<fd>
<fd-id>89</fd-id>
<pfd>552</pfd>
<pfn>Test Descr2</pfn>
<pft>Type3</pft>
<z>
<pfzd>523</pfzd>
<pfzn>532</pfzn>
<pfx>555d</pfx>
</z>
</fd>
</fs>
<pm/>
And I would want the output in this format.
mid mname mrid fs fd-id pfd pfn pft pfzd pfzn pfx
15 Info 145 11 73 23 Test Descr1 Type1 67.7 4444
15 Info 145 11 88 552 Test Descr2 Type3 523 532 555
15 Info 145 22 73 23 Test Descr1 Type1 67.7 4444
15 Info 145 22 88 552 Test Descr2 Type3 523 532 555
15 Info 145 2 2 89 552 Test Descr2 Type3 523 532 555d
Could you help.

Solution is something like this...
SELECT extractValue(p.xml,'/pm/mid/text()') mid,
extractValue(p.xml,'/pm/mname/text()') mname,
extractValue(p.xml,'/pm/mrid/text()') mrid,
extractValue(x.column_value,'/fs/@id') fsid,
extractValue(y.column_value,'/fd/fd-id/text()') fd_id,
extractValue(y.column_value,'/fd/pfd/text()') pfd,
extractValue(y.column_value,'/fd/pfn/text()') pfn,
extractValue(y.column_value,'/fd/pft/text()') pft,
extractValue(z1.column_value,'/z/pfzd/text()') pfzd,
extractValue(z1.column_value,'/z/pfzn/text()') pfzn,
extractValue(z1.column_value,'/z/pfzn/text()') pfx,
FROM xml_table p,
TABLE(XMLSequence(extract(p.xml,'/pm/fs','xmlns:xsi="http://urltest"'))) x,
TABLE(XMLSequence(extract(x.column_value,'/fs/fd','xmlns:xsi="http://urltest"'))) (+) y,
TABLE(XMLSequence(extract(y.column_value,'fd/pft/z','xmlns:xsi="http://urltest"')))(+) z1

Similar Messages

  • Extract records from file using RegEx

    Hi guys,
    I was wondering if there's a way to extract records from a text file using regular expressions matching groups in Endeca Integrator.
    I have several XML files and I have mapped and extracted records from them using XML Reader component, but I need to preserve the tags of mapped elements. For example, if I have the following XML:
    <Msg><Para>Some text. <Emphasis>More text</Emphasis><Para></Msg>
    mapping Msg element to an output cloverField will return "Some text. More text". I need to preserve tags, so I need an output like: "<Msg><Para>Some text. <Emphasis>More text</Emphasis><Para></Msg>",
    I don't know if there's a way to accomplish this by modifying the setting of the XML Reader component, but I was thinking of using regular expressions to solve this. Unfortunately, I can't find a way to do it by using the built-in components in Integrator.
    The final solution is do it programmatically without using Integrator, but I want to know if I'm missing something.
    Thanks in advance.

    This will get the name and extension in separate variables
    set vTheFile to (choose file) as text
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
    set vPath to (vTheFile's text items 1 thru -2 as text)
    -- Add this for the file name
    set vFile to vTheFile's text item -1
    -- This will get the name and extension as  seperate items
    set AppleScript's text item delimiters to "."
    set {vFileName, VfileNameExtension} to {text item 1 of vFile, text item 2 of vFile}
    set AppleScript's text item delimiters to TempTID
    display dialog "Path is: " & vPath & return & return & "File is: " & vFile & return & "File name is: " & vFileName & return & "Extension is : " & VfileNameExtension
    (but I think I am done now)

  • Problem trying to extract records from VBFA on Smartform.

    Hello
    I'm attempting to extract records from the table VBFA and my inexperience with Smartforms is start to show.
    I only want to have  1 record per handling unit. I'm extracting using VBELV, VBELN and VBTYP_N via SELECT * FROM VBFA.
    However this gives me multiple records per handling unit. There is no further field available on the record to make it unique. This is were my inexperience comes in. How do I perform the read of VBFA without using SELECT.?
    Regards
    Mike.

    Hello Brad,
    You're right, I'm trying to get am internal table to use a loop node.
    I'd like to go for the full SELECT into a table then read it and either a skip or ignore a record that is a duplication. I'm not sure of the way to achieve this though. This is the first time I've had to manipulate the data like this. Until now I've had the keys to select the data for me.
    I've currently got:
    SELECT * FROM VBFA INTO TABLE LT_VBFA
       WHERE VBELV = IS_DLV_DELNOTE-HD_GEN-DELIV_NUMB
       AND VBTYP_N = 'X'.
    Then I have LT_VBFA INTO WA_VBFA in a LOOP node .
    There needs to be some thing between the 2 nodes to prune the unwanted duplicates.
    Regards
    Mike.

  • Need help in extracting value from an xml tag.

    Hi ALL,
    Good Morning to all, i have problem in fetching a value from a xml tag. I have created a xml schema based on the schema i have created a xmltype table and inserted a value to the table. When i am trying to fetch a value from a particular tag i am unable to do so.. Kindly help me to solve this. Here by i am posting all the workings i have done...
    I am using the following client:
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 31 11:44:59 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ////////////////////////////////// XML Schema ///////////////////////
    begin
    dbms_xmlschema.registerSchema(
    'http://www.oradev.com/chipsxml.xsd',
    '<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.oradev.com/chipsxml.xsd"
    xmlns:samp="http://www.oradev.com/chipsxml.xsd"
    version="1.0">
    <element name="Field1">
    <complexType>
    <sequence>
         <element name="UTI">
              <complexType>
              <sequence>
              <element name = "U01" type = "string"/>
              <element name = "U02" type = "string"/>
              <element name = "U03" type = "string"/>
              <element name = "U03a" type = "string"/>
              <element name = "U03b" type = "string"/>          
              <element name = "U03c" type = "string"/>          
              <element name = "U04" type = "string"/>                    
              <element name = "U05" type = "string"/>                    
              </sequence>
              </complexType>
         </element>
    </sequence>
    </complexType>
    </element>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end;
    ////////////////////////// Table which has multiple Column //////////////////////////
    CREATE TABLE chipsxmltable1 (
    id number, XMLDATA XmlType)
    XMLTYPE XMLDATA STORE AS OBJECT RELATIONAL
    XMLSCHEMA "http://www.oradev.com/chipsxml.xsd"
    ELEMENT "Field1";
    ///////////////////////////////// Insert Query in chipsxmltable //////////////////////////
    INSERT INTO chipsxmltable VALUES(
    xmltype.createxml('<?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd" >
    <UTI>
    <U01>No</U01>
    <U02>Y</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>     
    <U04>Y</U04>
    <U05>Y</U05>          
    </UTI>
    </samp:Field1>'));
    To show the data as a field with structure:
    1. Query:
    Select * from chipsxmltable1;
    Output:
    ID XMLDATA
    1 <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    2. Query: (Both the query displays the same Output)
         SELECT X.xmldata.getClobVal() "XMLDATA" FROM chipsxmltable1 X;
         select extract(XMLDATA, '/Field1').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    XMLDATA
    <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    To show the data as a single string without structure using "getstringval()":
    3. Query
         select extract(XMLDATA, '//text()').getstringval() "CHIPS - XML" from chipsxmltable1 x;
    OUtput:
    CHIPS - XML
    NoNoYYYYYY
    To show the data as a single string without structure using "getclobval()":
    4.Query
         select extract(XMLDATA, '//text()').getClobVal() "CHIPS - XML" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    NoNoYYYYYY
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACT" function:
    6.Query:
         select extract(XMLDATA, '/Field1/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    The above queries are not fetching the value.
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACTVALUE" function:
    7. Query:
         select extractValue(XMLDATA, '/Field1/UTI') "XMLDATA" from chipsxmltable1 x;
         select extractValue(XMLDATA, '/Field1/UTI/U01') "XMLDATA" from chipsxmltable1 x;
    Output:
    X
    The above queries are not fetching the value.
    My question is:
    How to fetch values from xml tag when the value are inserted through xml schema?
    Apologies if the description is not clear. Kindly let me know if further details are needed. Many thanks for your help.
    Very best regards,
    Godwin Jebakumar C.V.

    Hi,
    You need to declare the namespace of each element used in the XPath expression, like this :
    SQL> select extractvalue( XMLDATA
      2                     , '/samp:Field1/UTI/U01'
      3                     , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA"
      4  from chipsxmltable1 x
      5  ;
    XMLDATA
    No
    SQL> select extract( XMLDATA
      2                , '/samp:Field1/UTI'
      3                , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"'
      4                ).getstringval() "XMLDATA"
      5  from chipsxmltable1 x
      6  ;
    XMLDATA
    <UTI>
      <U01>No</U01>
      <U02>Y</U02>
      <U03>Y</U03>
      <U03a>Y</U03a>
      <U03b>Y</U03b>
      <U03c>Y</U03c>
      <U04>Y</U04>
      <U05>Y</U05>
    </UTI>
    Please see EXTRACT and EXTRACTVALUE documentation :
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm#i1006712
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm#SQLRF06173
    BTW, "XMLDATA" is a pseudo-column used by Oracle. I don't know if it'll ever cause any conflict but maybe you should rename your column.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256
    Regards.

  • Extracting Records from multiple tables

    hi
    I have to extract almost 1 lack  records from 3 tables.
    Please help me in ABAP CODE.
    PLease it is very urgent.

    Which tables are they ?  Refer to link below for more hints abt performance.
    Re: select query - optimization

  • Extracting array from loaded xml

    I'm using Flex 4 in an AIR project and need to load the following xml text file
    <list>
        <month name="Jan-04" revenue="400263" average="80052">
            <region name="APAC" revenue="46130"/>
            <region name="Europe" revenue="106976"/>
            <region name="Japan" revenue="79554"/>
            <region name="Latin America" revenue="39252"/>
            <region name="North America" revenue="128351"/>
        </month>
        <month name="Feb-04" revenue="379145" average="75829">
            <region name="APAC" revenue="70324"/>
            <region name="Europe" revenue="88912"/>
            <region name="Japan" revenue="69677"/>
            <region name="Latin America" revenue="59428"/>
            <region name="North America" revenue="90804"/>
        </month>
    </list>
    The original example (the old Flex 2 Dashboard example) used
       <mx:HTTPService id="srv" url="results.xml" useProxy="false" result="resultHandler(event)"/>
    to load the xml file, then used the line:
                monthData = event.result.list.month.source as Array;
    to convert the text to an array. Since this is an AIR project I'm using Filestream etc. to load the file but cannot convert it to an array. Not sure why. Here is the filestream code:
    private function loadFile():void{
    var file:File = File.applicationDirectory.resolvePath("results.xml");
    var fileStream:FileStream = new FileStream();
    fileStream.open(file, FileMode.READ);
    var xmlList:XML = XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
    fileStream.close();
    monthData = xmlList.month.source as Array;
    trace(monthData);
    but the trace is always null no matter what I try.

    Ignore all the httpService vs Filestream, the xml seems to be loading ok but I can't extract the array from the xml. The original example was from Flex 2 so I'm not sure if something has changed but the original
    monthData = xmlXML.month as Array;
    doesn't work. The xml seems fine as I can extract anything from it.
    trace(xmlXML.month[2].region[0].@name);
    I just can't turn it into an Array like in the original.

  • Inserting parent /child records from a xml file ...

    XML file pasted below:
    I have loaded the xml file into a table called xml_demo which has a column xml_data of type xmltype.
    The select for parent record is as follows and it works:
    INSERT INTO balit_submissions (balitdoc, documentversion, datetime_from,job_id, status,creation_datetime)
    (SELECT 'MOL'
    ,to_number(extract(x.xml_data,'/MolDocument/DocumentVersion/@v'))
    ,to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
    'yyyy-mm-dd"T"hh24:mi')
    ,123456
    ,'CREATED',
    NULL
    FROM xml_DEMO x WHERE
    existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1)
    Having problem creating child records. From this file I expect to create 3 records.
    insert into balit_energy_blocks
    SO_ID,
    DATETIME_FROM,
    DIRECTION,
    BLOCK_NUMBER,
    ENERGY,
    LAST_SUBMIT_DATETIME,
    PRICE_POUNDS,
    PRICE_EUROS,
    BALIT_REF,
    STATUS,
    LAST_EDIT_DATETIME,
    MOL_REASON,
    ACQUIRING_SO_AREA)
    (SELECT 'RTE'
    ,to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
    'yyyy-mm-dd"T"hh24:mi')
    ,DECODE(extract(x.xml_data,'/MolDocument/MolTimeSeries/Direction/@v'),'AO1','Up','Down')
    ,to_number(substr(extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))
    ,to_number(extract(x.xml_data,'/MolDocument/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
    ,sysdate
    ,null -- price pounds
    ,null -- price euro
    ,extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v')
    ,'SUBMITTED'
    ,'A96'
    ,NULL -- acquiring area
    ,sysdate
    FROM xml_DEMO x WHERE
    existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1)
    For example, there are 3 ContractIdentification tags. Example of 1:
    <ContractIdentification v="RTE_20100331_1500_16"/>
    I was expecting this select to pluck the last number from this string. In this case 16.
    The select was:
    to_number(substr(extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))
    The result I got was:
    16RTE_20100331_1500_20NG_20100331_1500_6
    All contractident values are concatnated and returns from position 19 onwards.
    Can anyone help me to extract the last number from each ContractIdentification tag value and to create the 3 records
    Thanks
    James Sathiaraj
    <?xml version="1.0" encoding="UTF-8"?>
    <MolDocument DtdVersion="3" DtdRelease="0">
    <DocumentIdentification v="MOL_20100331_1500_1600"/>
    <DocumentVersion v="1"/>
    <DocumentType v="A43"/>
    <SenderIdentification codingScheme="A01" v="17X100Z100Z0001H"/>
    <SenderRole v="A35"/>
    <ReceiverIdentification codingScheme="A01" v="10XFR-RTE------Q"/>
    <ReceiverRole v="A04"/>
    <CreationDateTime v="2010-03-31T14:10:00Z"/>
    <ValidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Domain codingScheme="A01" v="10YDOM-1001A001A"/>
    <MolTimeSeries>
    <ContractIdentification v="RTE_20100331_1500_16"/>
    <ResourceProvider codingScheme="A01" v="10XFR-RTE------Q"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YFR-RTE------C"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A02"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.45"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    <MolTimeSeries>
    <ContractIdentification v="RTE_20100331_1500_20"/>
    <ResourceProvider codingScheme="A01" v="10XFR-RTE------Q"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YFR-RTE------C"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A02"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.48"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    <MolTimeSeries>
    <ContractIdentification v="NG_20100331_1500_6"/>
    <ResourceProvider codingScheme="A01" v="10X1001A1001A515"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YGB----------A"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A01"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="17.0"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    </MolDocument>

    Hi,
    The result I got was:
    16RTE_20100331_1500_20NG_20100331_1500_6In the query you tried, you access a single record so you can't expect to get three rows "magically". The EXTRACT function just works as expected, it extracts the requested nodes, but the result is still an XML fragment (a scalar value).
    In order to achieve your goal, you have to break the MolTimeSeries sequence into relational rows.
    Two similar solutions are possible, XMLTable (10gR2 and up) or Table/XMLSequence.
    In your other post you mentioned db version 10.1, so I guess we'll go with XMLSequence :
    SELECT 'RTE'
           ,to_date(substr(extractvalue(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),'yyyy-mm-dd"T"hh24:mi')
           ,decode(extractvalue(x2.column_value,'/MolTimeSeries/Direction/@v'),'A01','Up','Down')
           ,to_number(regexp_substr(extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v'),'\d+$'))
           ,to_number(extractvalue(x2.column_value,'/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
           ,sysdate
           ,null
           ,null
           ,extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v')
           ,'SUBMITTED'
           ,'A96'
           ,null
           ,sysdate
    FROM xml_demo x,
         table(
           xmlsequence(
             extract(x.xml_data, '/MolDocument/MolTimeSeries')
         ) x2
    WHERE existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1;Please also note the use of REGEXP_SUBSTR instead of the regular SUBSTR because it didn't work for "NG_20100331_1500_6".
    Hope that helps.
    Edited by: odie_63 on 24 juin 2010 21:18 - added regexp comment

  • Forms pulling Multiple Records from an XML Schema and XML data files - Adobe LiveCycle Designer

    I built a form in Adobe LiveCycle with an xml schema and data file.  The problem is with how the form renders the xml data file.
    I have a statement element that consists of about 6 fields (statementID, statementName, statementAddress, statementCountry, statementZip, statementDate, etc) of data in the schema that allows for multiple iterations - so one xml data file can contain multiple statements. These fields allow for null values.
    But here's the problem:  When any of the statements - say statement 2 of 6 - has a null value in one of the fields, if the xml data file doesn't have a placeholder
    (example of placeholder:  <statementName type="String"/>   )in the xml for that field, my form pulls the field value from the NEXT statement.
    This corrupts all the rest of the statement records, as this field is shifted up for all the rest.
    I know that in the past I haven't needed a placeholder when a field was null. But I'm wondering if when the data allows for multiple records the xml data file needs to generate the placeholder.  And where is the problem? In the Schema? The xml data file? My form?  And the 64-thousand-dollar question:  How to fix it?

    If your <statement> element is the one that repeats, it should be bound to a subform with the binding string of something like $.statement[*]. Then in that subform should be your fields and they should have bindings of $.statementID, $.statementName, $.statementAddress, etc.
    Kyle

  • Extracting elements from an xml string - org.apache.xerces.dom.DeferredText

    Hello all,
    I am new to xml, and I thought I had a handle on things until I got this problem...I am getting an xml string from the body of an e-mail message, and then I am trying to extract elements out of it. Here is an example xml string:
    <?xml version="1.0" encoding="UTF-8"?>
    <filterRoot>
       <filter action="MOVE" bool="AND" name="My Saved Filter" target="Deleted Items">
          <condition attribute="TO" bool="AND" contains="CONTAINS">
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
          </condition>
       </filter>
    </filterRoot>I am trying to extract the <filter> element out and store it into a Vector of Elements (called, not surprisingly, filters). However, I am getting a class cast exception:
    java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImplIt is being called from where I trying to extract the <filter> in this way:
            filterRoot = doc.getDocumentElement(); // get topmost element
            NodeList list = filterRoot.getChildNodes();
            Vector newFilters = new Vector();
            debug("There are "+list.getLength()+" filters in document");
            for(int i=0; i<list.getLength(); i++) {
                Node n = list.item(i);
                debug("Node "+i+" getNodeValue() is "+n.getNodeValue());
                Element temp = (Element)n;
                newFilters.add(temp);
            }Perhaps my question is, how do I correctly get hold of the <filter> node so that I may cast it as an Element?
    thanks,
    Riz

    Yes, I already knew that it is not a bug.
    But, I got next step problem.
    I put "false" to "include-ignorable-whitespace" feature in xerces parser.
    But, I still found unnecessary TextNodes in my parser object.
    Feature link : http://xerces.apache.org/xerces-j/features.html.
    I use xerces-2_8_0.
    DOMParser parser = new DOMParser();
    parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
    parser.parse(inputSource);
    document = ps.getDocument();
    System.out.println(document.getDocumentElement().getChildNodes().length()); // still wrong lengthIs tehre any example of usage this feature?
    What is default defination of white-space "\n "(enter with one space) or " "(juz white space) or something else?
    Thanks,

  • Extracting data from an XML document that uses namespaces

    Hello all,
    Firstly, please let me wish you all a very happy and prosperous 2013!
    I have a piece of XML containing namespaces (retrieved from a web service) and I am having difficulty extracting values
    (If you're interested this is the webservice: http://api.worldbank.org/countries/FRA/indicators/NY.GDP.MKTP.CD?date=2009)
    Here is some test code with two cases -
    1) where I leave in the namespace and
    2) where I strip out all references to the namespace
    Case 1 doesn't work, whereas Case 2 works well.
    I would prefer a more elegant solution than simply stripping out the namespace.
    I have probably just misunderstood something about how to work with namespaces in PL/SQL.
    Do any of you have suggestions about how best to approach this?
    Many thanks in advance.
    Niall.
    set serveroutput on
    set define off
    DECLARE
    v_xml XMLTYPE;
    v_clob CLOB;
    v_country VARCHAR2(255);
    BEGIN
    v_clob := '<?xml version="1.0" encoding="utf-8"?>
    <wb:data page="1" pages="1" per_page="50" total="1" xmlns:wb="http://www.worldbank.org">
    <wb:data>
    <wb:indicator id="NY.GDP.MKTP.CD">GDP (current US$)</wb:indicator>
    <wb:country id="FR">France</wb:country>
    <wb:date>2009</wb:date>
    <wb:value>2619685000757.11</wb:value>
    <wb:decimal>0</wb:decimal>
    </wb:data>
    </wb:data>';
    v_xml := XMLTYPE(v_clob);
    SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
    INTO v_country
    FROM dual;
    dbms_output.put_line(' ');
    dbms_output.put_line('*** Case 1');
    dbms_output.put_line('*** '||nvl(v_country,'nothing'));
    dbms_output.put_line(v_xml.getStringVal());
    v_xml := XMLTYPE(replace(v_clob,'wb:')); -- strip out wb:
    SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
    INTO v_country
    FROM dual;
    dbms_output.put_line(' ');
    dbms_output.put_line('*** Case 2');
    dbms_output.put_line('*** '||nvl(v_country,'nothing'));
    dbms_output.put_line(v_xml.getStringVal());
    END;
    /

    Your case 1 query should be
    (not tested)
    SELECT extractvalue(v_xml,'/wb:data/wb:data[1]/wb:country', 'xmlns:wb="http://www.worldbank.org/"')If the XML is going to be small, you could also do it this way purely in PL/SQL
    [url http://anononxml.blogspot.com/2010/06/xml-parsing-with-namespaces-via-plsql.html]XML Parsing with Namespaces via PL/SQL. Ignore the DOMDocument examples (first two) in there.
    If the XML will be large and you are on 11.1 or greater, then it would be faster to insert the XML into a column in a DB table (could be a global temporary table) where the column is XMLType and the storage is SECUREFILE BINARY (default on 11.2.0.2+). Then you could use XMLTable, like
    [url http://anononxml.blogspot.com/2010/08/xml-parsing-with-namespaces-via.html]XML Parsing with Namespaces via XMLTable 

  • Extracting records from 3 tables using joins in MySQL

    Hi All,
    Pls help me urgently...
    I have a n Order Processing Module and I have 4 tables for this.
    When a new order is placed these 2 tables are populated.
    Order_Customer : records details abt the direct customer/dealer who places the order.
    Order_Product : records the details abt the product (qty, unit price, taxes etc).
    At the Supplier's end the newly placed orders are accepted or rejected and notification is passed on to the despatch dept.
    No when Acceptance authority logs in all the new orders should be viewed..all the previously accepted orders should not be displayed. Here OrderId, OrderDate, Cust/Deal Name (from Order_Customer) and Product, Qty, OrdValue (from Order_Product) are to be displayed. My normal join qry does not work here
    "SELECT * FROM Order_Customer,Order_Product where Order_Customer.OSerialNo NOT IN (SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Product.OrdCustSrNo NOT IN (SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Customer.OSerialNo=Order_Product.OrdCustSrNo"
    This gives an error "Unable to load driver.java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Product.OrdCustSrNo NOT IN (' at line 1 "
    Also tried
    "SELECT Order_Customer.* FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo where Order_Acceptance.OrdCustSrNo IS NULL";
    Here it gives error Column Name Product not found.
    Similar is the case when moving an Accepted Order to Despatch Dept.
    Need help urgently.

    "SELECT Order_Customer.* FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo where Order_Acceptance.OrdCustSrNo IS NULL";
    I think the above query has syntax error. for try with this
    "SELECT * FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo and Order_Acceptance.OrdCustSrNo IS NULL";

  • Picking up the corresponding records from the xml.

    Hi All,
    I want to create a xsl file which will give on line results as and when i selects the criteria.
    Do any of you have any code which clarifies how this is done?
    Regards,
    Kulkarni
    null

    You unfortunately don't provide enough specifics to directly suggest something, but you might want to check out the Building Oracle XML Applications for lots of examples in this general area of functionality.
    If you post more specific info, we might be able to suggest something more specific.
    Thanks.

  • How to parse and retrieve records from xml files into columns in Table

    Hi
    I attached the thing what i tried.
    Table to hold the XML COntent:
    create table xmlfile(xml_con sys.xmltype);
    Inserting Xml file content into the Above table:
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><name>RAM</name><age>23</age></Root>'))
    SQL> select * from xmlfile;
    XML_CON
    <Root>
    <name>RAM</name>
    <age>23</age>
    </Root>
    SQL> select extractValue(xml_con, '/Root/name') content from xmlfile;
    CONTENT
    RAM
    This one works fine
    But if the file content is as below( contains MUltiple Records)
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><Record><name>RAM</name><age>23</age></Record><Record><name>SAM</name><age>23</age></Record></Root>'))
    SQL> select extractValue(xml_con, '/Root/Record/name') content from xmlfile;
    ERROR at line 1:
    ORA-19025: EXTRACTVALUE returns value of only one node
    Can anyone help me 4 this issue-How to extract multiple records from the XML file inthis manner(from PL/SQL without using JAVA)
    OR
    If there is anyother way to do this please tell me?

    SQL> SELECT EXTRACTVALUE (COLUMN_VALUE, '//name') NAME,
           EXTRACTVALUE (COLUMN_VALUE, '//age') age
      FROM TABLE
              (XMLSEQUENCE
                  (EXTRACT
                      (XMLTYPE
                          ('<Root>
                              <Record>
                                <name>RAM</name>
                                <age>23</age>
                              </Record>
                              <Record>
                                <name>SAM</name>
                                <age>23</age>
                              </Record>
                            </Root>'
                       '/Root/Record'
    NAME       AGE      
    RAM        23       
    SAM        23       
    2 rows selected.

  • How to show records from xml file

    HI All
    I have created one region its actually search region
    which having 5 items and result table region
    I want to search records based on that 5 items and want to show output in table
    I have table name as hr_api_transactions which contains lot of columns
    and that table also contain one column
    name as TRANSACTION_DOCUMENT of type CLOB()
    that columns xml files for each record
    I want to extract data from that xml file and want to display.

    I have created one region on seeded page
    in that region I have created one table for output
    that region is search region
    which having 5 items of textfield and 2 items of type submit button
    GO and Clear
    I want to search based on that 5 items
    I want to display records in table that I have created on that region
    I have one seeded table
    that contain one column
    that column contain xml file for each individual records
    that xaml file contains values what I want to display
    MY problems are
    how can I extract data from xml file?
    how can I show all values for each records on that table?
    how can I search based on that 5 items?
    now I am able to find out single value from that XML file
    by using SQL command
    select xmltype(transaction_document).extract('//IrcPostingContentsVlEORow/CreationDate/text()').getStringVal() CreationDate
    from hr_api_transactions
    where transaction_ref_table = 'PER_ALL_VACANCIES'
    and transaction_ref_id = 4693;how can I extract more than one records from that XML file

  • Is it possible to extract the xpath for fields from a XML file

    Hi,
    After all we do the recording to capture the xpath of the fields, so i thought of extracting xpath from a XML file will be a good idea.
    Is there a way to do this?
    Please suggest
    regards
    Suresh

    Yes, there is.  Go to the Tools menu -> Generate XPaths and load in your xml file.  Select the element you are interested in and you will get the XPath to utilise.
    Regards,
    Jamie

Maybe you are looking for

  • The DRIVERS on my HP Pavilion dv7-6c95dx WON'T INSTALL DEVICES.

    Please if anyone knows how to fix this i will appriciate all the help,  a few months back I did a a hard reset on the laptop and since then the drivers always acted weird when i tried plugging in my ipod or phone but i didnt pay it any mind now the d

  • Reader 8.1.2 installs but will not launch

    I am unable to launch any Adobe Reader above 6.0 under WINXP. My install appears to go flawlessly. When finished, there is a new Adobe reader Icon on the desktop and all pdf apps have become associated. Regardless of whether I try to launch a pdf, or

  • Max number of Hits Account Identification

    Hi all, we are currently having the problem in IC that when somebody try to identify an account of an BP with more that 100 related sold to parties, that no account is displayed because of the standard max number of hits 100. I have found the path to

  • Lenovo Thinkpad T60 - 1952 Screen problems

    Hello! I have Thinkpad T60 and i have a little problem: Sometimes my screen blinks and turns blue or pink or black. And when i press the "FN+F7" the T60 screen get output to both LCD and External display even tho there is no display plug in! and the

  • How to populate an array with random text files.

    I am making a Jeopardy program. I have my program set up so that it retrieves 5 random text files. I just want to know how I populate one array with all the lines from the text files my program is retrieving.