Click here to Skip to main content
15,887,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts

I have a .XSD file and registered into the Oracle XMLDB repository. I would like to create a table conforming to the XSD structure and insert records in that and retrieve the output in a XML format.

The following is an example of an XML schema definition, po.xsd:

<schema targetnamespace="http://www.oracle.com/PO.xsd" xmlns:po="http://www.oracle.com/PO.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
<complextype name="PurchaseOrderType">
<sequence>
<element name="PONum" type="decimal">
<element name="Company">
<simpletype>
<restriction base="string">
<maxlength value="100">



<element name="Item" maxoccurs="1000">
<complextype>
<sequence>
<element name="Part">
<simpletype>
<restriction base="string">
<maxlength value="1000">



<element name="Price" type="float">





<element name="PurchaseOrder" type="po:PurchaseOrderType">


Example XML Document, po.xml Conforming to XML Schema, po.xsd

The following is an example of an XML document that conforms to XML schema po.xsd:

<purchaseorder xmlns="http://www.oracle.com/PO.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.oracle.com/PO.xsd
http://www.oracle.com/PO.xsd">
<ponum>1001
<company>Oracle Corp
<item>
<part>9i Doc Set
<price>2550



Please could anyone advise how to achieve the about result with an simple example?

Thanks.

What I have tried:

I have registered the following schema in Oracle but not sure how to create Object relational data, insert some values and retrieve the output in XML format.

begin
insert into po_tab values (1,
xmltype('<po:purchaseorder xmlns:po="http://www.oracle.com/PO.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.oracle.com/PO.xsd
http://www.oracle.com/PO.xsd">
<ponum>1001
<company>Oracle Corp
<item>
<part>9i Doc Set
<price>2550

<item>
<part>8i Doc Set
<price>350

'));
commit;
end;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900