How to generate XML from relational data : PL/SQL or Java

I'm new to Oracle XML and would appreciate some advice. I've been asked to generate XML documents from data stored in relational tables. The XML documents must be validated against a DTD. We will probably want to store the XML in the database.
I've seen a PL/SQL based approach as follows :
1.Mimic the structure of the DTD using SQL object types 2.Assign the relational data to the object type using PL/SQL as required
3.Use the SYS_XMLGEN package to render the required XML documents from the SQL objects
However, creating the object types seems to be quite time consuming (step 1 above) for anything other than the simplest of XML documents.
I've also seen that there is the Java based approach, namely :
1. Use the XML generator to build Java classes based on a DTD.
2. Use these classes to build the required XML
On the face of it, the Java based approach seems simpler. However, I'm not that familiar with Java.
Which is the best way to proceed ? Is the PL/SQL based approach worth pursuing or should I bite the bullet and brush up my Java ?
Is it possible to use a combination of PL/SQL and Java to populate the dtd generated java classes (step 2 of the Java approach) to reduce my learning curve ?
Thanks in advance

To help answer your questions:
1) Now, in 9iR2, you can use SQL/XML as another choice.
2) You can also use XSU to generate the XML and use XSLT to transform it to a desired format instead of using object views if possible.
3) XDK provide Class generator support to populate XML data to Java classes.

Similar Messages

  • How to generate XML from EBusiness suite ARXSGPO

    Could someone tell me how I can generate XML from the EBusiness Suite Accounts Receivable report ARXSGPO.rdf I understand this report is called by a C program. I have tried changing the concurrent request to output format to XML the result does not resemble XML. Does anyone have any suggestions how I can generate XML from the ARXSGPO report?
    Thanks,
    Mark

    Hi Mark
    the next release of XMLP will have last page only support. The problem is that at the template layer you do not know how many lines are going to fit on the page, so you never know what is going to be the last page. The only way around it for now is to specify the number of lines to a page and then check when all the lines have been rendered and then render the remit portion.
    I have a sample invoice that does the same, drop me a mail, you can work out the email from my name and the fact I work for XMLP Im sure.
    Tim

  • Building XML from relational data

    I need to create XML documents from relational data that conforms to an XML schema document. We need to store and query the XML documents we create.
    Therefore, we have decided to store the XML using the object model rather than as a CLOB
    i.e. register the schema with the XML DB which in turn creates the tables and object types that represent the schema.
    What is the best way build the XML document from the relational data ??
    Can I pass the relational data to the default constructors of the object types created by the schema registration ?? (and then create an XML document from the top level object instance using SYS_XMLGEN)
    Or should I build the xml from strings using XMLELEMENT,XMLFOREST built-in's when retrieving the data from the relational tables ?? OR use the XMLDOM package to build the document ??
    Would appreciate any advice on the best approach.

    There are basically two ways to join your document fragments with SQLX:
    1/. With xmlForest
    e.g. SELECT XMLELEMENT ( "Emp",XMLForest(e.employee_id, e.lname, e.salary)) AS "result"
    FROM employees e WHERE employee_id > 1500 ;
    result
    <Emp>
    < employee_id >1769</ employee_id >
    < lname >Smith</ lname >
    < salary >200000</ salary >
    </Emp>
    2/. With nested invocations of xmlElement
    e.g. SELECT XMLELEMENT("Emp", XMLELEMENT("name", e.fname ||' '|| e.lname),
    XMLELEMENT ( "hiredate", e.hire)) AS "result"
    FROM employees e WHERE employee_id > 200 ;
    result
    <Emp>
    <name>John Smith</name>
    <hiredate>2000-05-24</hiredate>
    </Emp>
    <Emp>
    <name>Mary Martin</name>
    <hiredate>1996-02-01</hiredate>
    </Emp>

  • How to generate XML from SQL query

    possible ways to generate XML from SQL qury.
    i want to generate XML of following query. "Select * from emp,dep wher emp.deptno=dept.deptno"

    Hello.
    Can you try:
    SQL> set pages 0
    SQL> set linesize 150
    SQL> set long 9999999
    SQL> set head off
    SQL> select dbms_xmlgen.getxml('Select * from emp,dep wher emp.deptno=dept.deptno') from dual;
    It works fine for me.
    Octavio

  • How to create XML from relational tables based on an XML Schema ?

    There is no automated way in Oracle XML DB to define an automatic mapping between a set of columns in some existing relational tables and the elements and attributres defined by an XML Schema.
    However it is easy solve this problem by using the SQL/XML operators (XMLAGG, XMLELEMENT, XMLFOREST, XMLATTRIBUTES, etc) to generate XML documents that are compliant with an XML Schema directly from a SQL statement.
    If the XML Schema is registered with Oracle XML DB and the appropraite Schema Location information is added into the generated document using XMLAttributes then it becomes very easy to ensure that the generated documents are valid.
    The following example show an easy way to do this by creating an XML View that contains the documents to be validated.
    SQL> drop table PURCHASEORDER_LINEITEM
      2  /
    Table dropped.
    SQL> drop table PURCHASEORDER_REJECTION
      2  /
    Table dropped.
    SQL> drop table PURCHASEORDER_SHIPPING
      2  /
    Table dropped.
    SQL> drop TABLE PURCHASEORDER_ACTION
      2  /
    Table dropped.
    SQL> drop TABLE PURCHASEORDER_TABLE
      2  /
    Table dropped.
    SQL> create table PURCHASEORDER_TABLE
      2  (
      3   REFERENCE                                          VARCHAR2(28),
      4   PRIMARY KEY ("REFERENCE"),
      5   REQUESTER                                          VARCHAR2(48),
      6   USERID                                             VARCHAR2(32),
      7   COSTCENTER                                         VARCHAR2(3),
      8   SPECIALINSTRUCTIONS                                VARCHAR2(2048)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_ACTION
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   ACTIONEDBY                                         VARCHAR2(32),
      6   DATEACTIONED                                       DATE
      7  )
      8  /
    Table created.
    SQL> create table PURCHASEORDER_SHIPPING
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   PRIMARY KEY ("REFERENCE"),
      6   SHIPTONAME                                         VARCHAR2(48),
      7   ADDRESS                                            VARCHAR2(512),
      8   PHONE                                              VARCHAR2(32)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_REJECTION
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   PRIMARY KEY ("REFERENCE"),
      6   REJECTEDBY                                         VARCHAR2(32),
      7   DATEREJECTED                                       DATE,
      8   COMMENTS                                           VARCHAR2(2048)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_LINEITEM
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   LINENO                                             NUMBER(10),
      6   PRIMARY KEY ("REFERENCE","LINENO"),
      7   UPC                                                   VARCHAR2(14),
      8   DESCRIPTION                                        VARCHAR2(128),
      9   QUANTITY                                           NUMBER(10),
    10   UNITPRICE                                          NUMBER(12,2)
    11  )
    12  /
    Table created.
    SQL> insert into PURCHASEORDER_TABLE values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','SMCCAIN','A10','Courier')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_ACTION values ('SMCCAIN-20030109123335470PDT','SVOLLMAN',NULL)
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_SHIPPING values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','800 Bridge Parkway,Redwood Shores,CA,9406
    5,USA','650 506 7800')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_REJECTION values ('SMCCAIN-20030109123335470PDT',null,null,null)
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','1','715515010320','Life of Brian - Monty Python''s','2','39.
    95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','2','37429145227','The Night Porter','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','3','37429128121','Oliver Twist','1','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','4','715515012720','Notorious','4','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','5','715515012928','In the Mood for Love','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','6','37429130926','Alphaville','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','7','37429166529','General Idi Amin Dada','4','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','8','715515012928','In the Mood for Love','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','9','715515009423','Flesh for Frankenstein','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','10','715515008976','The Killer','1','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','11','37429167922','Ballad of a Soldier','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','12','37429158623','Ordet','2','0')
      2  /
    1 row created.
    SQL> var schemaPath varchar2(256)
    SQL> --
    SQL> begin
      2    :schemaURL := 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd';
      3    :schemaPath := '/public/purchaseOrder.xsd';
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
      2  /
    Call completed.
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(
      4  '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
      5  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="tr
    ue">
      6          <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
      7          <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T" xdb:maintainDOM="false">
      8                  <xs:sequence>
      9                          <xs:element name="Reference" type="ReferenceType" xdb:SQLName="REFERENCE"/>
    10                          <xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
    11                          <xs:element name="Reject" type="RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
    12                          <xs:element name="Requestor" type="RequestorType" xdb:SQLName="REQUESTOR"/>
    13                          <xs:element name="User" type="UserType" xdb:SQLName="USERID"/>
    14                          <xs:element name="CostCenter" type="CostCenterType" xdb:SQLName="COST_CENTER"/>
    15                          <xs:element name="ShippingInstructions" type="ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
    16                          <xs:element name="SpecialInstructions" type="SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
    17                          <xs:element name="LineItems" type="LineItemsType" xdb:SQLName="LINEITEMS"/>
    18                  </xs:sequence>
    19          </xs:complexType>
    20          <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T" xdb:maintainDOM="false">
    21                  <xs:sequence>
    22                          <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="L
    INEITEM_V"/>
    23                  </xs:sequence>
    24          </xs:complexType>
    25          <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T" xdb:maintainDOM="false">
    26                  <xs:sequence>
    27                          <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESRIPTION"/>
    28                          <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
    29                  </xs:sequence>
    30                  <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
    31          </xs:complexType>
    32          <xs:complexType name="PartType" xdb:SQLType="PART_T" xdb:maintainDOM="false">
    33                  <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
    34                          <xs:simpleType>
    35                                  <xs:restriction base="xs:string">
    36                                          <xs:minLength value="10"/>
    37                                          <xs:maxLength value="14"/>
    38                                  </xs:restriction>
    39                          </xs:simpleType>
    40                  </xs:attribute>
    41                  <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
    42                  <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
    43          </xs:complexType>
    44          <xs:simpleType name="ReferenceType">
    45                  <xs:restriction base="xs:string">
    46                          <xs:minLength value="18"/>
    47                          <xs:maxLength value="30"/>
    48                  </xs:restriction>
    49          </xs:simpleType>
    50          <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T" xdb:maintainDOM="false">
    51                  <xs:sequence>
    52                          <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
    53                                  <xs:complexType xdb:SQLType="ACTION_T" xdb:maintainDOM="false">
    54                                          <xs:sequence>
    55                                                  <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
    56                                                  <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
    57                                          </xs:sequence>
    58                                  </xs:complexType>
    59                          </xs:element>
    60                  </xs:sequence>
    61          </xs:complexType>
    62          <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T" xdb:maintainDOM="false">
    63                  <xs:all>
    64                          <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
    65                          <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
    66                          <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
    67                  </xs:all>
    68          </xs:complexType>
    69          <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T" xdb:maintainDOM="false">
    70                  <xs:sequence>
    71                          <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
    72                          <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
    73                          <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
    74                  </xs:sequence>
    75          </xs:complexType>
    76          <xs:simpleType name="moneyType">
    77                  <xs:restriction base="xs:decimal">
    78                          <xs:fractionDigits value="2"/>
    79                          <xs:totalDigits value="12"/>
    80                  </xs:restriction>
    81          </xs:simpleType>
    82          <xs:simpleType name="quantityType">
    83                  <xs:restriction base="xs:decimal">
    84                          <xs:fractionDigits value="4"/>
    85                          <xs:totalDigits value="8"/>
    86                  </xs:restriction>
    87          </xs:simpleType>
    88          <xs:simpleType name="UserType">
    89                  <xs:restriction base="xs:string">
    90                          <xs:minLength value="1"/>
    91                          <xs:maxLength value="10"/>
    92                  </xs:restriction>
    93          </xs:simpleType>
    94          <xs:simpleType name="RequestorType">
    95                  <xs:restriction base="xs:string">
    96                          <xs:minLength value="0"/>
    97                          <xs:maxLength value="128"/>
    98                  </xs:restriction>
    99          </xs:simpleType>
    100          <xs:simpleType name="CostCenterType">
    101                  <xs:restriction base="xs:string">
    102                          <xs:minLength value="1"/>
    103                          <xs:maxLength value="4"/>
    104                  </xs:restriction>
    105          </xs:simpleType>
    106          <xs:simpleType name="VendorType">
    107                  <xs:restriction base="xs:string">
    108                          <xs:minLength value="0"/>
    109                          <xs:maxLength value="20"/>
    110                  </xs:restriction>
    111          </xs:simpleType>
    112          <xs:simpleType name="PurchaseOrderNumberType">
    113                  <xs:restriction base="xs:integer"/>
    114          </xs:simpleType>
    115          <xs:simpleType name="SpecialInstructionsType">
    116                  <xs:restriction base="xs:string">
    117                          <xs:minLength value="0"/>
    118                          <xs:maxLength value="2048"/>
    119                  </xs:restriction>
    120          </xs:simpleType>
    121          <xs:simpleType name="NameType">
    122                  <xs:restriction base="xs:string">
    123                          <xs:minLength value="1"/>
    124                          <xs:maxLength value="20"/>
    125                  </xs:restriction>
    126          </xs:simpleType>
    127          <xs:simpleType name="AddressType">
    128                  <xs:restriction base="xs:string">
    129                          <xs:minLength value="1"/>
    130                          <xs:maxLength value="256"/>
    131                  </xs:restriction>
    132          </xs:simpleType>
    133          <xs:simpleType name="TelephoneType">
    134                  <xs:restriction base="xs:string">
    135                          <xs:minLength value="1"/>
    136                          <xs:maxLength value="24"/>
    137                  </xs:restriction>
    138          </xs:simpleType>
    139          <xs:simpleType name="DateType">
    140                  <xs:restriction base="xs:date"/>
    141          </xs:simpleType>
    142          <xs:simpleType name="CommentsType">
    143                  <xs:restriction base="xs:string">
    144                          <xs:minLength value="1"/>
    145                          <xs:maxLength value="2048"/>
    146                  </xs:restriction>
    147          </xs:simpleType>
    148          <xs:simpleType name="DescriptionType">
    149                  <xs:restriction base="xs:string">
    150                          <xs:minLength value="1"/>
    151                          <xs:maxLength value="256"/>
    152                  </xs:restriction>
    153          </xs:simpleType>
    154  </xs:schema>
    155  ');
    156  begin
    157    if (dbms_xdb.existsResource(:schemaPath)) then
    158      dbms_xdb.deleteResource(:schemaPath);
    159    end if;
    160    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    161  end;
    162  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      :schemaURL,
      5      xdbURIType(:schemaPath).getClob(),
      6      TRUE,TRUE,FALSE,FALSE
      7    );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> create or replace view PURCHASEORDER_XML
      2  of xmltype
      3  xmlSCHEMA "http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "PurchaseOrder"
      4  with object id
      5  (
      6    substr(extractValue(object_value,'/PurchaseOrder/Reference'),1,32)
      7  )
      8  as
      9    select xmlElement
    10           (
    11             "PurchaseOrder",
    12             xmlAttributes
    13             (
    14               'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd' as "xsi:noNamespaceSchemaLocation",
    15               'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi"
    16             ),
    17             xmlElement("Reference",p.REFERENCE),
    18             xmlElement
    19             (
    20               "Actions",
    21               ( select xmlAgg
    22                        (
    23                          xmlElement
    24                          (
    25                            "Action",
    26                            xmlElement("User",ACTIONEDBY),
    27                            case
    28                              when DATEACTIONED is not null
    29                              then xmlElement("Date",DATEACTIONED)
    30                            end
    31                          )
    32                        )
    33                   from PURCHASEORDER_ACTION a
    34                  where a.REFERENCE = p.REFERENCE
    35               )
    36             ),
    37             xmlElement
    38             (
    39               "Reject",
    40                  xmlForest
    41                  (
    42                    REJECTEDBY as "User",
    43                 DATEREJECTED as "Date",
    44                    COMMENTS as "Comments"
    45                  )
    46             ),
    47             xmlElement("Requestor",REQUESTER),
    48             xmlElement("User",USERID),
    49             xmlElement("CostCenter",COSTCENTER),
    50             xmlElement
    51             (
    52               "ShippingInstructions",
    53               xmlElement("name",SHIPTONAME),
    54               xmlElement("address",ADDRESS),
    55               xmlElement("telephone",PHONE)
    56             ),
    57             xmlElement("SpecialInstructions",SPECIALINSTRUCTIONS),
    58             xmlElement
    59             (
    60               "LineItems",
    61               ( select xmlAgg
    62                        (
    63                          xmlElement
    64                          (
    65                            "LineItem",
    66                            xmlAttributes(LINENO as "ItemNumber"),
    67                            xmlElement("Description",DESCRIPTION),
    68                            xmlElement
    69                            (
    70                              "Part",
    71                              xmlAttributes
    72                              (
    73                                UPC       as "Id",
    74                                QUANTITY  as "Quantity",
    75                                UNITPRICE as "UnitPrice"
    76                              )
    77                            )
    78                          )
    79                        )
    80                    from PURCHASEORDER_LINEITEM l
    81                   where l.REFERENCE = p.REFERENCE
    82               )
    83             )
    84           )
    85      from PURCHASEORDER_TABLE p, PURCHASEORDER_REJECTION r, PURCHASEORDER_SHIPPING s
    86     where r.REFERENCE = p.REFERENCE
    87       and s.REFERENCE = p.REFERENCE
    88  /
    View created.
    SQL> set long 10000 pages 0 lines 140
    SQL> --
    SQL> select x.object_value.extract('/*')
      2    from PURCHASEORDER_XML x
      3  /
    <PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Reference>SMCCAIN-20030109123335470PDT</Reference>
      <Actions>
        <Action>
          <User>SVOLLMAN</User>
        </Action>
      </Actions>
      <Reject/>
      <Requestor>Samuel B. McCain</Requestor>
      <User>SMCCAIN</User>
      <CostCenter>A10</CostCenter>
      <ShippingInstructions>
        <name>Samuel B. McCain</name>
        <address>800 Bridge Parkway,Redwood Shores,CA,94065,USA</address>
        <telephone>650 506 7800</telephone>
      </ShippingInstructions>
      <SpecialInstructions>Courier</SpecialInstructions>
      <LineItems>
        <LineItem ItemNumber="1">
          <Description>Life of Brian - Monty Python&apos;s</Description>
          <Part Id="715515010320" Quantity="2" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="2">
          <Description>The Night Porter</Description>
          <Part Id="37429145227" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="3">
          <Description>Oliver Twist</Description>
          <Part Id="37429128121" Quantity="1" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="4">
          <Description>Notorious</Description>
          <Part Id="715515012720" Quantity="4" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="5">
          <Description>In the Mood for Love</Description>
          <Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="6">
          <Description>Alphaville</Description>
          <Part Id="37429130926" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="7">
          <Description>General Idi Amin Dada</Description>
          <Part Id="37429166529" Quantity="4" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="8">
          <Description>In the Mood for Love</Description>
          <Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="9">
          <Description>Flesh for Frankenstein</Description>
          <Part Id="715515009423" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="10">
          <Description>The Killer</Description>
          <Part Id="715515008976" Quantity="1" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="11">
          <Description>Ballad of a Soldier</Description>
          <Part Id="37429167922" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="12">
          <Description>Ordet</Description>
          <Part Id="37429158623" Quantity="2" UnitPrice="0"/>
        </LineItem>
      </LineItems>
    </PurchaseOrder>
    SQL> begin
      2    for x in (select object_value from PURCHASEORDER_XML) loop
      3      x.object_value.schemaValidate();
      4    end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL>

    There is no automated way in Oracle XML DB to define an automatic mapping between a set of columns in some existing relational tables and the elements and attributres defined by an XML Schema.
    However it is easy solve this problem by using the SQL/XML operators (XMLAGG, XMLELEMENT, XMLFOREST, XMLATTRIBUTES, etc) to generate XML documents that are compliant with an XML Schema directly from a SQL statement.
    If the XML Schema is registered with Oracle XML DB and the appropraite Schema Location information is added into the generated document using XMLAttributes then it becomes very easy to ensure that the generated documents are valid.
    The following example show an easy way to do this by creating an XML View that contains the documents to be validated.
    SQL> drop table PURCHASEORDER_LINEITEM
      2  /
    Table dropped.
    SQL> drop table PURCHASEORDER_REJECTION
      2  /
    Table dropped.
    SQL> drop table PURCHASEORDER_SHIPPING
      2  /
    Table dropped.
    SQL> drop TABLE PURCHASEORDER_ACTION
      2  /
    Table dropped.
    SQL> drop TABLE PURCHASEORDER_TABLE
      2  /
    Table dropped.
    SQL> create table PURCHASEORDER_TABLE
      2  (
      3   REFERENCE                                          VARCHAR2(28),
      4   PRIMARY KEY ("REFERENCE"),
      5   REQUESTER                                          VARCHAR2(48),
      6   USERID                                             VARCHAR2(32),
      7   COSTCENTER                                         VARCHAR2(3),
      8   SPECIALINSTRUCTIONS                                VARCHAR2(2048)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_ACTION
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   ACTIONEDBY                                         VARCHAR2(32),
      6   DATEACTIONED                                       DATE
      7  )
      8  /
    Table created.
    SQL> create table PURCHASEORDER_SHIPPING
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   PRIMARY KEY ("REFERENCE"),
      6   SHIPTONAME                                         VARCHAR2(48),
      7   ADDRESS                                            VARCHAR2(512),
      8   PHONE                                              VARCHAR2(32)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_REJECTION
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   PRIMARY KEY ("REFERENCE"),
      6   REJECTEDBY                                         VARCHAR2(32),
      7   DATEREJECTED                                       DATE,
      8   COMMENTS                                           VARCHAR2(2048)
      9  )
    10  /
    Table created.
    SQL> create table PURCHASEORDER_LINEITEM
      2  (
      3   REFERENCE,
      4   FOREIGN KEY ("REFERENCE")                          REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
      5   LINENO                                             NUMBER(10),
      6   PRIMARY KEY ("REFERENCE","LINENO"),
      7   UPC                                                   VARCHAR2(14),
      8   DESCRIPTION                                        VARCHAR2(128),
      9   QUANTITY                                           NUMBER(10),
    10   UNITPRICE                                          NUMBER(12,2)
    11  )
    12  /
    Table created.
    SQL> insert into PURCHASEORDER_TABLE values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','SMCCAIN','A10','Courier')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_ACTION values ('SMCCAIN-20030109123335470PDT','SVOLLMAN',NULL)
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_SHIPPING values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','800 Bridge Parkway,Redwood Shores,CA,9406
    5,USA','650 506 7800')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_REJECTION values ('SMCCAIN-20030109123335470PDT',null,null,null)
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','1','715515010320','Life of Brian - Monty Python''s','2','39.
    95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','2','37429145227','The Night Porter','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','3','37429128121','Oliver Twist','1','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','4','715515012720','Notorious','4','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','5','715515012928','In the Mood for Love','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','6','37429130926','Alphaville','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','7','37429166529','General Idi Amin Dada','4','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','8','715515012928','In the Mood for Love','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','9','715515009423','Flesh for Frankenstein','3','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','10','715515008976','The Killer','1','39.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','11','37429167922','Ballad of a Soldier','2','29.95')
      2  /
    1 row created.
    SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','12','37429158623','Ordet','2','0')
      2  /
    1 row created.
    SQL> var schemaPath varchar2(256)
    SQL> --
    SQL> begin
      2    :schemaURL := 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd';
      3    :schemaPath := '/public/purchaseOrder.xsd';
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
      2  /
    Call completed.
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(
      4  '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
      5  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="tr
    ue">
      6          <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
      7          <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T" xdb:maintainDOM="false">
      8                  <xs:sequence>
      9                          <xs:element name="Reference" type="ReferenceType" xdb:SQLName="REFERENCE"/>
    10                          <xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
    11                          <xs:element name="Reject" type="RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
    12                          <xs:element name="Requestor" type="RequestorType" xdb:SQLName="REQUESTOR"/>
    13                          <xs:element name="User" type="UserType" xdb:SQLName="USERID"/>
    14                          <xs:element name="CostCenter" type="CostCenterType" xdb:SQLName="COST_CENTER"/>
    15                          <xs:element name="ShippingInstructions" type="ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
    16                          <xs:element name="SpecialInstructions" type="SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
    17                          <xs:element name="LineItems" type="LineItemsType" xdb:SQLName="LINEITEMS"/>
    18                  </xs:sequence>
    19          </xs:complexType>
    20          <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T" xdb:maintainDOM="false">
    21                  <xs:sequence>
    22                          <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="L
    INEITEM_V"/>
    23                  </xs:sequence>
    24          </xs:complexType>
    25          <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T" xdb:maintainDOM="false">
    26                  <xs:sequence>
    27                          <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESRIPTION"/>
    28                          <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
    29                  </xs:sequence>
    30                  <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
    31          </xs:complexType>
    32          <xs:complexType name="PartType" xdb:SQLType="PART_T" xdb:maintainDOM="false">
    33                  <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
    34                          <xs:simpleType>
    35                                  <xs:restriction base="xs:string">
    36                                          <xs:minLength value="10"/>
    37                                          <xs:maxLength value="14"/>
    38                                  </xs:restriction>
    39                          </xs:simpleType>
    40                  </xs:attribute>
    41                  <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
    42                  <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
    43          </xs:complexType>
    44          <xs:simpleType name="ReferenceType">
    45                  <xs:restriction base="xs:string">
    46                          <xs:minLength value="18"/>
    47                          <xs:maxLength value="30"/>
    48                  </xs:restriction>
    49          </xs:simpleType>
    50          <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T" xdb:maintainDOM="false">
    51                  <xs:sequence>
    52                          <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
    53                                  <xs:complexType xdb:SQLType="ACTION_T" xdb:maintainDOM="false">
    54                                          <xs:sequence>
    55                                                  <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
    56                                                  <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
    57                                          </xs:sequence>
    58                                  </xs:complexType>
    59                          </xs:element>
    60                  </xs:sequence>
    61          </xs:complexType>
    62          <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T" xdb:maintainDOM="false">
    63                  <xs:all>
    64                          <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
    65                          <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
    66                          <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
    67                  </xs:all>
    68          </xs:complexType>
    69          <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T" xdb:maintainDOM="false">
    70                  <xs:sequence>
    71                          <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
    72                          <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
    73                          <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
    74                  </xs:sequence>
    75          </xs:complexType>
    76          <xs:simpleType name="moneyType">
    77                  <xs:restriction base="xs:decimal">
    78                          <xs:fractionDigits value="2"/>
    79                          <xs:totalDigits value="12"/>
    80                  </xs:restriction>
    81          </xs:simpleType>
    82          <xs:simpleType name="quantityType">
    83                  <xs:restriction base="xs:decimal">
    84                          <xs:fractionDigits value="4"/>
    85                          <xs:totalDigits value="8"/>
    86                  </xs:restriction>
    87          </xs:simpleType>
    88          <xs:simpleType name="UserType">
    89                  <xs:restriction base="xs:string">
    90                          <xs:minLength value="1"/>
    91                          <xs:maxLength value="10"/>
    92                  </xs:restriction>
    93          </xs:simpleType>
    94          <xs:simpleType name="RequestorType">
    95                  <xs:restriction base="xs:string">
    96                          <xs:minLength value="0"/>
    97                          <xs:maxLength value="128"/>
    98                  </xs:restriction>
    99          </xs:simpleType>
    100          <xs:simpleType name="CostCenterType">
    101                  <xs:restriction base="xs:string">
    102                          <xs:minLength value="1"/>
    103                          <xs:maxLength value="4"/>
    104                  </xs:restriction>
    105          </xs:simpleType>
    106          <xs:simpleType name="VendorType">
    107                  <xs:restriction base="xs:string">
    108                          <xs:minLength value="0"/>
    109                          <xs:maxLength value="20"/>
    110                  </xs:restriction>
    111          </xs:simpleType>
    112          <xs:simpleType name="PurchaseOrderNumberType">
    113                  <xs:restriction base="xs:integer"/>
    114          </xs:simpleType>
    115          <xs:simpleType name="SpecialInstructionsType">
    116                  <xs:restriction base="xs:string">
    117                          <xs:minLength value="0"/>
    118                          <xs:maxLength value="2048"/>
    119                  </xs:restriction>
    120          </xs:simpleType>
    121          <xs:simpleType name="NameType">
    122                  <xs:restriction base="xs:string">
    123                          <xs:minLength value="1"/>
    124                          <xs:maxLength value="20"/>
    125                  </xs:restriction>
    126          </xs:simpleType>
    127          <xs:simpleType name="AddressType">
    128                  <xs:restriction base="xs:string">
    129                          <xs:minLength value="1"/>
    130                          <xs:maxLength value="256"/>
    131                  </xs:restriction>
    132          </xs:simpleType>
    133          <xs:simpleType name="TelephoneType">
    134                  <xs:restriction base="xs:string">
    135                          <xs:minLength value="1"/>
    136                          <xs:maxLength value="24"/>
    137                  </xs:restriction>
    138          </xs:simpleType>
    139          <xs:simpleType name="DateType">
    140                  <xs:restriction base="xs:date"/>
    141          </xs:simpleType>
    142          <xs:simpleType name="CommentsType">
    143                  <xs:restriction base="xs:string">
    144                          <xs:minLength value="1"/>
    145                          <xs:maxLength value="2048"/>
    146                  </xs:restriction>
    147          </xs:simpleType>
    148          <xs:simpleType name="DescriptionType">
    149                  <xs:restriction base="xs:string">
    150                          <xs:minLength value="1"/>
    151                          <xs:maxLength value="256"/>
    152                  </xs:restriction>
    153          </xs:simpleType>
    154  </xs:schema>
    155  ');
    156  begin
    157    if (dbms_xdb.existsResource(:schemaPath)) then
    158      dbms_xdb.deleteResource(:schemaPath);
    159    end if;
    160    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    161  end;
    162  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      :schemaURL,
      5      xdbURIType(:schemaPath).getClob(),
      6      TRUE,TRUE,FALSE,FALSE
      7    );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> create or replace view PURCHASEORDER_XML
      2  of xmltype
      3  xmlSCHEMA "http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "PurchaseOrder"
      4  with object id
      5  (
      6    substr(extractValue(object_value,'/PurchaseOrder/Reference'),1,32)
      7  )
      8  as
      9    select xmlElement
    10           (
    11             "PurchaseOrder",
    12             xmlAttributes
    13             (
    14               'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd' as "xsi:noNamespaceSchemaLocation",
    15               'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi"
    16             ),
    17             xmlElement("Reference",p.REFERENCE),
    18             xmlElement
    19             (
    20               "Actions",
    21               ( select xmlAgg
    22                        (
    23                          xmlElement
    24                          (
    25                            "Action",
    26                            xmlElement("User",ACTIONEDBY),
    27                            case
    28                              when DATEACTIONED is not null
    29                              then xmlElement("Date",DATEACTIONED)
    30                            end
    31                          )
    32                        )
    33                   from PURCHASEORDER_ACTION a
    34                  where a.REFERENCE = p.REFERENCE
    35               )
    36             ),
    37             xmlElement
    38             (
    39               "Reject",
    40                  xmlForest
    41                  (
    42                    REJECTEDBY as "User",
    43                 DATEREJECTED as "Date",
    44                    COMMENTS as "Comments"
    45                  )
    46             ),
    47             xmlElement("Requestor",REQUESTER),
    48             xmlElement("User",USERID),
    49             xmlElement("CostCenter",COSTCENTER),
    50             xmlElement
    51             (
    52               "ShippingInstructions",
    53               xmlElement("name",SHIPTONAME),
    54               xmlElement("address",ADDRESS),
    55               xmlElement("telephone",PHONE)
    56             ),
    57             xmlElement("SpecialInstructions",SPECIALINSTRUCTIONS),
    58             xmlElement
    59             (
    60               "LineItems",
    61               ( select xmlAgg
    62                        (
    63                          xmlElement
    64                          (
    65                            "LineItem",
    66                            xmlAttributes(LINENO as "ItemNumber"),
    67                            xmlElement("Description",DESCRIPTION),
    68                            xmlElement
    69                            (
    70                              "Part",
    71                              xmlAttributes
    72                              (
    73                                UPC       as "Id",
    74                                QUANTITY  as "Quantity",
    75                                UNITPRICE as "UnitPrice"
    76                              )
    77                            )
    78                          )
    79                        )
    80                    from PURCHASEORDER_LINEITEM l
    81                   where l.REFERENCE = p.REFERENCE
    82               )
    83             )
    84           )
    85      from PURCHASEORDER_TABLE p, PURCHASEORDER_REJECTION r, PURCHASEORDER_SHIPPING s
    86     where r.REFERENCE = p.REFERENCE
    87       and s.REFERENCE = p.REFERENCE
    88  /
    View created.
    SQL> set long 10000 pages 0 lines 140
    SQL> --
    SQL> select x.object_value.extract('/*')
      2    from PURCHASEORDER_XML x
      3  /
    <PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Reference>SMCCAIN-20030109123335470PDT</Reference>
      <Actions>
        <Action>
          <User>SVOLLMAN</User>
        </Action>
      </Actions>
      <Reject/>
      <Requestor>Samuel B. McCain</Requestor>
      <User>SMCCAIN</User>
      <CostCenter>A10</CostCenter>
      <ShippingInstructions>
        <name>Samuel B. McCain</name>
        <address>800 Bridge Parkway,Redwood Shores,CA,94065,USA</address>
        <telephone>650 506 7800</telephone>
      </ShippingInstructions>
      <SpecialInstructions>Courier</SpecialInstructions>
      <LineItems>
        <LineItem ItemNumber="1">
          <Description>Life of Brian - Monty Python&apos;s</Description>
          <Part Id="715515010320" Quantity="2" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="2">
          <Description>The Night Porter</Description>
          <Part Id="37429145227" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="3">
          <Description>Oliver Twist</Description>
          <Part Id="37429128121" Quantity="1" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="4">
          <Description>Notorious</Description>
          <Part Id="715515012720" Quantity="4" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="5">
          <Description>In the Mood for Love</Description>
          <Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="6">
          <Description>Alphaville</Description>
          <Part Id="37429130926" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="7">
          <Description>General Idi Amin Dada</Description>
          <Part Id="37429166529" Quantity="4" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="8">
          <Description>In the Mood for Love</Description>
          <Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="9">
          <Description>Flesh for Frankenstein</Description>
          <Part Id="715515009423" Quantity="3" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="10">
          <Description>The Killer</Description>
          <Part Id="715515008976" Quantity="1" UnitPrice="39.95"/>
        </LineItem>
        <LineItem ItemNumber="11">
          <Description>Ballad of a Soldier</Description>
          <Part Id="37429167922" Quantity="2" UnitPrice="29.95"/>
        </LineItem>
        <LineItem ItemNumber="12">
          <Description>Ordet</Description>
          <Part Id="37429158623" Quantity="2" UnitPrice="0"/>
        </LineItem>
      </LineItems>
    </PurchaseOrder>
    SQL> begin
      2    for x in (select object_value from PURCHASEORDER_XML) loop
      3      x.object_value.schemaValidate();
      4    end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL>

  • Need some help how to generate xml from java bean.

    Hi,
    Can some one help me how to generate the xml format output from a java bean.
    The bean contains around 15 to 20 attribute values.
    Thanks in Advance.
    sarayu

    You can use XMLEncoder with custom persistence delegates if needed:
    http://java.sun.com/products/jfc/tsc/articles/persistence4/

  • Adobe LiveCycle Workbench -- How to generate XML from SQL Server 2008 R2

    Hello,
    Please let me know if anyone has the solution to generate XML in adobe livecycle workbench and generate a dynamic PDF form using that XML.
    Regards,
    Himanshu

    Yes, XML could be generated as here : http://www.adobe.com/devnet/livecycle/articles/building-xml.html
    You can merge this XML with the form template and generate the form.
    Hope this helps.
    Thnaks,
    Wasil

  • Generating xml from oracle-data

    In our company we have to export customer-data to xml using a predefined format (which we cannot change).
    This xml will subsequently be used to import the data into another system.
    I'm not that familiar with XML. Most of the work can be done using dbms_xmlgen which is pretty simple and straightforward to use
    There is one type of element I cannot place correctly in the specification
    The use of foreign keys. For instance
    A employee has a foreign key to a bussiness unit that should be written down in the xml
    when using "normal" dbms_xmlgen the tag would be like
    <bussinessunit>"bisut100"</bussinessunit>
    But the specification specifies the following format
    <bussinessunit bussinesunitId="bisut100"/>
    Any idea how to get this using dbms_xmlgen?
    Or if not possible with dbms_xmlgen how could this easily be achieved?

    Thanks for the reply and the challenge is more to generate the closing tag exactly like in the specification
    The following is a snippet of what is required
    -<employee>
    <id>2</id>
    <empno>102105<empno>
    -<name>
    <firstname>Tom</firstname>
    <lastname>Hanks</lastname>
    </name>
    <bussinessunit bussinesunitId="bisut100"/>
    <employee>
    -<employee>
    <id>3</id>
    I wonder how to achieve the line
    <bussinessunit bussinesunitId="bisut100"/>
    I tried using
    DBMS_XMLGEN.setNullHandling(qryCtx, DBMS_XMLGEN.EMPTY_TAG);
    and then the construction
    qryCtx := DBMS_XMLGEN.newContext(
    ' select id, custom0 bussinessunit , company_id "@bussinessunitId", lname
    from tpt_employees t
    where rownum < 2
    and custom0 is null');
    Unfortunately, the resulting xml-line
    <BUSSINESSUNIT bussinessunitId = "1" <BUSSINESSUNIT/>
    is not the xml I had hoped for (it's not valid as well)

  • Generating XML from relational tables and storing back in CLOB field

    I have been reviewing the documentation and trying to figure out the best approach. I am on v 10.2.0.3 and need to select from a parent table and three child tables and want to generate the results as xml that I will place in a clob field in another table. I looked at XMLQuery and dbms_xmlgen.getxml. The difference appears to be that getxml allows you to code traditional sql to join the tables.
    I would greatly appreciate it if someone could provide some feedback and any sample code along the line that I describe above.
    Thank you in advance for your help!
    Jerry

    Any feedback to the above questions would be greatly appreciated!

  • How to generate XML from XML schema

    Hi,
    I have registered XML schema and I would like to construct XML document for the schema. I wonder it is possible to create an empty instance and then populate it with the data? One solution is to construct the XML with concatenation of the elements but I think it exists more flexible and intelligent way. I read OTN and Metalink samples, documentation and forums users’ examples but I did not find any appropriate. What is the ordinary way for XML construction? Can you give me some advice? Tank you in advance.
    Best regards,
    Georgi

    The JAXB Class Generator generates java classes with the
    orajaxb utility.
    oracle.xml.jaxb.orajaxb -schema <schemafile> -outputDir <outputdir>
    The java classes generated have get/set methods to construct an XML document.
    thanks,
    Deepak

  • How to generate xml from xsd

    Hi,
    Is there any tool to validate the xml file form given xsd.
    Regards,
    Shakir

    did you not ask this before,
    http://forum.java.sun.com/thread.jspa?threadID=791199
    Hi,
    I am new to xml.I want to validate the xml file from
    a given xsd file.
    Is there any tool validate xml file from a given xsd
    file
    Regards,
    Shakir

  • How to add doctype when generating XML from an arbitrary data structure

    I was reading SUN's tutorial "Working with XML - PART IV: Using XSLT". Inside this tutorial, in 3, it talks about how to generate XML from an arbitrary data structure making use of a XMLReader and a Transformer. The example only shows adding elements. Is there a way to add DTD information in the XML generated, i.e. <!DOCTYPE ... >? What APIs can I use?
    Thanks,
    Alex

    The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
    When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
    If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
    If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
    t_factory.newTransformer(new StreamSource("test.xsl"));
    and use this as test.xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output doctype-system="yourDTDfile.dtd"/>
       <!-- this is the identity transformation -->
       <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:copy>
             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>Good luck.

  • How to generate XML data from Lotus Notes to migrate to SharePoint by passing XML to SharePoint.?

    How to generate XML data from Lotus Notes to migrate to SharePoint by passing XML to SharePoint.?
    Ramesh S

    You could use XMLQuery to return the data from your tables as XML, that would give you a CLOB.
    An example using the SCOTT schema might be like this:
    SELECT XMLQuery(
             'for $i in ora:view("DEPT")/ROW
              return <Department dname="{$i/DNAME}">
                     <Employee>
                       {for $j in ora:view("EMP")/ROW
                        where $j/DEPTNO eq $i/DEPTNO
                        return ($j/ENAME, $j/JOB, $j/SAL)}
                     </Employee>
                     </Department>'
             RETURNING CONTENT) FROM DUAL;In the docs you can find more information about its use:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_xquery.htm

  • Generating XML from SQL queries and saving to a xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    Hi
    Here is an example of some code that i am using on Oracle 817.
    The create_file procedure is the one that creates the file.
    The orher procedures are utility procedures that can be used with any XML file.
    PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
    pi_root_tag IN VARCHAR2,
                                            po_root_element OUT xmldom.domelement,
                                            po_root_node OUT xmldom.domnode,
                                            pi_doctype_url IN VARCHAR2) IS
    xmldoc xmldom.DOMDocument;
    root xmldom.domnode;
    root_node xmldom.domnode;
    root_element xmldom.domelement;
    record_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
    -- Create the root --
    root := xmldom.makeNode(xmldoc);
    -- Create the root element in the file --
    create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
    po_xmldoc := xmldoc;
    po_root_node := root_node;
    po_root_element := root_element;
    END create_file_with_root;
    PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
    pi_element_name IN VARCHAR2,
                                            pi_parent_node IN xmldom.domnode,
                                            po_new_element OUT xmldom.domelement,
                                            po_new_node OUT xmldom.domnode) IS
    element xmldom.domelement;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    element := xmldom.createElement(pi_xmldoc, pi_element_name);
    child_node := xmldom.makeNode(element);
    -- Append the new node to the parent --
    newelenode := xmldom.appendchild(pi_parent_node, child_node);
    po_new_node := child_node;
    po_new_element := element;
    END create_element_and_append;
    FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
    pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
    parent_node xmldom.domnode;                                   
    child_node xmldom.domnode;
    child_element xmldom.domelement;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
    parent_node := child_node;
    -- Create a text node --
    textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
    child_node := xmldom.makeNode(textele);
    -- Link the text node to the new node --
    compnode := xmldom.appendChild(parent_node, child_node);
    RETURN newelenode;
    END create_text_element;
    PROCEDURE create_file IS
    xmldoc xmldom.DOMDocument;
    root_node xmldom.domnode;
    xml_doctype xmldom.DOMDocumentType;
    root_element xmldom.domelement;
    record_element xmldom.domelement;
    record_node xmldom.domnode;
    parent_node xmldom.domnode;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
    xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
    parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
    parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
    -- write the newly created dom document into the buffer assuming it is less than 32K
    xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
    EXCEPTION
    WHEN xmldom.INDEX_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
    WHEN xmldom.DOMSTRING_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'String Size error');
    WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
    WHEN xmldom.WRONG_DOCUMENT_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
    WHEN xmldom.INVALID_CHARACTER_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
    WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
    WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
    WHEN xmldom.NOT_FOUND_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not found error');
    WHEN xmldom.NOT_SUPPORTED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
    WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
    WHEN OTHERS THEN
    dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
    END create_file;

  • Generating XML from dual

    Hey Gurus,
    I'm trying to generate the following XML from dual, however, I keep getting an error message stating my top level is not defined. Any ideas? Thanks!
    <PUDOOUTPUT>
    <PKG>
    <SHIPMENTID>12345</SHIPMENTID>
    <ERROR>'NO DATA'</ERROR>
    <ERRORTEXT>'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.'</ERRORTEXT>
    </PKG>
    </PUDOOUTPUT>
    select xmlelement("PUDOOUTPUT",xmlelement("PKG",xmlelement("SHIPMENTID",i.shipmentid),
    xmlelement("ERROR",'NO DATA'),
    xmlelement("ERRORTEXT",'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.')))
    into p_wms_output
    from dual;

    Hi,I need to generate XML FIle.Since i m new to XML.
    I had toregister the valid schema in my DB now i want to generate the XML file and with the refernce to this schema that xml file should be validated one against that schema.
    things i hav done till now
    ->i hav registered the scehma
    and the sample XML file provided by client
    <?xml version="1.0"?>
    <MEDMLDATA xmlns="PhaseForward-MedML-Inform4">
    <!-- Insert Trial/Study Information -->
    <STUDYVERSION UUID="id"
    STUDYNAME="name"
    VERSIONDESCRIPTION="text" />
    <!-- Insert Site Personnel Information -->
    <USER USERNAME="mmeyer"
    USERTYPE = "SITE"
    ACTIVESTATE = "TRUE"
    DELETESTATE = "FALSE"
    FIRSTNAME = "Marianne"
    LASTNAME = "Meyer"
    DISPLAYNAME = "Marianne Meyer"
    TITLE = ""
    HOMESCREENURL = "./Custom/HomeDefault.html"
    PHONE = "(555) 555-1212"
    FAX = "(555) 555-1212"
    ALTPHONE = ""
    EMAIL = "[email protected]"
    ADDRESS = ""
    ADDRESS2 = ""
    CITY = ""
    STATE = ""
    ZIPCODE = ""
    COUNTRY = ""
    BEEPER = ""
    USERMUSTRESETPASSWORD = "FALSE"
    DESCRIPTION = ""
    PASSWORD="changeme"/>
    <USER USERNAME="john"
    USERTYPE = "SITE"
    ACTIVESTATE = "TRUE"
    DELETESTATE = "FALSE"
    FIRSTNAME = "John"
    LASTNAME = "Meyer"
    DISPLAYNAME = "John Meyer"
    TITLE = ""
    HOMESCREENURL = "./Custom/HomeDefault.html"
    PHONE = "(555) 555-1212"
    FAX = "(555) 555-1212"
    ALTPHONE = ""
    EMAIL = "[email protected]"
    ADDRESS = ""
    ADDRESS2 = ""
    CITY = ""
    STATE = ""
    ZIPCODE = ""
    COUNTRY = ""
    BEEPER = ""
    USERMUSTRESETPASSWORD = "FALSE"
    DESCRIPTION = ""
    PASSWORD="changeme"/>
    <!-- Insert Site Information -->
    <SITE NAME= "(01) Massachusetts General Hospital" MNEMONIC="01"
    ADDRESS = "1 Main Street"
    ADDRESS2 = ""
    CITY = "Boston"
    STATE = "MA"
    ZIPCODE = ""
    COUNTRY = "USA"
    PHONE = "(555) 555-1212"
    ALTPHONE = ""
    FAX = ""
    EMAIL = ""
    TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
    SITEDATEFORMAT = "MONTH_DAY_YEAR"
    STARTDATE = "April 1, 2005">
    </SITE>
    <SITE NAME= "(02) Boston General Hospital" MNEMONIC="01"
    ADDRESS = "1 Main Street"
    ADDRESS2 = ""
    CITY = "Boston"
    STATE = "MA"
    ZIPCODE = ""
    COUNTRY = "USA"
    PHONE = "(555) 555-1212"
    ALTPHONE = ""
    FAX = ""
    EMAIL = ""
    TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
    SITEDATEFORMAT = "MONTH_DAY_YEAR"
    STARTDATE = "April 1, 2005">
    </SITE>
    <!-- Insert SITE and User Mapping Information -->
    <SITEGROUP SITENAME="(01) Massachusetts General Hospital">
    <USERREF USERNAME="mmeyer"/>
    </SITEGROUP>
    <SITEGROUP SITENAME="(02) Boston General Hospital">
    <USERREF USERNAME="John"/>
    </SITEGROUP>
    <!-- Insert User ROle Information -->
    <RIGHTSGROUP GROUPNAME="CRA">
    <!-- Insert Rights -->
    <RIGHTREF RIGHT="Print"/>
    <RIGHTREF RIGHT="Monitor"/>
    <RIGHTREF RIGHT="Canned Reports"/>
    <RIGHTREF RIGHT="View CRF"/>
    <RIGHTREF RIGHT="View Signature History for CRF"/>
    <RIGHTREF RIGHT="View Signature History for CRB"/>
    <RIGHTREF RIGHT="Data Export Listings"/>
    <RIGHTREF RIGHT="Freeze a CRF"/>
    <RIGHTREF RIGHT="Unfreeze a CRF"/>
    <RIGHTREF RIGHT="Mark and Unmark a CRF as SVed"/>
    <RIGHTREF RIGHT="Freeze a CRB"/>
    <RIGHTREF RIGHT="Unfreeze a CRB"/>
    <RIGHTREF RIGHT="Change Query State from Candidate to Open"/>
    <RIGHTREF RIGHT="Change Query State from Candidate to Deleted"/>
    <RIGHTREF RIGHT="Change Query State from Answered to Closed"/>
    <RIGHTREF RIGHT="Change Query State from Open to Closed"/>
    <RIGHTREF RIGHT="Change Query State from Reissued Candidate to Closed"/>
    <RIGHTREF RIGHT="Enter Query in Candidate State"/>
    <RIGHTREF RIGHT="Enter Query in Open State"/>
    <RIGHTREF RIGHT="Re-issue Query in Candidate State"/>
    <RIGHTREF RIGHT="Re-issue Query in Open State"/>
    <RIGHTREF RIGHT="Navigate by Visit"/>
    <RIGHTREF RIGHT="Navigate by Form"/>
    <RIGHTREF RIGHT="Reordering of Patients"/>
    <!-- Insert Users for role -->
    <USERREF USERNAME="mmeyer"/>
    <USERREF USERNAME="john"/>
    </RIGHTSGROUP>
    </MEDMLDATA>
    now i need to generate XML based on the above SAMple XML file,can anybody tell me how to generate XML file based on this..and after generating it should be validated against the registerd schema.

Maybe you are looking for

  • How do I add a iDVD slideshow on my .mac??

    I can't see a link anywhere to import it. I tried buring it ias a disc and at a video ts file and niether will allow me to upload it.

  • Price condition - all items

    Hi gurus, I have a little problem from a client. For example : i have 3 items   item A     gross weight 2kgrs   item B     gross weight 1,5kgrs   item C     gross weight 3kgrs there is SD order with above items as follows:   item A  2 pcs  (gross wei

  • How Business Objects connects with Composite Studio 4.6.0

    Hi, Info on Composite: Composite Studio is third party tool which connects to multiple data sources and executes the scripts (similiar to VIEW) to retrieve the results. One has to make call to the scripts to get the results. more information: http://

  • Debugging installed AIR .exe

    When running my AIR app in Flex Builder with ADL, my error messages come through fine and I get an error dialog when something fatal has happened (that wasn't caught by a try/catch). However, when I package up and install my AIR app on another machin

  • ITunes Mess

    My iTunes is locking up constantly. Is this related to iTunes 11? What a mess. It doesn't matter what area I am in, such as store or library, or anywhere. It just locks up and says not responding. Any suggestions?