Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generated schema on a query returns xsd:string for date data type

541305Oct 23 2006 — edited Oct 27 2006
I'm a complete newbie to oracle's xml generation and have encountered the following problem. But first the important details:
select * from v$version

Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
"CORE 10.2.0.2.0 Production"
TNS for Linux: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production

--
We have a large number of dynamic queries that we would like to generate xml for. I'm currently using the dbms_query.getXML(context, 2) to generate the schema definition for the columns as well as the xml row data. Currently, the problem I have is that the schema definition for date columns is being returned as xsd:string rather than xsd:date. I've no idea why it is coming back that way, and haven't found anything to point me in the direction of any configuration data where this can be changed. Here is the table and code I'm using:

query: select dbms_xmlquery.getxml('select * from clh_xml_test',2) from dual

table definition:
create table CLH_XML_TEST
(
ID NUMBER not null,
NAME VARCHAR2(50) not null,
DATE_COL DATE,
EMAIL_ADDRESS VARCHAR2(100) not null,
URL VARCHAR2(100) not null,
TIMESTAMP_COL DATE
)

Sample results:
<?xml version="1.0"?>
<DOCUMENT xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ROWSET">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xsd:double" minOccurs="0"/>
<xsd:element name="NAME" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="DATE_COL" type="xsd:string" nillable="true" minOccurs="0"/>
<xsd:element name="EMAIL_ADDRESS" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="URL" nillable="true" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="TIMESTAMP_COL" type="xsd:string" nillable="true" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<ROWSET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#/DOCUMENT/xsd:schema[not(@targetNamespace)]">
<ROW num="1">
<ID>779451193</ID>
<NAME>Clh Test</NAME>
<DATE_COL>1/1/2001 0:0:0</DATE_COL>
<EMAIL_ADDRESS>test@gmail.com</EMAIL_ADDRESS>
<URL>http://www.google.com</URL>
<TIMESTAMP_COL>7/8/2004 10:7:4</TIMESTAMP_COL>
</ROW>
</ROWSET>
</DOCUMENT>

Thank you for your help, let me know if I can provide any additional information.
Chris

Message was edited by:
user538302
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2006
Added on Oct 23 2006
1 comment
574 views