My Oracle Support Banner

DBMS_XMLSchema.generateSchema can't generate correct XML schema with attributes (Doc ID 1349296.1)

Last updated on FEBRUARY 03, 2019

Applies to:

Oracle Server - Enterprise Edition - Version: and later   [Release: 11.2 and later ]
Information in this document applies to any platform.


DBMS_XMLSchema.generateSchema generates wrong XSD.

SQL> create or replace type emp_t as object
 2  (
 3   "@id" number(6),
 4   email varchar2(25),
 5   department_id number(4));
 6  /

Type created.

SQL> SELECT DBMS_XMLSchema.generateSchema('XDBTEST', 'EMP_T') as result from dual;

<?xml version="1.0"?>
<xsd:schema xmlns:xsd=""
<xsd:element name="EMP_T" type="EMP_TType" xdb:SQLType="EMP_T" xdb:SQLSchema="XDBTEST"/>
<xsd:complexType name="EMP_TType" xdb:SQLType="EMP_T" xdb:SQLSchema="XDBTEST" xdb:maintainDOM="false">
    <xsd:element name="_x0040_id" type="xsd:double" xdb:SQLName="@id" xdb:SQLType="NUMBER"/>
    <xsd:element name="EMAIL" xdb:SQLName="EMAIL" xdb:SQLType="VARCHAR2">
       <xsd:restriction base="xsd:string">
        <xsd:maxLength value="25"/>
    <xsd:element name="DEPARTMENT_ID" type="xsd:double" xdb:SQLName="DEPARTMENT_ID" xdb:SQLType="NUMBER"/>

This should be an attribute:

<xsd:element name="_x0040_id" type="xsd:double" xdb:SQLName="@id" xdb:SQLType="NUMBER"/>


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.