I am going to receive XML-documents like this one (header not shown and with many set of orders) :
<order>
<Orderid> 10 </Orderid>
<Orderdate> 01-AUG-2011 </Orderdate>
<Customerid> 123 </Customerid>
<Deliverancedate> 05-08-2011 </Deliverancedate>
<Orderlines>
<Orderline>
<Itemid> 45 </Itemid>
<Numbers_of_items> 5 </Numbers_of_items>
<Priceprunit> 12.5 </Priceprunit>
</Orderline>
<Orderline>
<Itemid> 46 </Itemid>
<Numbers_of_items> 7 </Numbers_of_items>
<Priceprunit> 25 </Priceprunit>
</Orderline>
</Orderlines>
</order>
… next order
The XML-document is places in this table
Create table TAB_XML as
(xmlid number(10)
XMLFIELD clob);
I have two tables like this:
Create table Order_header as
Orderid number (10),
Orderdate date,
Customerid number(10),
Deliverancedate date;
Create table order_line as
Orderid number(10),
Itemid number(10),
Numbers_of_items number(10),
Priceprunit number(10,2)
I need this:
1: A corresponding XSD
2: A PL/SQL procedure called with an xmlid-value that get the xml-document from the clob-field in the table, validate the xml and unpack / parse the XML-Doc to the corresponding tables. I do not want a solution using searching for a string and getting substrings etc, but a solution using the XSD and standard Oracle features for handling and parsing XML, while the solutions will be used in a bigger setup.
To be used in Oracle 10G versions and up.
I am currently working on an Oracle web serives project with similar XML parsing requirements. Should take me a total of two hours or less. I can generate the XSD for you initially if you need some sort of proof of concept. Beyond that, I can create your procedure to extract the clob and use inherent XML functions to insert into tables. Only tricky part is splitting the XML document across two tables. But can select corresponding elements when calling insert.
I do have one question to ensure there are no character issues ... what National Character set is your Oracle instance using?
Thanks for your consideration and let me know if I can answer any questions or provide any further proof-of-concepts.
Brian