Dbms_xmlschema.generateschema - JAXB

dbms_xmlschema.generateschema - JAXB
We want to use our Oracle produced xsd to build JAVA content trees for unmarshalling and marshalling USING JAXB. The Oracle generated xsd does NOT nest complex sequence elements properly for JAXB. Any input is appreciated.
Below is an example from the sun tutorial for using JAXB. Notice the ITEMS/ITEM structure. Below that is our example types, PL/SQL to generate xsd and the results.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
CREATE OR REPLACE TYPE sjs.Item AS OBJECT
( "productName"                    VARCHAR2(100),
"quantity"               INTEGER
CREATE OR REPLACE TYPE sjs.Items AS TABLE OF sjs.Item
CREATE OR REPLACE TYPE sjs.purchaseOrder AS OBJECT
("comment"               VARCHAR2(100),
"Items"               Items
DECLARE
RECURSE BOOLEAN := TRUE;
ANNOTATE BOOLEAN := FALSE;
EMBEDCOLL BOOLEAN := FALSE;
Schemaurl VARCHAR2(10) := 'WWW';
XSD_TYPE XMLTYPE;
XSD_CLOB CLOB;
XML_CLOB CLOB;
XML_TYPE XMLsequenceTYPE;
valid_flag INTEGER;
p_out     CLOB;
message VARCHAR2(4000);
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
XSD_TYPE := dbms_xmlschema.generateschema('SJS','ITEMS','purchaseOrder',RECURSE,ANNOTATE,EMBEDCOLL);
XSD_CLOB := XSD_TYPE.getclobval;
sjs.file_util.write_clob(XSD_CLOB,'po.xsd','C:\XMLAPI_PRODUCE');
DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.CREATETEMPORARY(xsd_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xsd_CLOB, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.CLOSE(xml_CLOB);
DBMS_LOB.FREETEMPORARY(xml_CLOB);
DBMS_LOB.CLOSE(xsd_CLOB);
DBMS_LOB.FREETEMPORARY(xsd_CLOB);
END;
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdb="http://xmlns.oracle.com/xdb" xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
<xsd:element name="purchaseOrder" type="ITEMSType"/>
<xsd:complexType name="ITEMSType">
<xsd:sequence>
<xsd:element name="ITEMS_ITEM" type="ITEMType" maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ITEMType">
<xsd:sequence>
<xsd:element name="productName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="quantity" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

DB Structure
Parent Table - Incident --> Child Table - IncidentCharges --> Child Table of IncidentCharges --> IncidentChargeWeapons
Container
Oracle Containers for JAVA(OC4J)
We have a schema (Incident.xsd) which comprises of our entire database structure. We unmarshalled the schema using JAXB to Java classes and interfaces .
It created 2 .java classes and 2 .java interfaces for each high level tag . for eg for our Incident tag it created a Incident interface and a IncidentType Interface
and also it created 2 classes IncidentImpl and IncidentTypeImpl . The IncidentTypeImpl has all the get and set properties we require eg. getIncidentType,
setIncidentType,getIncidentNumber,setIncidentNumber,getOccuranceDate,setOccuranceDate etc.
Our objective is to create a JSP page which has form fields to enter data which use these JAXB generated classes get and set properties. In other words
we want to bind the JSP form fields to these JAXB generated classes. And once these JAXB objects are populated we want to marshal it and create a XML file with the data from those JAXB . Our database would then consume the generated XML. We tried creating a simple incident form with just 3 fields IncidentType,Occurance date and Incident Number and tried to bind these fields with the properties from IncidentTypeImpl classes using the <jsp:usebean> tag . When we deployed it to our container and tried to load the Incident.jsp page , it would not load up . Only when we cleared all the bindings it loaded up .
Then we tried another workaround (just to get it working. Not a preferred approach) . We created another simple JAVA bean(not JAXB generated beans) which has set and get properties for the form fields and bound the form fields to it.
On submitting the JSP page we called a servlet which takes data from our created bean and transfers it to the JAXB generated IncidentTypeImpl bean. When we deployed this the jsp page loads up and also our bean is filled with data . But the servlet bombs with this error below.
500 Internal Server Error
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
     at Servlets.IncidentServlet.doPost(Unknown Source)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
     at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
     at java.lang.Thread.run(Thread.java:534)
We have 2 questions .
1. Can a JSP page be bound directly to this JAXB generated bean in pretty much the same way as we bind it to our own bean ? (We would like to do this so that we dont have to create duplicate classes which mirror the JAXB generated classes.)
2. Is there something special we have to do to deploy this application to recognize the JAXB classes. Do we have to deploy some jar file for it to recognize those classes ?

Similar Messages

  • Dbms_xmlschema.generateschema

    Hi!
    I want to generate a XMLschema from the database but i only get this:
    DBMS_XMLSCHEMA.GENERATESCHEMA(UPPER('SCOTT'),'EMPLOYEE_T').GETCLOBVAL()
    <?xml version="1.0"?>
    <xsd:schema targetNamespace="http://ns.oracle.com/xdb/SCOT
    This is my code:
    select dbms_xmlschema.generateschema(upper('scott'), 'EMPLOYEE_T').getClobVal()
    from dual;
    This is my database:
    9.2.0.1.0
    Is my database the reason or have i done something wrong?
    With best regards
    Nicole

    Hi Nicole
    "set long 1000000000" should solve your problem.
    Chris
    PS: if you want to use XDB you should install 9.2.0.4.0

  • ORA-31094 & ORA-31082 when registering Schemas generated w/generateSchema()

    I have genereated several Schemas using DBMS_XMLSCHEMA.generateSchema(). However, trying to register these Schemas results in error messages. The error messages state that "REF" and also my own Types were incompatible SQL-Types for an Attribute or Element (ORA-31094). Also, they state that "SQLSchema" was an invalid Attribute (ORA-31082).
    As an example, I have included one of the Schemas that has been generated, the procedure used to register it and and also the type OTYP_Artikel it has been generated from. I would like to know why the Schemas generated by Oracle contain these errors and how to fix this.
    declare
    doc varchar2(2000) := '<xsd:schema targetNamespace="http://ns.oracle.com/xdb/OO_CHEF" xmlns="http://ns.oracle.com/xdb/OO_CHEF" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
    <xsd:element name="OTYP_ARTIKEL" type="OTYP_ARTIKELType" xdb:SQLType="OTYP_ARTIKEL" xdb:SQLSchema="OO_CHEF"/>
    <xsd:complexType name="OTYP_ARTIKELType">
    <xsd:sequence>
    <xsd:element name="ARTIKEL_NR" type="xsd:string" xdb:SQLName="ARTIKEL_NR" xdb:SQLType="VARCHAR2"/>
    <xsd:element name="MWST" type="xsd:hexBinary" xdb:SQLName="MWST" xdb:SQLType="REF"/>
    <xsd:element name="BEZEICHNUNG" type="xsd:string" xdb:SQLName="BEZEICHNUNG" xdb:SQLType="VARCHAR2"/>
    <xsd:element name="LISTENPREIS" type="xsd:double" xdb:SQLName="LISTENPREIS" xdb:SQLType="NUMBER"/>
    <xsd:element name="BESTAND" type="xsd:double" xdb:SQLName="BESTAND" xdb:SQLType="NUMBER"/>
    <xsd:element name="MINDESTBESTAND" type="xsd:double" xdb:SQLName="MINDESTBESTAND" xdb:SQLType="NUMBER"/>
    <xsd:element name="VERPACKUNG" type="xsd:string" xdb:SQLName="VERPACKUNG" xdb:SQLType="VARCHAR2"/>
    <xsd:element name="LAGERPLATZ" type="xsd:double" xdb:SQLName="LAGERPLATZ" xdb:SQLType="NUMBER"/>
    <xsd:element name="KANN_WEGFALLEN" type="xsd:double" xdb:SQLName="KANN_WEGFALLEN" xdb:SQLType="NUMBER"/>
    <xsd:element name="BESTELLVORSCHLAG" type="xsd:date" xdb:SQLName="BESTELLVORSCHLAG" xdb:SQLType="DATE"/>
    <xsd:element name="NACHBESTELLUNG" type="xsd:date" xdb:SQLName="NACHBESTELLUNG" xdb:SQLType="DATE"/>
    <xsd:element name="NACHBESTELLMENGE" type="xsd:double" xdb:SQLName="NACHBESTELLMENGE" xdb:SQLType="NUMBER"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>';
    begin
    dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', doc);
    end;
    DROP TABLE otab_artikel
    DROP TABLE otab_mwstsatz
    DROP TYPE otyp_artikel
    DROP TYPE otyp_mwstsatz
    CREATE OR REPLACE TYPE otyp_mwstsatz AS OBJECT (
    mwst integer,
    prozent number (3,3),
    beschreibung varchar2(10),
    MAP MEMBER FUNCTION mwst_order RETURN REAL,
    PRAGMA RESTRICT_REFERENCES
    (mwst_order, RNDS, WNDS, RNPS, WNPS),
    STATIC FUNCTION construct_mwst (in_mwst IN INTEGER,
    in_prozent IN NUMBER, in_beschreib IN VARCHAR2)
    RETURN otyp_mwstsatz
    show errors
    CREATE OR REPLACE TYPE BODY otyp_mwstsatz AS
    MAP MEMBER FUNCTION mwst_order RETURN REAL IS
    BEGIN
    RETURN prozent;
    END mwst_order;
    STATIC FUNCTION construct_mwst (in_mwst IN INTEGER,
    in_prozent IN NUMBER,
    in_beschreib IN VARCHAR2)
    RETURN otyp_mwstsatz IS
    BEGIN
    IF in_mwst < 0 THEN
    DBMS_OUTPUT.PUT_LINE ('Mwst-Schluessel muss >=0 sein');
    raise_application_error(-1,'Wertfehler bei mwst',FALSE);
    ELSE
    RETURN otyp_mwstsatz(in_mwst,in_prozent,in_beschreib);
    END IF;
    END construct_mwst;
    END;
    show errors
    CREATE TABLE otab_mwstsatz OF otyp_mwstsatz
    mwst NOT NULL,
    prozent NOT NULL,
    CONSTRAINT pk_mwstsatz PRIMARY KEY (mwst)
    CREATE OR REPLACE TYPE otyp_artikel AS OBJECT (
    artikel_nr varchar2(4),
    mwst REF otyp_mwstsatz,
    bezeichnung varchar2(15),
    listenpreis number(8,2),
    bestand number(5,0),
    mindestbestand number (5,0),
    verpackung varchar2(15),
    lagerplatz number(2,0),
    kann_wegfallen number(1,0),
    bestellvorschlag date,
    nachbestellung date,
    nachbestellmenge number(5,0),
    MEMBER FUNCTION get_mwst RETURN REAL,
    PRAGMA RESTRICT_REFERENCES (get_mwst, WNDS, WNPS)
    show errors
    CREATE OR REPLACE TYPE BODY otyp_artikel AS
    MEMBER FUNCTION get_mwst RETURN REAL IS
    lvar_prozent NUMBER(3,3);
    lvar_mwst otyp_mwstsatz;
    BEGIN
    SELECT DEREF(mwst) INTO lvar_mwst
    FROM dual;
    lvar_prozent := lvar_mwst.prozent;
    RETURN lvar_prozent;
    END get_mwst;
    END;
    show errors
    CREATE TABLE otab_artikel OF otyp_artikel (
    CONSTRAINT pk_artikel PRIMARY KEY (artikel_nr),
    CONSTRAINT nn_mwst mwst NOT NULL,
    CONSTRAINT nn_bezeichnung bezeichnung NOT NULL,
    CONSTRAINT nn_listenpreis listenpreis NOT NULL,
    CONSTRAINT nn_bestand bestand NOT NULL,
    CONSTRAINT chk_bestand CHECK (bestand >= 0),
    CONSTRAINT nn_mindestbestand mindestbestand NOT NULL,
    CONSTRAINT chk_mindestbestand CHECK (mindestbestand >= 0),
    CONSTRAINT chk_nachbestell
    CHECK (nachbestellmenge IS NULL OR nachbestellmenge >= 0)
    );

    Please post your question to XML DB forum for further help.

  • Dbms_xmlschema

    How do you "unregister a schema". The following is being used to register and validate but it will not "reregister". getting the following error:
    DECLARE
    RECURSE BOOLEAN := TRUE;
    ANNOTATE BOOLEAN := FALSE;
    EMBEDCOLL BOOLEAN := TRUE;
    XSD_TYPE XMLTYPE;
    XSD_CLOB CLOB;
    XML_CLOB CLOB;
    XML_TYPE XMLTYPE;
    valid_flag INTEGER;
    p_out     CLOB;
    BEGIN
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
    XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',RECURSE,ANNOTATE,EMBEDCOLL);
    XSD_CLOB := XSD_TYPE.getclobval;
    dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', XSD_CLOB);
    sjs.file_util.write_clob(XSD_CLOB,'TEST.xml','C:\XMLAPI_PRODUCE');
    DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
    DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
    sjs.file_util.ReadClob(xml_CLOB,'XML_DIR','INC200306261138511.xml');
    xml_type := XMLTYPE.createXML(xml_clob);
    IF xml_type.isSchemaValid('http://www.oracle.com/best.xsd') = 1 THEN
    DBMS_OUTPUT.PUT_LINE('Valid xml');
    ELSE
    DBMS_OUTPUT.PUT_LINE('NOT Valid xml');
    END IF;
    DBMS_LOB.CLOSE(xml_CLOB);
    DBMS_LOB.FREETEMPORARY(xml_CLOB);
    dbms_output.put_line(p_out);
    END;
    ERROR at line 1:
    ORA-31085: schema "http://www.oracle.com/best.xsd" already registered
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
    ORA-06512: at line 15

    Got it, Thanks, The following stil always produces Not valid for the xml. Do you know a way to get the info on why the xml is invalid?
    Thanks
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
    RECURSE BOOLEAN := TRUE;
    ANNOTATE BOOLEAN := FALSE;
    EMBEDCOLL BOOLEAN := TRUE;
    XSD_TYPE XMLTYPE;
    XSD_CLOB CLOB;
    XML_CLOB CLOB;
    XML_TYPE XMLTYPE;
    valid_flag INTEGER;
    p_out     CLOB;
    BEGIN
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
    XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',RECURSE,ANNOTATE,EMBEDCOLL);
    XSD_CLOB := XSD_TYPE.getclobval;
    dbms_xmlschema.deleteSchema('http://www.oracle.com/best.xsd', dbms_xmlschema.DELETE_CASCADE);
    dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', XSD_CLOB);
    sjs.file_util.write_clob(XSD_CLOB,'TEST.xml','C:\XMLAPI_PRODUCE');
    DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
    DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
    sjs.file_util.ReadClob(xml_CLOB,'XML_DIR','TEST.xml');
    xml_type := XMLTYPE.createXML(xml_clob);
    IF xml_type.isSchemaValid(XSD_CLOB) = 1 THEN
    DBMS_OUTPUT.PUT_LINE('Valid xml');
    ELSE
    DBMS_OUTPUT.PUT_LINE('NOT Valid xml');
    END IF;
    DBMS_LOB.CLOSE(xml_CLOB);
    DBMS_LOB.FREETEMPORARY(xml_CLOB);
    dbms_output.put_line(p_out);
    END;

  • Generateschema minlength/maxlength ??

    Can the dbms_xmlschema.generateschema procedure produce minlength and maxlength when producing the schema?
    Thanks

    9.2.0.4
    Windows 2000
    Can the dbms_xmlschema.generateschema generate minlength/maxlength attributes?
    Here is the procedure call:
    XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',FALSE,FALSE,FALSE);
    here is the output portion:
    <?xml version="1.0"?>
    <xsd:schema targetNamespace="http://ns.oracle.com/xdb/SJS" xmlns="http://ns.oracle.com/xdb/SJS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
    <xsd:element name="IncidentRecord" type="XMLAPI_INCIDENT_TYPEType"/>
    <xsd:complexType name="XMLAPI_INCIDENT_TYPEType">
    <xsd:sequence>
    <xsd:element name="I_ID" type="xsd:double"/>
    <xsd:element name="AgencyORI" type="xsd:string"/>
    <xsd:element name="IncidentNumber" type="xsd:string"/>
    <xsd:element name="DivisionPrecinct" type="xsd:string"/>
    <xsd:element name="CaseNumber" type="xsd:string"/>
    <xsd:element name="IncidentType" type="xsd:string"/>
    <xsd:element name="ExternalIncidentID" type="xsd:string"/>
    <xsd:element name="ExternalSourceLocation" type="xsd:string"/>

  • Call to createxml with a schema url does not create schema based xml

    Unfortunately I am unable to post the exact creates that I have done, but I am having a problem and none of my DBA's were able to help me.
    Basically what I have done is, I had existing tables in our database that have legacy data in them. Our ultimate goal is to export information in xml format from the database.
    The first thing I did was to create objects in oracle that wrapped the logic of these tables and filled the objects in based on on ID parameter. There are 3 separate levels of objects. One object that has tables of two other objects each of which has tables of objects themselves.
    After the objects were created, I used a call to dbms_xmlschema.generateschema to generate the schema for these objects. After that I changed the schema so that the names of the elements in the schema were names that i wanted to be. I THOUGHT that this would map my oracle object names to new element names.
    After the schema was generated and changed, I used a call to dbms_xmlschema.registerSchema with the following options:
    local=>true, genTypes=>false, force=>false, GENTABLES=>false, genbean=>false
    I tried it with gentables = true, but unfortunately i don't have access to create these tables and the dba's were not allowing me to because they aren't familiar with the xml capabilities and I couldn't explain why it was necessary. I'm not sure that it is.
    Once the schema was registered, i made a call to xmltype.createxml
    with a call to my object contstructor method as the first parameter, and the schema url that was registered in the database as the second parameter.
    Now, here is my problem. The xmltype result that comes back from the query to createxml does not return the element tag names that i had written in the schema. The tag names are the same as the object names which are the same as it is if i didn't use the schema url at all. Does anyone know what I could possibly be doing wrong? Maybe I am misunderstanding the functionality of creating xml with an oracle xml annotated schema. Please help!

    code tags and formatting are done with square brackets :-) Check out the Formatting Help on the message entry page
    What does the URL resolve to when you view source on the JSP page?
    Try it just "/ViewScores" rather than "/servlet/ViewScores"
    Apart from that, it looks fine to me
    Cheers,
    evnafets

  • Register schema: insufficient privileges to use enablehierarchy

    Hello,
    In Oracle11g release 2 I'm trying to register a schema. It works, as long as I set enablehierarchy to ENABLE_HIERARCHY_NONE.
    For all other values of this parameter, I get this error message:
    ORA-31061: XDB error: DBMS_XDBZ.ENABLE_HIERARCHY
    ORA-06512: at "XDB.DBMS_XDBZ0", line 131
    ORA-06512: at "XDB.DBMS_XDBZ0", line 586
    ORA-01031: insufficient privileges
    ORA-06512: at "XDB.DBMS_XDBZ", line 37
    ORA-06512: at line 1
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 55
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 159
    ORA-06512: at line 4
    for instance, this works:
    declare doc xmltype;
    begin
    select dbms_xmlschema.generateschema(user,'VORM') into doc from dual;
    dbms_xmlschema.registerschema('http://www.5hart.com/schema/vormen.xsd', doc,
    gentypes => false,
    enablehierarchy=>dbms_xmlschema.*ENABLE_HIERARCHY_NONE*);
    end;
    but this doesn't:
    declare doc xmltype;
    begin
    select dbms_xmlschema.generateschema(user,'VORM') into doc from dual;
    dbms_xmlschema.registerschema('http://www.5hart.com/schema/vormen.xsd', doc,
    gentypes => false,
    enablehierarchy=>dbms_xmlschema.*ENABLE_HIERARCHY_CONTENTS*);
    end;
    Could someone tell me what privileges I'm missing? I have the role XDBADMIN, I've tried "grant execute on DBMS_XDBZ, but nothing works.
    Help would be appreciated.
    Thanx,
    Marko
    Edited by: user11998055 on 10-dec-2009 2:09
    Edited by: user11998055 on 10-dec-2009 2:55

    Nowadays I can explain why this works - I think.
    Locally registered xml schemas are protected by ACL's (more or less) and is accessable ONLY by the user that created it (besides SYS). DBA,XDBADMIN, system accounts etc are just not good enough.
    The direct granted "alter session" prevents having to use the full syntax of OWNER.OBJECT_NAME.COLUMN_NAME@DBLINK etc, etc... and thus refering to objects can be reduced to OBJECT_NAME instead of OWNER.OBJECTNAME and makes it possible for the package to do its XDBZ thingy.
    ;-)

  • Restrictive query always returns no rows

    I am trying to run a query with a where clause, but I'm always getting no rows returned. I am obviously overlooking something. Here are my scripts that are on the employee dept tables.
    The scripts run without any errors and when I do a 'select * from dept_xml' I get the complete XML output. However if I run the query
    select * from dept_xml
    where existsNode(sys_nc_rowinfo$, '/DEPT_T[DEPTNO=40]') = 1
    no rows returned
    WHY??
    drop type emp_t force
    drop type emplist_t force
    drop type dept_t force
    drop type deptlist_t force
    drop type depts_t force
    CREATE OR REPLACE TYPE emp_t AS OBJECT
    EMPNO NUMBER(4),
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(8,2),
    COMM NUMBER(8,2)
    CREATE OR REPLACE TYPE emplist_t AS TABLE OF emp_t
    CREATE OR REPLACE TYPE dept_t AS OBJECT
    DEPTNO NUMBER(2),
    DNAME VARCHAR2(14),
    LOC VARCHAR2(13),
    EMPS EMPLIST_T
    CREATE OR REPLACE TYPE deptlist_t AS TABLE OF dept_t
    CREATE OR REPLACE TYPE depts_t AS OBJECT
    DEPTS DEPTLIST_T
    begin
    dbms_xmlschema.deleteSchema('http://www.oracle.com/depts.xsd', 4);
    dbms_xmlschema.registerSchema('http://www.oracle.com/depts.xsd', dbms_xmlschema.generateschema('SCOTT','DEPT_T'),TRUE,FALSE);
    end;
    CREATE OR REPLACE VIEW dept_xml OF XMLTYPE
    XMLSCHEMA "http://www.oracle.com/depts.xsd" ELEMENT "DEPT_T"
    WITH OBJECT ID (sys_nc_rowinfo$.extract('/DEPT_T/DEPTNO').getNumberVal())
    AS
    SELECT dept_t(d.deptno,
    d.dname,
    d.loc,
    cast(multiset(SELECT emp_t(e.empno,
    e.ename,
    e.job,
    e.mgr,
    e.hiredate,
    e.sal,
    e.comm)
    FROM emp e
    WHERE e.deptno = d.deptno)
    AS emplist_t))
    FROM dept d;

    #1. I would strong recommend using the SQL/XML operators (XMLElement, XMLForest etc)to define your view, rather than creating SQL Types. We will be focusing future development on improving the performance and functionality of the SQL/XML operators, so these operators are now the preferred approach.
    #2 Please post the XML document that is generated by teh view. I suspect that the XPATH expression does not match the generated docuemnt.

  • Tool to create XML definition, a tool for creating XSD

    I need a tool to create XML definition, a tool for creating XSD.
    I was trying to do this with Oracle packages. But again there are some problems. Could you tell me which one, I should use?
    Can I do it with the Oracle SQL Developer?

    Hello,
    i get the error message and I don't know, what I can do
    The user have the permissions to use DBMS_LOB package.
    Is it the sofware, do I need a license version tool for XML generation
    SQL> select DBMS_XMLSCHEMA.GENERATESCHEMA( 'HR', 'EMP_DATA' )
    2 from dual;
    select DBMS_XMLSCHEMA.GENERATESCHEMA( 'HR', 'EMP_DATA' )
    ERROR at line 1:
    ORA-00904: "DBMS_XMLSCHEMA"."GENERATESCHEMA": invalid identifier

  • ORA-19034

    Hi all,
    I'm trying to generate schema to custom type like:
    CREATE OR REPLACE TYPE my_type AS OBJECT
    (field1 number(1),
    field2 varchar2(10));
    CREATE OR REPLACE TYPE my_type_ct as table of my_type;
    The select DBMS_XMLSCHEMA.GENERATESCHEMA(user,'MY_TYPE' ) from dual works fine, but by
    select DBMS_XMLSCHEMA.GENERATESCHEMA(user,'MY_TYPE_CT' ) from dual -I'm getting ORA-19034.
    What I'm missing?
    Thanks a lot,
    Alex

    Hi,
    GENERATESCHEMA works on scalar object types, so that the generated schema describes a single-rooted XML content (i.e. an XML document).
    To make it work in your case, you'll have to create another object type containing the collection and build the schema from it.

  • Generate + register xml schema

    Hi,
    I want to generate and register an xml schema based on the following object type :
    CREATE TYPE STRAAT_T AS OBJECT
    naam varchar2(50),
    prv_cd number(1),
    arr_cd number(1),
    gem_cd number(3)
    I ran the following pl/sql code :
    begin
    dbms_xmlschema.registerSchema(schemaURL=>'http://www.oracle.com/straat.xsd',
    schemaDoc=>dbms_xmlschema.generateschema('TEST_RKW','STRAAT_T'));
    end;
    but got the following error code :
    .ORA-31094: Incompatible SQL-type "STRAAT_T" for attribute of element "STRAAT_T".
    What is wrong with this ???
    tx for any help.

    Roger
    Since the Type already exists you need to pass the value 'FALSE', as the fourth argument to registerSchema().
    Eg
    CREATE or replace TYPE STRAAT_T AS OBJECT
    naam varchar2(50),
    prv_cd number(1),
    arr_cd number(1),
    gem_cd number(3)
    begin
    dbms_xmlschema.registerSchema('http://www.oracle.com/straat.xsd', dbms_xmlschema.generateschema('SCOTT','STRAAT_T'),TRUE,FALSE);
    end;
    /

  • Marshaling problem in creation of xml thru JAXB

    Hi java gurus,
    I am trying to create an XML which will has the data of database using JAXB. I am able to generate JAXB classes, but its giving some error the stack trace is like this
    java.lang.NoSuchMethodError: com.sun.xml.bind.marshaller.XMLWriter.setXmlDecl(Z)V
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:223)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:238)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:233)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:126)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:66)
         at org.bas.dss.common.dao.MetaDAO.createInstInformation(MetaDAO.java:627)
         at org.bas.core.fidownload.DownloadActionHandler.getInstInfoXMLData(DownloadActionHandler.java:163)
         at org.bas.core.fidownload.DownloadActionHandler.performPreDownloadAction(DownloadActionHandler.java:74)
         at org.bas.core.fidownload.DownloadAction.perform(DownloadAction.java:129)
         at org.bas.core.fidownload.DownloadAction.execute(DownloadAction.java:79)
    the method is like this,
    valueObject = getInstInformation (registrationId, appVersionId);
    System.out.println("MetaDAO-->valueObject:"+valueObject); //here i am gettingthe object
    context = JAXBContext.newInstance("org.bas.dss.common.vo.bii");
    System.out.println("MetaDAO-->context:"+context); //here i am getting the context
    sumissionInfoMarshaller = context.createMarshaller();
    System.out.println("MetaDAO-->sumissionInfoMarshaller:"+sumissionInfoMarshaller); //here also i am getting some object type
    sumissionInfoMarshaller.setProperty(
    Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
    System.out.println("MetaDAO-->MetaDAO-->");
    sumissionInfoMarshaller.marshal (valueObject, streamToWrite); // the problem is coming here.
    anyone can suggest what will be the problem, and tell me how can i resolve this issue,
    thanks in advance,
    varma

    Pl post this question to SDK Forum

  • Upgrading to JAXB/JWSDP1.3 from JAXB/JWSDP 1.2 -- problems

    I am seeing 2 problems after upgrading to the JAXB found in WSDP 1.3 (from 1.2)
    We are using JAXB in a client/server style app where the server is accessed via a web interface and the client is delivered via Java Web Start (JWS). Both the server and client use JAXB-generated classes.
    We have an ant build.xml file that invokes xjc and this was working for us as expected.
    For the JWS piece, we need to sign the jars we use and for testing purposes we were self-signing them, including the jar files needed for JAXB also self-signed. This is also coordinated through an ant task.
    After replacing the jar files in our lib area with the ones from my recent download of the 1.3 version of JAXB the following happens.
    1. I am seeing compiler deprecation warnings for the generated code -- this did not happen in our use of JAXB from 1.2. For example:
    [javac] /Users/jjs/Projects/SGS-Install-Fixed/sgs/src/com/gestalt/sgs/uobdif/impl/runtime/SAXMarshaller.java:259: warning: ERR_MISSING_OBJECT in com.sun.xml.bind.marshaller.Messages has been deprecated
    [javac] Messages.format(Messages.ERR_MISSING_OBJECT), null,
    [javac] ^
    I am using Java 1.4.1 on Max OS X (I know... not supported but this doesn't seem like a platform dependency) and these warnings go away if I revert back to the JAXB jars from the 1.2 release of WSDP.
    2. These are only warnings, so my build proceeds with ant. But, when I get to the jar signing step I see:
    [signjar] Signing Jar : /Users/jjs/Projects/SGS-Install-Fixed/sgs/lib/jaxb-libs.jar
    [signjar] jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 63854 but got 19845 bytes)
    I looked at the jar file using the jar command and there are entries there:
    4038 Wed Dec 03 22:16:20 EST 2003 META-INF/MANIFEST.MF
    3303 Wed Dec 03 22:16:20 EST 2003 META-INF/SUN_MICR.RSA
    3780 Wed Dec 03 22:16:20 EST 2003 META-INF/SUN_MICR.SF
    0 Wed Dec 03 22:16:20 EST 2003 META-INF/pack.properties
    that suggest to me that perhaps the jar is now sigend by Sun and therefore can't be signed again. If I look at the corresponding jar from the JAXB/1.2, these SUN_MICR entries do not appear.
    Is this assumption correct? Can I deliver my app through web start with my apps own jars self-signed and the JAXB jars signed by Sun? I suppose I can un-jar the JAXB jars, remove the manifest material and then re-jar the files and sign those. I expect this might work.
    I am looking to share migration experiences (1.2 to 1.3) and to see what work-arounds there might be.
    Thanks
    Jim

    Replying to my own post.
    It seems that with the JWSDP 1.3 release, most (if not all) of the included jars are signed by Sun. You can NOT include jars with different signatures in the same web start application -- that's the error I get when I tried to do this.
    This means that if I want to package my jars using a self-signed certificate, I have to first un-jar all of the JAXB lib jars I want to include, get rid of the parts of the manifest that deal with signing, re-jar them and then sign all of the jars in my web start app using my own cert. More work for me, but not a show-stopper.
    I still am not sure why I am getting deprecated warnings from javac though.
    Jim

  • How to read the attribute of the xml file using jaxb

    Thanks,
    Buddy as i have a issue i have to read the xml file using jaxb and xml file contains this data and i have read the attribute like name , desc and action for a particular menu name pls tell the code how to do this it will be a great favour to me
    thanx in advance
    Rasool
    <contextmenu>
    <menu name='Lead' >
    <menuitem name='newlead' desc='New Lead' action='/leads.do?dispatch=insert' />
    <menuitem name='editlead' desc='Edit Lead' action='' />
    <menuitem name='leadinfo' desc='Lead Information' action='' />
    </menu>
    <menu name='Cases' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    <menu name='Contact' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    </contextmenu>

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • Dbms_xmlschema.registerschema, (ORA-31084: error while creating table )..

    Hello,
    I have some problems with dbms_xmlschema.registerschema
    My database is: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    My XSD schema is (SEPA pain.002.001.03.xsd) also available on this url: http://code.google.com/p/leontestbed/source/browse/trunk/bc2/sample/Schema/pain.002.001.03.xsd?r=241
    After
    begin
       DOK_XML_UTIL.p_vnesi_xsd_blob(401941242); -- store a XSD on file system from blob field
       dbms_xmlschema.registerschema(
        schemaurl => 'http://localhost/TEST1.XSD',
        schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
        csid => nls_charset_id('AL32UTF8'));
    commit;
    end;I get:
    ORA-31084: error while creating table "INIS_PROD"."Document2781_TAB" for element "Document"
    ORA-02320: failure in creating storage table for nested table column "XMLDATA"."CstmrPmtStsRpt"."OrgnlPmtInfAndSts"
    ORA-01792: maximum number of columns in a table or view is 1000
    ORA-02310: exceeded maximum number of allowable columns in table
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 65
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 136
    ORA-06512: at line 4
    What I'am doing wrong or what is the reason for this error..

    Arrgghhh.....
    begin
       DOK_XML_UTIL.p_vnesi_xsd_blob(401941242);
       dbms_xmlschema.registerschema(
        schemaurl => 'http://localhost/TEST1.XSD',
        schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
        csid => nls_charset_id('AL32UTF8')
        , local => true
      , genTypes => false
      , genTables => false);
    commit;
    end;sorry...

Maybe you are looking for

  • Find words within a text file

    Hey all. I am playing around with the idea of finding a line of text within a text file, by using scanner and some next methods. The way I am trying to get it to work is that one enters a string and the program then finds all the lines of text contai

  • How to create Header and Footer  template

    Hi, I am wondering if this is possible, if yes , can some help me please? At present we have preprinted stationary for invoices and now the plan is to get rid of preprinted stationary and print header and footer via oracle reports directly. The addre

  • Connect MDM components (MDM, MDIS) with Oracle (MCOD)

    Hello! I successfully installed SRM-MDM Catalog with MDS and MDIS and MDM console (scenario: SAP EHP4 ERP system with SRM server, SAP EP EHP1 and SRM-MDM Catalog). Now I would like to integrate MDM with Oracle. On the server I allready have 2 Oracle

  • CMOD Enhancements

    Hi please confirm that you want to convey that i can write the actual code in CMOD exit_rsap_saplr_001 for transactional data?? if i put 20 data sources enhancement code in there is'nt that too bulky and will cause the failing all extractor if one co

  • Lifecycle Rights Management ES for CATIA

    Hello, I would just like to confirm a few points considering CATIA and Microsoft Office documents. Digital rights of native CATIA files cannot be controlled directly . They must be converted to pdf in order apply rights management. Thus, file distrib