Parse XML into relational view?

Hi All,
In the xml doc below, how can I extract value of lineNumber attribute of <item> tag? The query as it stands returns correct rows but it is missing line number.
Thanks!
select
extract(value(xml), '/Segment/@type').getStringval() att_name,
extract(value(xml), '/Segment/@id').getStringval() att_value,
extract(value(xml), '/item/@lineNumber').getNumberVal() att_line -- does not work!
from table(xmlsequence(
extract(xmltype('<?xml version="1.0" encoding="utf-8" ?>
<Header>
<item lineNumber = "1">
<Segment type="Action" id="Add" description="Action" />
<Segment type="Business Owner" id="John Doe" description="Business Owner" />
<Segment type="Catalog Item Ordered" id="20677765" description="Catalog Item Ordered" />
<Segment type="Asset Tag" id="0060123" description="Asset Tag" />
</item>
<item lineNumber = "2">
<Segment type="Action" id="Add" description="Action" />
<Segment type="Business Owner" id="Jane Doe" description="Business Owner" />
<Segment type="Catalog Item Ordered" id="20688865" description="Catalog Item Ordered" />
<Segment type="Asset Tag" id="0061444" description="Asset Tag" />
</item>
</Header>'), '/Header/item/Segment')
)) xml;
Message was edited by:
user521497

Here's you go
SQL> set pages 20 lines 150
SQL> --
SQL> var xmltext varchar2(4000)
SQL> --
SQL> begin
  2    :xmltext :=
  3  '<?xml version="1.0" encoding="utf-8" ?>
  4  <Header>
  5    <item lineNumber = "1">
  6      <Segment type="Action" id="Add" description="Action" />
  7      <Segment type="Business Owner" id="John Doe" description="Business Owner" />
  8      <Segment type="Catalog Item Ordered" id="20677765" description="Catalog Item Ordered" />
  9      <Segment type="Asset Tag" id="0060123" description="Asset Tag" />
10    </item>
11    <item lineNumber = "2">
12      <Segment type="Action" id="Add" description="Action" />
13      <Segment type="Business Owner" id="Jane Doe" description="Business Owner" />
14      <Segment type="Catalog Item Ordered" id="20688865" description="Catalog Item Ordered" />
15      <Segment type="Asset Tag" id="0061444" description="Asset Tag" />
16     </item>
17  </Header>';
18  end;
19  /
PL/SQL procedure successfully completed.
SQL> --
SQL> select extractValue(value(seg), '/Segment/@type') att_name,
  2         extractValue(value(seg), '/Segment/@id') att_value,
  3         extractValue(value(item), '/item/@lineNumber') att_line
  4    from table(xmlsequence(extract(xmltype(:xmltext), '/Header/item'))) item,
  5         table(xmlsequence(extract(value(item), '/item/Segment'))) seg
  6  /
ATT_NAME
ATT_VALUE
ATT_LINE
Action
Add
1
Business Owner
John Doe
1
Catalog Item Ordered
20677765
1
Asset Tag
ATT_NAME
ATT_VALUE
ATT_LINE
0060123
1
Action
Add
2
Business Owner
Jane Doe
2
Catalog Item Ordered
20688865
ATT_NAME
ATT_VALUE
ATT_LINE
2
Asset Tag
0061444
2
8 rows selected.
SQL> select seg.ATT_NAME, seg.ATT_VALUE, item.ITEM_NUMBER
  2    from xmltable
  3         (
  4           '/Header/item'
  5           passing xmltype(:xmltext)
  6           columns
  7           ITEM_NUMBER number(2) path '@lineNumber',
  8           SEGMENT_XML xmltype path 'Segment'
  9         ) item,
10         xmltable
11         (
12           '/Segment'
13           passing item.SEGMENT_XML
14           columns
15           ATT_NAME  varchar2(32) path '@type',
16           ATT_VALUE varchar2(32) path '@id'
17         ) seg
18  /
ATT_NAME                         ATT_VALUE                        ITEM_NUMBER
Action                           Add                                        1
Business Owner                   John Doe                                   1
Catalog Item Ordered             20677765                                   1
Asset Tag                        0060123                                    1
Action                           Add                                        2
Business Owner                   Jane Doe                                   2
Catalog Item Ordered             20688865                                   2
Asset Tag                        0061444                                    2
8 rows selected.
SQL>

Similar Messages

  • How to Parse XML into String in BPEL?

    Hi,
    Can anyone tell me, how can I parse XML into String?
    I am taking input from File Adapter, File adapter is reading that XML.
    Then in assign activity i am using XPath expression(built functions) using XMLParser(),doTranslateToNative() etc.. many functions I have tried but XML is not getting parsed into String Variable.
    Please help me asap.
    Thanks
    Shikha

    Thanks a lot Eric.
    I am trying this, oraext:get-content-as-string('receiveInput_Read_InputVariable','body','/ns3:orders')
    but getting this error
    <bpelFault><faultType>0</faultType><subLanguageExecutionFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is oraext:get-content-as-string('receiveInput_Read_InputVariable','body','/ns3:orders'). The XPath expression failed to execute; the reason was: internal xpath error. Check the detailed root cause described in the exception message text and verify that the XPath query is correct. </summary></part><part name="code"><code>XPathExecutionError</code></part></subLanguageExecutionFault></bpelFault>

  • Loading xml into relational tables.

    I was wondering if anyone knows of a product/libraries which does the following:
    -Read data from a relational Database (multiple tables) and generate XML files based upon an XML Schema or DTD file?
    -Read XML files and load data into a relational Database.
    -Graphical Interface for performing the maps (perhaps based upon .xslt). ie.... Mapping of the XML Schema to Multiple Database Tables, Performing Joins etc...
    -Ability to connect to any type of Relational database (not just Oracle). Which rules out XML DB.

    This product does look to be ok, however it is missing a couple features that I would like the product to have.
    I would like this product to be able to insert/update data across multiple tables. Being able to do such things as generate foreign key relationships.
    It doesn't seem as though the XML being generated can be customized very easily. Some XML formats I deal with are very complex (such as X12/EDI).
    I would really like a graphical mapper.
    Here is a note from the doc:
    Storing XML Data Across Tables
    Currently the XML SQL Utility (XSU) can only store data in a single table. It maps a canonical representation of an XML document into any table or view. But there is a way to store XML with XSU across tables. You can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (using object views if needed) and then do the insertions into the view. If the view is inherently non-updatable (because of complex joins), then you can use INSTEAD OF triggers over the views to do the inserts.
    This product looks really good, I was hoping that Oracle had something comparable:
    http://www.hitsw.com/products_services/xml_platform/allora.html

  • Convert XML to relational view

    WE are retrieving data using Web Services, i.e. using SOAP protocol and receiving data in XML format.
    We need to access this data using a normal relational view, but can not find a solution how to do this.
    Example:
    The returned XML is a invoice with 2 lines. We want to create 2 distinct views, one for the invoice header and one for the lines, i.e. it must return 2 rows.
    How is this possible?

    You can create a relational view using extract() and extractValue() SQL operators on the underlying XMLType data. Also, the XMLSequence() operator can be used to generate the view for lines.
    See XML DB Developer's Guide for further details.

  • Inserting data into relational views of object tables

    I hope someone could help me to solve the following problem:
    I would like to design an object-relational database in O8i. Unfortunatly the client-software (GIS) can only understand relational data (except the object type 'geometry'). So I created relational views on my object tables. But now it is not possible to insert data in those views. Do I have to create triggers on those views for inserting data ???
    Nevertheless: Updating data in views makes no problems.
    Thank you for reading this and I look foreward to hearing from you soon.
    Christian Heil

    Hi Mohammed,
    I guess following is your requirement
    List1 tile is attached to "BOList1". On button press you wanted the data to be persisted to Business object "BOList1History"
    I assume that you have created "BOLIst1History" properly by associating a write Bdoc etc etc.
    Write a method in Business object "BOList" called ZUpdateHistory. This new method should contain code for creating an instance of "BOLIST1History" and fill the property values as per your requirement. Call this method from the Button press event as follows
    anchor.bo.ZUpdateHistory
    Hope this helps
    Regards
    Ganesh Datta

  • Problem inserting XML into object view

    Hi all,
    My environment is :
    Windows NT 4.0
    Oracle 8i 8.1.5
    (NLS_CHARACTERSET = EL8MSWIN1253)
    Apache 1.3.11 Web Server
    Apache JServ 1.1
    XSQL v 0.9.9.1 and XML parser for Java v2,
    XMLSQL that come with it
    I've created an object view as following :
    create table schedules (
    schedule_id varchar2(20),
    description varchar2(100),
    constraint pk_schedule_id primary key (schedule_id)
    create table schedule_details (
    schedule_id varchar2(20),
    starting_time date,
    duration number,
    constraint pk_schedule_dtls primary key (schedule_id, starting_time),
    constraint fk_schedule_id foreign key (schedule_id) references schedules (schedule_id)
    create or replace type schedule_detail_t as object (
    starting_time varchar2(20),
    duration number
    create or replace type schedule_detail_list as table of schedule_detail_t;
    create or replace type schedule_details_t as object (
    schedule_id varchar2(20),
    description varchar2(100),
    details schedule_detail_list
    create or replace view schedule_details_view of schedule_details_t
    with object OID (schedule_id)
    as select schedule_id, description,
    cast(multiset(select schedule_detail_t (to_char(starting_time, 'hh24:mi'), duration) as Detail
    from schedule_details
    where schedule_details.schedule_id = schedules.schedule_id
    ) as schedule_detail_list )
    from schedules;
    And I'm trying to insert using putXML this
    <?xml version = "1.0" encoding = "ISO-8859-1"?>
    <ROWSET>
    <ROW>
    <SCHEDULE_ID>S1112</SCHEDULE_ID>
    <DESCRIPTION>Working 08:00 to 20:00</DESCRIPTION>
    <DETAILS>
    <DETAILS_ITEM>
    <STARTING_TIME>08:00</STARTING_TIME>
    <DURATION>12</DURATION>
    </DETAILS_ITEM>
    </DETAILS>
    </ROW>
    </ROWSET>
    The error I get is
    oracle.xml.sql.OracleSQLXMLException:
    non supported oracle-character-set-174
    Note: no rows have been inserted
    at oracle.xml.sql.dml.OracleXMLSave.insertXML
    When I'm posting using XSQL the XML doesn't get inserted with no error message.
    But when I try this for a change
    <?xml version = "1.0" encoding = "ISO-8859-1"?>
    <ROWSET>
    <ROW>
    <SCHEDULE_ID>S1111</SCHEDULE_ID>
    <DESCRIPTION>Working 08:00 to 20:00</DESCRIPTION>
    </ROW>
    </ROWSET>
    Trying to insert into table (this time) "schedules" using putXML it works ...
    It works on tables and it doesn't work on object views.
    Any piece of advice will be highly appreciated.
    Nick

    No known limitations. Please post the sample DDL to create your object types and object view, along with an example of the example XML document you're trying to insert.

  • How do I implement an HTTP Get which returns XML into a View Object?

    I've got a 3rd party program which accepts an HTTP GET and returns information via XML. I'd like to take that XML and then populate a View Object.
    The examples given in the manual are only for JavaScript with an AJAX server that I don't have. Here's an example:
    function UpdateNow() {
         var req = new Ajax.Request("qbwc://docontrol/
         UpdateNow?async=true&AppName=WCWebService3", {method:'get',
         onSuccess:processDataOne, onFailure:reportError});
    }I've been to literally dozens of sites trying to answer my question, but I'm just not knowledgeable enough to know where to start. Can someone point me in the right direction?
    Using JDev 11.1.1.6
    Thanks,
    Will

    I guess the basics would be:
    Create a Java class that reads from the URL of the service:
    http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html
    Then get the XML that you read into the ADF BC VO using the readXML method of the VO.
    Example 18 here: https://blogs.oracle.com/smuenchadf/resource/examples#18

  • Parsing XML into Array problem

    my previous problem had turned slightly into a different
    issue;
    basically now when i trace the variables i'm getting
    undefined. Any help is great appreciated. Thanks!

    >>description
    = award.secondChild.nodeValue
    there is no such thing as secondChild.
    >>image = new Array(images.length);
    Where is image defined initially? You can't just use an index
    like that if
    image isn't already an array.
    I would suggest changing the structure a little. An array of
    award objects
    might work well.
    var allAwards = new Array();
    var award = new Object();
    award.caption = "my caption";
    award.images = new Array();
    allAwards.push(award);
    Then you can do like:
    trace(allAwards[0].caption);
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Load XML Document/Data into relational Table

    Hi All,
    I have a requirement to load data in an XML file into an oracle db and subsequently split the contents into columns in an oracle table. This has to be done on the command line from a unix box which connects to a remote oracle DB.
    Can some one give me a step by step procedure to do this or point me in the right direction.
    thank you

    Hi,
    There can be many different way we can achieve this. Mainly depending on size of XML, complexity of XML and your use of that data (e.g. you just want to insert XML into relational or you want to write something and the generate new xmls later on).
    If you go to Oracle online documentation -> Oracle XML DB Developer's guide, first 3-4 chapters will give you what you need.
    Regards

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • Best way to transfer a List Object into a view object?

    Hi Guys and Gals,
    I'm working with some 3rd party code. This code queries a 3rd party database and returns the data into a List like so:
            PlatformSessionContext context = webutils.getPlatformContext(accesstoken,accessstokensecret,realmID,dataSource);
         QBCustomerService customerService = customerService = QBServiceFactory.getService(context, QBCustomerService.class);
         List<QBCustomer> customers = customerService.findAll(context, 1, 100);What is then the best way to populate a view object with that list? I would think I would need to do a couple of things ...
    1) Map the QBCustomer's fields/getters to my ViewObject attributes somehow ...
    2) Iterate through the List and sync the QBCustomer field values to the VO rows/attributes.
    Am I on the right track? What do you think is the best way to accomplish this? I've come across populating a VO via XML here (How do I implement an HTTP Get which returns XML into a View Object? ). Should I look for this QBCustomer.class's query and XML?
    This is all a little over my head. Any help would be appreciated. Using JDev 11.1.2.2.0.
    Thanks,
    Will

    Hi,
    bets is to do it similar as in https://blogs.oracle.com/smuenchadf/resource/examples#134
    In this sample, a list of selected keys is passed to a custom method exposed on the ViewObject. In your case you need to make sure the QBCustomer class is known by the ADF BC project. Then from the custom method, you create new rows in the VO and populate the attributes with values from the QBCustomer object. The method can be dragged from the data control palette (as a parameter form) or manually create in the PageDef (method binding). The latter case requires you to reference an object holding the list of QBCustomer
    Frank

  • Changing flat XML into nested

    I'm working on a tree navigation that needs to have some data provided in a nested xml format
    <node label="California">
         <node label="location 1" />
         <node label="location 2">
              <node label="option 1" />
              <node label="option 2" />
         </node>
    </node>
    But the data that I'm getting (and probably can't change) is coming out flat:
    <item>
         <id>12</id>
         <label>California</label>
    </item>
    <item>
         <id>15</id>
         <label>location 1</label>
         <parent>12</parent>
    </item>
    <item>
         <id>17</id>
         <label>location 2</label>
         <parent>12</parent>
    </item>
    <item>
         <id>33</id>
         <label>option 1</label>
         <parent>17</parent>
    </item>
    <item>
         <id>70</id>
         <label>loption 2</label>
         <parent>17</parent>
    </item>
    Any suggestions on how to change that data from what I'm supplied to what I need? Is it just a brute force looping through the xml nodes a bunch of times? Or is there a clever way that I'm not seeing?

    If you are sure about data integrity, especially ids relationships, the following is one of the ways to reposition nodes without changing general node structure. Following this logic you can restructure XML altogether.
    With that said, I am not sure XML restructuring is the best way to go anyway. I feel a much better solution would be to parse XML into a more native to AS3 structure like Array, Object or Vector. I would rather create a specialized data provider class.
    Example uses the following XML:
    <items>
        <item>
            <id>1</id>
            <label>California</label>
        </item>
        <item>
            <id>2</id>
            <label>California location 1</label>
            <parent>1</parent>
        </item>
        <item>
            <id>3</id>
            <label>California location 1 option 1</label>
            <parent>2</parent>
        </item>
        <item>
            <id>4</id>
            <label>California location 1 option 2</label>
            <parent>2</parent>
            </item>
        <item>
            <id>5</id>
            <label>California location 1 option 3</label>
            <parent>2</parent>
        </item>
        <item>
            <id>6</id>
            <label>California location 2</label>
            <parent>1</parent>
        </item>
        <item>
            <id>7</id>
            <label>California location 2 option 1</label>
            <parent>6</parent>
        </item>
        <item>
            <id>8</id>
            <label>California location 2 option 2</label>
            <parent>6</parent>
        </item>
        <item>
            <id>9</id>
            <label>New York</label>
        </item>
        <item>
            <id>10</id>
            <label>New York location 1</label>
            <parent>9</parent>
        </item>
        <item>
            <id>11</id>
            <label>New York location 1 option 1</label>
            <parent>10</parent>
        </item>
        <item>
            <id>12</id>
            <label>New York location 1 option 1</label>
            <parent>10</parent>
        </item>
    </items>
    Code that parses this xml is (given the value of the xml above is assigned to var xml:XML
    var parent:XMLList;
    for each (var node:XML in xml.item)
        if (node.parent.toString() != "")
            parent = xml.item.(id == node.parent.toString());
            if (parent.parent.toString() == "")
                parent.@["type"] = "top";
            node.@["type"] = "child";
            parent.appendChild(node);
    xml = new XML(xml.toString());
    while (xml.item.(@type == "child").length() > 0)
        delete xml.item.(@type == "child")[0];
    trace(xml);
    Output is:
    <items>
        <item type="top">
            <id>1</id>
            <label>California</label>
            <item type="child">
                <id>2</id>
                <label>California location 1</label>
                <parent>1</parent>
                <item type="child">
                    <id>3</id>
                    <label>California location 1 option 1</label>
                    <parent>2</parent>
                </item>
                <item type="child">
                    <id>4</id>
                    <label>California location 1 option 2</label>
                    <parent>2</parent>
                </item>
                <item type="child">
                    <id>5</id>
                    <label>California location 1 option 3</label>
                    <parent>2</parent>
                </item>
            </item>
            <item type="child">
                <id>6</id>
                <label>California location 2</label>
                <parent>1</parent>
                <item type="child">
                    <id>7</id>
                    <label>California location 2 option 1</label>
                    <parent>6</parent>
                </item>
                <item type="child">
                    <id>8</id>
                    <label>California location 2 option 2</label>
                    <parent>6</parent>
                </item>
            </item>
        </item>
        <item type="top">
            <id>9</id>
            <label>New York</label>
            <item type="child">
                <id>10</id>
                <label>New York location 1</label>
                <parent>9</parent>
                <item type="child">
                    <id>11</id>
                    <label>New York location 1 option 1</label>
                    <parent>10</parent>
                </item>
                <item type="child">
                    <id>12</id>
                    <label>New York location 1 option 1</label>
                    <parent>10</parent>
                </item>
            </item>
        </item>
    </items>

  • Insert XML file into Relational database model without using XMLTYPE tables

    Dear all,
    How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
    I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
    However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
    We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
    The database does and will not contain XMLTYPES, only plain RDBMS tables.
    Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
    Constraints : Input via XML files defined by third party
    Storage : relational database model with hundreds of tables and thousands of existing queries that can not be touched. The model must not be altered.
    Target : get this XML into the database on a daily basis via an automated process.
    Cheers.
    Luc.

    Luc,
    your Doomed !
    If you would try something like DBMS_XMLSTORE, you probably would be into serious performance problems in your case, very fast, and it would be very difficult to manage.
    If you would use a little bit of XMLType stuff, you would be able to shred the data into the relational model very fast and controlable. Take it from me, I am one of those old geezers like Mr. Tom Kyte way beyond 40 years (still joking). No seriously. I started out as a classical PL/SQL, Forms Guy that switched after two years to become a "DBA 1.0" and Mr Codd and Mr Date were for years my biggest hero's. I have the utmost respect for Mr. Tom Kyte for all his efforts for bringing the concepts manual into the development world. Just to name some off the names that influenced me. But you will have to work with UNSTRUCTURED data (as Mr Date would call it). 80% of the data out there exists off it. Stuff like XMLTABLE and XML VIEWs bridge the gap between that unstructured world and the relational world. It is very doable to drag and drop an XML file into the XMLDB database into a XMLtype table and or for instance via FTP. From that point on it is in the database. From there you could move into relational tables via XMLTABLE methods or XML Views.
    You could see the described method as a filtering option so XML can be transformed into relational data. If you don't want any XML in your current database, then create an small Oracle database with XML DB installed (if doable 11.1.0.7 regarding the best performance --> all the new fast optimizer stuff etc). Use that database as a staging area that does all the XML shredding for you into relational components and ship the end result via database links and or materialized views or other probably known methodes into your relational database that isn't allowed to have XMLType.
    This way you would keep your realtional Oracle database clean and have the Oracle XML DB staging database do all the filtering and shredding into relational components.
    Throwing the XML DB option out off the window beforehand would be like replacing your Mercedes with a bicycle. With both you will be able to travel the distance from Paris to Rome, but it will take you a hell of lot longer.
    :-)

  • Load XML data from UNIX Server Directly into Relational Database Tables

    Is there a way I can load data from an XML File into Oracle Tables , without having the Input XML file in some Oracle Server Directory. My XML File resides on UNIX Application server. And I need to directly load the data into Database tables. Without loading them into the Database Directory.
    Also I am looking for a solution that would not load my Database much and effect other running processes. Can it be done using SQL Loader ?
    Oracle Database Version is : Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

    Thanks for your reply ,
    Please would you quote an Example about : 'Load the file into that table using SQL*Loader'  (From UNIX Server) Or instance of some existing thread that relates to my situation.
    The Size of the File would be about 3 GB. For a similar requirement one of my peers Code which used XMLTABLE and XPATH Approach consumed a lot of resources while running and caused the other Database Applications to slow down. Thus those guys have come up with an approach to :
            Parse XML using a C Code using some STRING Functions =>  For a CSV or Fixed width .dat file and then use SQL Loader to just load the file into Tables.
            This approach is efficient in terms of Resources and Time(Takes 5 mins). But I am not confident about parsing XML based on String based C Functions.
             Please comment about this approach . Also if possible Suggest the best efficient way of doing this.

  • Reading XML file from specific location&Storing xmldata into related tables

    I am new to xml.
    My requirement is,
    1) Get the xml file from specified location (C:\xmlfiles\ xmldata.xml)
    2)Convert xml data in clob data.
    3)store the data into related table.
    and vice-versa.
    What i did,
    a) I got the data from related tables and converted into xmlformat using SQLX
    b)converted this resultset into clob data and stored as xml file in specific location.
    It uses more then ten tables.
    All this help i got from AskTom site , thanks for that.
    Now i have to do vise-versa, i.e. i have to perform 1), 2), 3) steps........
    Please tell me proper steps to acheive it.
    Thanks in advance for giving your precious time to solve my issue.

    Have you read the"XMLDB FAQ" in this Forum?
    You could use stuff like:
    create or replace directory xmldir as C:\xmlfiles'
    declare
    xmldata xmltype;
    begin
    xmldata := xmltype(bfilename('XMLDIR','xmldata.xml'),nls_charset_id('AL32UTF8'));
      -- etc, etc your code --
      -- --> convert to clob by using for instance getclobval() function
      -- --> then insert the data in your relational table with CLOB column
      -- etc, etc your code --
    end;
    /

Maybe you are looking for

  • Having trouble setting up Time capsule...

    I just bought a new iMac last night. I also picked up Time Capsule and Apple TV. I'm having a problem setting up Time Capsule correctly. I'll go through what I did step by step and hopefully someone can help me as I've never tried to set up a wireles

  • Two Separate Billing Documents created in the collec Billing through VF04

    Dear  Forum Friends, I am doing the collective Billing through VF04 for two deliveries (80015032 and 80015034) of the same day. When I am finding in VF05 it has been observed that Two Billing documents instead of one billing document have been create

  • Error Java System: unknow error of portal comunication

    Hi All! I get the following error when opening a WAD Template in the WAD Application. <b>"Error Java System: An unknow portal comunication error has ocurred"</b> After accept this error, it opens the template and I can work with it, but when I make c

  • MacBookPro OS X 10.4.6 Crashes.

    So I left my TWO WEEK OLD MacBookPro sit on the table and run iChat ... I leave it for a while, and I see the screen's black. I think it's just asleep, so I wake it up with a light tap on the power button (which usually wakes it right up!) .. but no,

  • Specific process with all effects in Layer

    Hi, I'm new here and my english is not perfect... For information, we have created a powerful board with many CPU on it for rendering many effect with less time. I have create Plug-ins for test 1 effect and it's working properly. Now I try to ask Aft