XDB schema evolution help
Hello,
I am currently working on a proof of concept using Oracle's XMLTYPE. I have successfully registered a schema and created a table that has an XMLTYPE column that is bound to the registered schema. Everything works perfect - invalid XML docs are rejected and valid XML docs are inserted without error.
I am now working through schema evolution. Since it is unlikely that our schemas will change drastically, I am testing the inplaceevolve functionality.
I have written a quick procedure and it looks like the evolve is working without error. Doing a quick SELECT * FROM USER_XML_SCHEMAS shows that the schema was updated - awesome!
When I go to insert an XML document through my client, it inserts fine with no errors! However, when I try to view the row in the SQL Navigator I get the following error.
ORA-30991: cannot use DOM to add special attribute to schema-based parent
I can still view the old documents but none of the new ones - what could I be missing?
Thanks for looking and especially any help provided.
Best!
Brian
Got the issue resoved.
Initially the schema was created in the local domain of the user. The updated schema was registered in the public domain.
The table Name301_TAB was therefore created under the user domain and the CopyEvolve() function was looking for the function in Public domain.
Thanks for the help.
Similar Messages
-
Errors when using inplace schema evolution
Hi, i have been having some issues when attempting to use inplace schema evolution to add a new element into an existing xsd file currently registered on the database and was looking for some help with this if possible.
Firstly, Oracle details are as follows :
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS for IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionThe xsd registered on the database is called truncheadtest2.xsd :
<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
<xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
<xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
<xs:sequence>
<xs:element ref="title" xdb:SQLName="TITLE"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>registered via :
BEGIN
DBMS_XMLSCHEMA.registerSchema(
SCHEMAURL => 'http://xmlns.kfis.co.uk/testevheader/xsdin/truncheadertest.xsd',
SCHEMADOC => XDBURIType('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtest2.xsd').getCLOB());
END;i have then created a new xsd, to add the new element to the xsd (using minoccurs to allow backwards compatibility between xml files conforming to the 1st xsd and this new xsd), called truncheadtestfn3.xsd :
<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
<xs:element name="forename">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
<xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
<xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
<xs:sequence>
<xs:element ref="title" xdb:SQLName="TITLE"/>
<xs:element ref="forename" minOccurs="0" xdb:SQLName="FORENAME"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>I can run the following code to create the difference doc between the 2 versions of the schema document, without errors:
DECLARE
schemaDiff XMLType;
res boolean;
BEGIN
SELECT xmlDiff
xdburitype('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtest2.xsd').getXML(),
xdburitype('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtestfn3.xsd').getXML()
INTO schemaDiff
FROM dual;
IF (dbms_xdb.existsResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml')) THEN
dbms_xdb.deleteResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml');
END IF;
res :=
dbms_xdb.createResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml',schemaDiff);
dbms_xmlschema.inPlaceEvolve('http://xmlns.kfis.co.uk/testevheader/xsdin/truncheadertest.xsd',schemaDiff,2);
END;
/ which creates the following xml file:
- <xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?>
- <xd:insert-node-before xd:node-type="element" xd:xpath="/xs:schema[1]/xs:element[2]">
- <xd:content>
- <xs:element name="forename">
- <xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:element>
</xd:content>
</xd:insert-node-before>
- <xd:append-node xd:node-type="element" xd:parent-xpath="/xs:schema[1]/xs:element[2]/xs:complexType[1]/xs:sequence[1]">
- <xd:content>
<xs:element ref="forename" minOccurs="0" xdb:SQLName="FORENAME" />
</xd:content>
</xd:append-node>
</xd:xdiff>However, when i then run the inplace schema evolution code for option 1, i get the following error:
Error report:
ORA-22324: altered type has compilation errors
ORA-22328: object "WEB_STAGING"."EVLN_CLIENTRISKEVENTHEADER_T" has errors.
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 173
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 231
ORA-06512: at line 17
22324. 00000 - "altered type has compilation errors"
*Cause: The use of the ALTER TYPE statement caused a compilation error.
*Action: Correct the error reported and resubmit the statement.I am getting this issue when attempting to add any string value to the existing xsd and i was wondering if you had any idea what the issue was here and how i could resolve this.
Thanks.Hi,
When you use INPLACE_TRACE flag, it traces the operations that would be performed with option 1.
If you look at the trace file produced in this case, you'll see where the error is coming from :
------------ QMTS Executing SQL ------------
ALTER TYPE "TEST"."EVLN_CLIENTRISKEVENTHEADER_T" ADD ATTRIBUTE "FORENAME" VARCHAR2 CASCADE NOT INCLUDING TABLE DATA
/The mandatory length specification is absent.
I thought adding an explicit xs:maxLength restriction would solve the problem, but it happens the generated DDL still lacks the length specification.
After some tries, I found that the issue seems related to the usage of ref elements in the schema.
On a side note, it's not the first time we see problems associated with ref (Cf. how do i get xml db to work right with imported or included schemas?).
The workaround is to use a named type.
I've also added an xdb:defaultTable annotation to the top-level element ("title") so that the registration process doesn't generate a table for it :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="title" xdb:defaultTable="">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:simpleType name="forenameType">
<xs:restriction base="xs:string">
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
<xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
<xs:sequence>
<xs:element ref="title" xdb:SQLName="TITLE"/>
<xs:element name="forename" type="forenameType" minOccurs="0" xdb:SQLName="FORENAME"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema> -
Copy Evolve Schema Evolution Fails
Oracle 11gr2 on Linux VM
SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 22 13:51:28 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: jmendez
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production I've been able to get schema evolution to work without data in the table (doesnt help much). When I have data in the table I get the following error message:
BEGIN
2 DBMS_XMLSCHEMA.copyEvolve(
3 xdb$string_list_t('http://localhost/xsd/test/collection_test_3.xsd'),
4 XMLSequenceType(XDBURIType('/u01/app/xsd/test/collection_evolve_3.xsd').getXML()),
5 XMLSequenceType(XDBURIType('/u01/app/xsd/test/collection_evolve_3.xsl').getXML()));
6 END;
7 /
BEGIN
ERROR at line 1:
ORA-30942: XML Schema Evolution error for schema
'http://localhost/xsd/test/collection_test_3.xsd' table
"JMENDEZ"."COLLECTION_TEST" column 'XML_DATA'
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: '()'
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 153
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 221
ORA-06512: at line 2I've registered the schema's and loaded revised schema and xsl style sheets into the database. Before I try schema evolution I create the proper context and xml indexes and run a few queries with sample data. This works just fine. I drop the indexes prior to starting schema evolution and run the above command. It fails every time.
CREATE TABLE collection_test
NAID NUMBER not null enable,
opa_counter number,
xml_data XMLType not null enable,
desc_type varchar2(25 byte),
constraint "PK_CL_NAID" Primary key ("NAID")
XMLTYPE COLUMN "XML_DATA" STORE AS BASICFILE CLOB
XMLSCHEMA "http://localhost/xsd/test/collection_test_3.xsd" ELEMENT "collection";
INSERT INTO COLLECTION_TEST(naid,XML_DATA) VALUES (111112,XMLTYPE('<collection>
<collectionIdentifier>AAS</collectionIdentifier>
<dataControlGroup>ou\=NW,ou\=groups,dc\=das,dc\=nara,dc\=gov</dataControlGroup>
<dateApproved>
<day>3</day>
<month>12</month>
<year>2001</year>
</dateApproved>
<dateEntered>
<day>3</day>
<month>12</month>
<year>2001</year>
</dateEntered>
<descriptionType>6021989</descriptionType>
<inclusiveEndDate>
<year>1926</year>
</inclusiveEndDate>
<inclusiveStartDate>
<year>1923</year>
</inclusiveStartDate>
<isUnderEdit>false</isUnderEdit>
<naId>766</naId>
<organizationalDonorArray>
<organizationName>
<naId>6505115</naId>
</organizationName>
</organizationalDonorArray>
<title>American Antiquarian Society Collection</title>
<variantControlNumberArray>
<variantControlNumber>
<number>AAS</number>
<variantControlNumberType>
<naId>6044072</naId>
</variantControlNumberType>
</variantControlNumber>
</variantControlNumberArray>
</collection>')); I've used mapforce to generate my XSL file.
I can't seem to find the right resource online for my problem. Any help or redirection is greatly appreciated. Thanks
-jjm
Edited by: jjmdb on Feb 22, 2012 10:51 AMI am testing schema evolution in a test environment. I'm only changing the xsd file and adding a new element (fullTitle) and having the data that copied from title to fulltitle.
BEFORE
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Description : Collections XML schema
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="0.3">
<!--
- Include document detailing common Archival Types
-->
<xs:include schemaLocation="ArchivalTypes.xsd"/>
<!--
- Main XML definition
-->
<xs:element name="collection" type="coll_type"/>
<xs:complexType name="coll_type">
<xs:sequence>
<xs:element name="approvedBy" type="xs:string" minOccurs="0"/>
<xs:element name="collectionIdentifier" type="xs:string" minOccurs="0"/>
<xs:element name="coverageEndDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="coverageStartDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="dataControlGroup" type="xs:string" minOccurs="0"/>
<xs:element name="dateApproved" type="dasDate" minOccurs="0"/>
<xs:element name="dateEntered" type="dasDate" minOccurs="0"/>
<xs:element name="dateNote" type="xs:string" minOccurs="0"/>
<xs:element name="descriptionAuthorArray" type="descriptionAuthorArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="descriptionDateArray" type="dasDateArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="descriptionType" type="xs:long" minOccurs="0"/>
<xs:element name="enteredBy" type="xs:string" minOccurs="0"/>
<xs:element name="findingAidArray" type="findingAidArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="formerlyContainedArray" type="seriesArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="inclusiveEndDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="inclusiveStartDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="isUnderEdit" type="xs:boolean" minOccurs="0"/>
<xs:element name="naId" type="xs:long" minOccurs="1"/>
<xs:element name="organizationalDonorArray" type="organizationNameArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="personalDonorArray" type="personArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="preliminaryDescriptionArray" type="preliminaryDescriptionArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="scopeAndContentNote" type="xs:string" minOccurs="0"/>
<xs:element name="seriesArray" type="seriesArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="staffOnlyNote" type="xs:string" minOccurs="0"/>
<xs:element name="title" type="xs:string" minOccurs="0"/>
<xs:element name="variantControlNumberArray" type="variantControlNumberArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
AFTER
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Description : Collections XML schema
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="0.3">
<!--
- Include document detailing common Archival Types
-->
<xs:include schemaLocation="ArchivalTypes.xsd"/>
<!--
- Main XML definition
-->
<xs:element name="collection" type="coll_type"/>
<xs:complexType name="coll_type">
<xs:sequence>
<xs:element name="approvedBy" type="xs:string" minOccurs="0"/>
<xs:element name="collectionIdentifier" type="xs:string" minOccurs="0"/>
<xs:element name="coverageEndDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="coverageStartDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="dataControlGroup" type="xs:string" minOccurs="0"/>
<xs:element name="dateApproved" type="dasDate" minOccurs="0"/>
<xs:element name="dateEntered" type="dasDate" minOccurs="0"/>
<xs:element name="dateNote" type="xs:string" minOccurs="0"/>
<xs:element name="descriptionAuthorArray" type="descriptionAuthorArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="descriptionDateArray" type="dasDateArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="descriptionType" type="xs:long" minOccurs="0"/>
<xs:element name="enteredBy" type="xs:string" minOccurs="0"/>
<xs:element name="findingAidArray" type="findingAidArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="formerlyContainedArray" type="seriesArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="inclusiveEndDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="inclusiveStartDate" type="qualifiableDate" minOccurs="0"/>
<xs:element name="isUnderEdit" type="xs:boolean" minOccurs="0"/>
<xs:element name="naId" type="xs:long" minOccurs="1"/>
<xs:element name="organizationalDonorArray" type="organizationNameArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="personalDonorArray" type="personArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="preliminaryDescriptionArray" type="preliminaryDescriptionArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="scopeAndContentNote" type="xs:string" minOccurs="0"/>
<xs:element name="seriesArray" type="seriesArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="staffOnlyNote" type="xs:string" minOccurs="0"/>
<xs:element name="title" type="xs:string" minOccurs="0"/>
<xs:element name="fullTitle" type="xs:string" minOccurs="0"/>
<xs:element name="variantControlNumberArray" type="variantControlNumberArray" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>XSLT
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file was generated by Altova MapForce 2012sp1
YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
Refer to the Altova MapForce Documentation for further details.
http://www.altova.com/mapforce
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:core="http://www.altova.com/MapForce/UDF/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="core xs fn">
<xsl:template name="core:convert-uri-to-windows-file-path">
<xsl:param name="uri" select="()"/>
<xsl:choose>
<xsl:when test="fn:starts-with($uri, 'file://')">
<xsl:choose>
<xsl:when test="(fn:substring($uri, xs:double('6'), xs:double('3')) = '///')">
<xsl:variable name="var1_resultof_url_decode" as="xs:string">
<xsl:call-template name="core:url-decode">
<xsl:with-param name="uri" select="fn:substring($uri, xs:double('9'), xs:double(fn:string-length($uri)))" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:sequence select="fn:translate($var1_resultof_url_decode, '/|', '\:')"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$uri"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$uri"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="core:url-decode">
<xsl:param name="uri" select="()"/>
<xsl:choose>
<xsl:when test="fn:contains($uri, '%')">
<xsl:variable name="var1_resultof_url_decode_part" as="xs:string">
<xsl:call-template name="core:url-decode-part">
<xsl:with-param name="uripart" select="fn:substring-after($uri, '%')" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:sequence select="fn:concat(fn:substring-before($uri, '%'), $var1_resultof_url_decode_part)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$uri"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="core:url-decode-part">
<xsl:param name="uripart" select="()"/>
<xsl:variable name="var1_resultof_dec_from__digits_hex" as="xs:decimal">
<xsl:call-template name="core:dec-from-2digits-hex">
<xsl:with-param name="hex" select="$uripart" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="($var1_resultof_dec_from__digits_hex < xs:decimal('128'))">
<xsl:call-template name="core:url-decode-utf8">
<xsl:with-param name="value" select="$var1_resultof_dec_from__digits_hex" as="xs:decimal"/>
<xsl:with-param name="bytes" select="xs:decimal('0')" as="xs:decimal"/>
<xsl:with-param name="rest" select="fn:substring($uripart, xs:double('3'), xs:double(fn:string-length($uripart)))" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="($var1_resultof_dec_from__digits_hex < xs:decimal('194'))">
<xsl:call-template name="core:url-decode">
<xsl:with-param name="uri" select="fn:substring($uripart, xs:double('3'), xs:double(fn:string-length($uripart)))" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="($var1_resultof_dec_from__digits_hex < xs:decimal('224'))">
<xsl:call-template name="core:url-decode-utf8">
<xsl:with-param name="value" select="$var1_resultof_dec_from__digits_hex" as="xs:decimal"/>
<xsl:with-param name="bytes" select="xs:decimal('1')" as="xs:decimal"/>
<xsl:with-param name="rest" select="fn:substring($uripart, xs:double('3'), xs:double(fn:string-length($uripart)))" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="($var1_resultof_dec_from__digits_hex < xs:decimal('240'))">
<xsl:call-template name="core:url-decode-utf8">
<xsl:with-param name="value" select="$var1_resultof_dec_from__digits_hex" as="xs:decimal"/>
<xsl:with-param name="bytes" select="xs:decimal('2')" as="xs:decimal"/>
<xsl:with-param name="rest" select="fn:substring($uripart, xs:double('3'), xs:double(fn:string-length($uripart)))" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="($var1_resultof_dec_from__digits_hex < xs:decimal('245'))">
<xsl:call-template name="core:url-decode-utf8">
<xsl:with-param name="value" select="$var1_resultof_dec_from__digits_hex" as="xs:decimal"/>
<xsl:with-param name="bytes" select="xs:decimal('3')" as="xs:decimal"/>
<xsl:with-param name="rest" select="fn:substring($uripart, xs:double('3'), xs:double(fn:string-length($uripart)))" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="''"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="core:dec-from-2digits-hex">
<xsl:param name="hex" select="()"/>
<xsl:variable name="var1_resultof_dec_from__digit_hex" as="xs:decimal">
<xsl:call-template name="core:dec-from-1digit-hex">
<xsl:with-param name="hex" select="fn:substring($hex, xs:double('1'), xs:double('1'))" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="var2_resultof_dec_from__digit_hex" as="xs:decimal">
<xsl:call-template name="core:dec-from-1digit-hex">
<xsl:with-param name="hex" select="fn:substring($hex, xs:double('2'), xs:double('1'))" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:sequence select="(($var1_resultof_dec_from__digit_hex * xs:decimal('16')) + $var2_resultof_dec_from__digit_hex)"/>
</xsl:template>
<xsl:template name="core:url-decode-utf8">
<xsl:param name="value" select="()"/>
<xsl:param name="bytes" select="()"/>
<xsl:param name="rest" select="()"/>
<xsl:choose>
<xsl:when test="($bytes = xs:integer('0'))">
<xsl:variable name="var1_resultof_char_from_code" as="xs:string">
<xsl:call-template name="core:char-from-code">
<xsl:with-param name="code" select="xs:integer($value)" as="xs:integer"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="var2_resultof_url_decode" as="xs:string">
<xsl:call-template name="core:url-decode">
<xsl:with-param name="uri" select="$rest" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:sequence select="fn:concat($var1_resultof_char_from_code, $var2_resultof_url_decode)"/>
</xsl:when>
<xsl:when test="(fn:substring($rest, xs:double('1'), xs:double('1')) = '%')">
<xsl:variable name="var3_resultof_cast" as="xs:double" select="xs:double(fn:string-length($rest))"/>
<xsl:variable name="var4_resultof_dec_from__digits_hex" as="xs:decimal">
<xsl:call-template name="core:dec-from-2digits-hex">
<xsl:with-param name="hex" select="fn:substring($rest, xs:double('2'), $var3_resultof_cast)" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="core:url-decode-utf8">
<xsl:with-param name="value" select="((($value mod xs:decimal('64')) * xs:decimal('64')) + ($var4_resultof_dec_from__digits_hex mod xs:decimal('64')))" as="xs:decimal"/>
<xsl:with-param name="bytes" select="($bytes - xs:decimal('1'))" as="xs:decimal"/>
<xsl:with-param name="rest" select="fn:substring($rest, xs:double('4'), $var3_resultof_cast)" as="xs:string"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="core:url-decode">
<xsl:with-param name="uri" select="$rest" as="xs:string"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="core:dec-from-1digit-hex">
<xsl:param name="hex" select="()"/>
<xsl:variable name="var1_resultof_string_length" as="xs:integer" select="fn:string-length(fn:substring-before('0123456789ABCDEFabcdef', $hex))"/>
<xsl:choose>
<xsl:when test="($var1_resultof_string_length <= xs:integer('15'))">
<xsl:sequence select="$var1_resultof_string_length"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="($var1_resultof_string_length - xs:decimal('6'))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="core:char-from-code">
<xsl:param name="code" select="()"/>
<xsl:sequence select="fn:codepoints-to-string($code)"/>
</xsl:template>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_resultof_document" as="node()" select="."/>
<xsl:variable name="var2_resultof_convert_uri_to_windows_file_path" as="xs:string">
<xsl:call-template name="core:convert-uri-to-windows-file-path">
<xsl:with-param name="uri" select="fn:document-uri($var1_resultof_document)" as="xs:string"/>
</xsl:call-template>
</xsl:variable>
<xsl:result-document href="{$var2_resultof_convert_uri_to_windows_file_path}" encoding="UTF-8">
<collection>
<xsl:attribute name="xsi:noNamespaceSchemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance" select="'C:/Users/Javier/Documents/XML/XSD/collection_evolve_2.xsd'"/>
<xsl:for-each select="$var1_resultof_document/collection">
<xsl:variable name="var3_title" as="node()?" select="title"/>
<xsl:for-each select="approvedBy">
<approvedBy>
<xsl:sequence select="fn:string(.)"/>
</approvedBy>
</xsl:for-each>
<xsl:for-each select="collectionIdentifier">
<collectionIdentifier>
<xsl:sequence select="fn:string(.)"/>
</collectionIdentifier>
</xsl:for-each>
<xsl:for-each select="coverageEndDate">
<coverageEndDate>
<xsl:sequence select="(./@node(), ./node())"/>
</coverageEndDate>
</xsl:for-each>
<xsl:for-each select="coverageStartDate">
<coverageStartDate>
<xsl:sequence select="(./@node(), ./node())"/>
</coverageStartDate>
</xsl:for-each>
<xsl:for-each select="dataControlGroup">
<dataControlGroup>
<xsl:sequence select="fn:string(.)"/>
</dataControlGroup>
</xsl:for-each>
<xsl:for-each select="dateApproved">
<dateApproved>
<xsl:sequence select="(./@node(), ./node())"/>
</dateApproved>
</xsl:for-each>
<xsl:for-each select="dateEntered">
<dateEntered>
<xsl:sequence select="(./@node(), ./node())"/>
</dateEntered>
</xsl:for-each>
<xsl:for-each select="dateNote">
<dateNote>
<xsl:sequence select="fn:string(.)"/>
</dateNote>
</xsl:for-each>
<xsl:for-each select="descriptionAuthorArray">
<descriptionAuthorArray>
<xsl:sequence select="(./@node(), ./node())"/>
</descriptionAuthorArray>
</xsl:for-each>
<xsl:for-each select="descriptionDateArray">
<descriptionDateArray>
<xsl:sequence select="(./@node(), ./node())"/>
</descriptionDateArray>
</xsl:for-each>
<xsl:for-each select="descriptionType">
<descriptionType>
<xsl:sequence select="xs:string(xs:integer(fn:string(.)))"/>
</descriptionType>
</xsl:for-each>
<xsl:for-each select="enteredBy">
<enteredBy>
<xsl:sequence select="fn:string(.)"/>
</enteredBy>
</xsl:for-each>
<xsl:for-each select="findingAidArray">
<findingAidArray>
<xsl:sequence select="(./@node(), ./node())"/>
</findingAidArray>
</xsl:for-each>
<xsl:for-each select="formerlyContainedArray">
<formerlyContainedArray>
<xsl:sequence select="(./@node(), ./node())"/>
</formerlyContainedArray>
</xsl:for-each>
<xsl:for-each select="inclusiveEndDate">
<inclusiveEndDate>
<xsl:sequence select="(./@node(), ./node())"/>
</inclusiveEndDate>
</xsl:for-each>
<xsl:for-each select="inclusiveStartDate">
<inclusiveStartDate>
<xsl:sequence select="(./@node(), ./node())"/>
</inclusiveStartDate>
</xsl:for-each>
<xsl:for-each select="isUnderEdit">
<isUnderEdit>
<xsl:sequence select="xs:string(xs:boolean(fn:string(.)))"/>
</isUnderEdit>
</xsl:for-each>
<naId>
<xsl:sequence select="xs:string(xs:integer(fn:string(naId)))"/>
</naId>
<xsl:for-each select="organizationalDonorArray">
<organizationalDonorArray>
<xsl:sequence select="(./@node(), ./node())"/>
</organizationalDonorArray>
</xsl:for-each>
<xsl:for-each select="personalDonorArray">
<personalDonorArray>
<xsl:sequence select="(./@node(), ./node())"/>
</personalDonorArray>
</xsl:for-each>
<xsl:for-each select="preliminaryDescriptionArray">
<preliminaryDescriptionArray>
<xsl:sequence select="(./@node(), ./node())"/>
</preliminaryDescriptionArray>
</xsl:for-each>
<xsl:for-each select="scopeAndContentNote">
<scopeAndContentNote>
<xsl:sequence select="fn:string(.)"/>
</scopeAndContentNote>
</xsl:for-each>
<xsl:for-each select="seriesArray">
<seriesArray>
<xsl:sequence select="(./@node(), ./node())"/>
</seriesArray>
</xsl:for-each>
<xsl:for-each select="staffOnlyNote">
<staffOnlyNote>
<xsl:sequence select="fn:string(.)"/>
</staffOnlyNote>
</xsl:for-each>
<xsl:for-each select="$var3_title">
<title>
<xsl:sequence select="fn:string(.)"/>
</title>
</xsl:for-each>
<xsl:for-each select="$var3_title">
<fullTitle>
<xsl:sequence select="fn:string(.)"/>
</fullTitle>
</xsl:for-each>
<xsl:for-each select="variantControlNumberArray">
<variantControlNumberArray>
<xsl:sequence select="(./@node(), ./node())"/>
</variantControlNumberArray>
</xsl:for-each>
</xsl:for-each>
</collection>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>Edited by: jjmdb on Feb 22, 2012 11:42 AM -
Schema evolution success! But new node is empty in XMLTYPE column?
Hi everyone!
Quick question. I am working through the XML Schema evolution process and was able to use inplaceevolve successfully. I can see the new node added to my schema under user_xml_schemas. However, when I try to upload an XML document with that new node, it shows up in the stored XML as empty?
Here are some more details...
I added the assistant nickname element
<element name="spousePartner" nillable="true" minOccurs="0" type="xsd:string" />
<element name="title" nillable="true" minOccurs="0" type="xsd:string" />
*<element name="assistantNickName" nillable="true" minOccurs="0" type="xsd:string" />*
and I see it was added in my registered schema.
I then add the node to my test XML and in my program's console I see the node being parsed...
physicalStreet>10 Green St</physicalStreet>
<salutation>Ms.</salutation>
<title>CEO</title>
*<assistantNickName>Big Bird</assistantNickName>*
</contact>
However, when I look at the stored XML in my XMLTYPE column, I see an empty node...
<physicalStreet>10 Green St</physicalStreet>
<salutation>Ms.</salutation>
<title>CEO</title>
*<assistantNickName/>*
</contact>
What am I missing?
Any help is greatly appreciated - thank you much!Hi,
Are you using BINARY XML?
I've just tested the following with object-relational storage (not binary) :
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as dev
SQL> var schema1 varchar2(4000);
SQL> var schema2 varchar2(4000);
SQL> BEGIN
2 :schema1 := '<?xml version="1.0" encoding="UTF-8"?>
3 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
4 xmlns:xdb="http://xmlns.oracle.com/xdb">
5 <xs:element name="root" xdb:SQLName="root">
6 <xs:complexType xdb:SQLType="ROOT_TYPE">
7 <xs:sequence>
8 <xs:element name="item" maxOccurs="unbounded" xdb:SQLCollType="ITEM_COLL">
9 <xs:complexType xdb:SQLType="ITEM_TYPE">
10 <xs:sequence>
11 <xs:element name="Code" type="xs:string"/>
12 <xs:element name="Val" type="xs:integer"/>
13 </xs:sequence>
14 </xs:complexType>
15 </xs:element>
16 </xs:sequence>
17 </xs:complexType>
18 </xs:element>
19 </xs:schema>'
20 ;
21
22 :schema2 := '<?xml version="1.0" encoding="UTF-8"?>
23 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
24 xmlns:xdb="http://xmlns.oracle.com/xdb">
25 <xs:element name="root" xdb:SQLName="root">
26 <xs:complexType xdb:SQLType="ROOT_TYPE">
27 <xs:sequence>
28 <xs:element name="item" maxOccurs="unbounded" xdb:SQLCollType="ITEM_COLL">
29 <xs:complexType xdb:SQLType="ITEM_TYPE">
30 <xs:sequence>
31 <xs:element name="Code" type="xs:string"/>
32 <xs:element name="Val" type="xs:integer"/>
33 <xs:element name="Comm" type="xs:string" minOccurs="0"/>
34 </xs:sequence>
35 </xs:complexType>
36 </xs:element>
37 </xs:sequence>
38 </xs:complexType>
39 </xs:element>
40 </xs:schema>'
41 ;
42 END;
43 /
PL/SQL procedure successfully completed
SQL> BEGIN
2 dbms_xmlschema.registerSchema(
3 schemaURL => 'schema1.xsd',
4 schemaDoc => :schema1,
5 local => true,
6 genTypes => true,
7 genTables => false
8 );
9 END;
10 /
PL/SQL procedure successfully completed
SQL> CREATE TABLE test_evolve OF XMLTYPE
2 XMLTYPE STORE AS OBJECT RELATIONAL
3 XMLSCHEMA "schema1.xsd" ELEMENT "root"
4 ;
Table created
SQL> INSERT INTO test_evolve
2 VALUES(
3 xmltype('<root>
4 <item><Code>A</Code><Val>1</Val></item>
5 <item><Code>B</Code><Val>2</Val></item>
6 <item><Code>C</Code><Val>3</Val></item>
7 </root>')
8 );
1 row inserted
SQL> COMMIT;
Commit complete
SQL> DECLARE
2
3 xdiff xmltype;
4
5 BEGIN
6
7 select xmldiff(
8 xmltype(:schema1),
9 xmltype(:schema2)
10 )
11 into xdiff
12 from dual;
13
14 dbms_xmlschema.InPlaceEvolve(
15 schemaURL => 'schema1.xsd',
16 diffXML => xdiff,
17 flags => dbms_xmlschema.INPLACE_EVOLVE
18 );
19
20 END;
21 /
PL/SQL procedure successfully completed
SQL> INSERT INTO test_evolve
2 VALUES(
3 xmltype('<root>
4 <item><Code>A</Code><Val>1</Val><Comm>This a comment</Comm></item>
5 <item><Code>B</Code><Val>2</Val></item>
6 <item><Code>C</Code><Val>3</Val></item>
7 </root>')
8 );
1 row inserted
SQL> SELECT t.object_value.getClobVal()
2 FROM test_evolve t
3 WHERE xmlexists('/root/item/Comm' passing t.object_value);
T.OBJECT_VALUE.GETCLOBVAL()
<root>
<item>
<Code>A</Code>
<Val>1</Val>
<Comm>This a comment</Comm>
</item>
<item>
<Code>B</Code>
<Val>2</Val>
</item>
<item>
<Code>C</Code>
<Val>3</Val>
</item>
</root>
The new element has been added correctly. -
Registering an XML Schema (schema.xsd is not an XDB schema document)
Hello there,
I'm trying to work with XML DB for a few days now, so far i didn't do anything really usefull to me, but i managed to do some general things reading these forums and the documentation. Now however, i encounter this error registering an XML Schema:
ERROR at line 1:
ORA-31000: Resource 'www.ariase.com.xsd' is not an XDB schema document
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 82
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 102
ORA-06512: at line 8I'm registering it with the following code:
DBMS_XMLSCHEMA.registerSchema('www.ariase.com.xsd', XDBURIType('D:\Stage\Results\XSD_Target\www.ariase.com.xsd').getClob(),TRUE,TRUE,FALSE,TRUE);and this is the schema i'm registering:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="ariase" xdb:defaultTable="ARIASE">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="ligne" type="typeLigne" xdb:SQLName="LIGNE"/>
<xs:element name="debit" type="typeDebit" xdb:SQLName="DEBIT"/>
<xs:element name="central" type="typeCentral" xdb:SQLName="CENTRAL"/>
<xs:element name="technologies" type="typeTechnologies" xdb:SQLName="TECHNOLOGIES"/>
<xs:element name="reseaux" type="typeReseaux" xdb:SQLName="RESEAUX"/>
<xs:element name="degroupage" type="typeDegroupage" xdb:SQLName="DEGROUPAGE"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Complex types -->
<xs:complexType name="typeLigne" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_LIGNE">
<xs:sequence>
<xs:element name="numero" type="typeNumero"/>
<xs:element name="longeur" type="xs:string"/>
<xs:element name="affaiblissement" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeDebit" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_DEBIT">
<xs:sequence>
<xs:element name="adsl2" type="xs:string"/>
<xs:element name="adsl" type="xs:string"/>
<xs:element name="readsl" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeCentral" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_CENTRAL">
<xs:sequence>
<xs:element name="code" type="xs:string"/>
<xs:element name="nom" type="xs:string"/>
<xs:element name="lieu" type="xs:string"/>
<xs:element name="lignes" type="xs:string"/>
<xs:element name="densite" type="xs:string"/>
<xs:element name="dslam" type="xs:string"/>
<xs:element name="plaque" type="xs:string"/>
<xs:element name="couvertures" type="typeCouvertures"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeCouvertures" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_COUVERTURES">
<xs:sequence maxOccurs="unbounded">
<xs:element name="comunne" type="typeComunne"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeComunne" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_COMUNNE">
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="couverture" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeTechnologies" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_TECHNOLOGIES">
<xs:sequence maxOccurs="unbounded">
<xs:element name="technologie" type="typeTechnologie"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeTechnologie" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_TECHNOLOGIE">
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="central" type="xs:string"/>
<xs:element name="ligne" type="xs:string"/>
<xs:element name="reponse" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeReseaux" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_RESEAUX">
<xs:sequence maxOccurs="unbounded">
<xs:element name="reseau" type="typeReseau"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeReseau" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_RESEAU">
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="adsl" type="xs:string"/>
<xs:element name="adsl2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeDegroupage" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_DEGROUPAGE">
<xs:sequence maxOccurs="unbounded">
<xs:element name="fournisseur" type="typeFournisseur"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="typeFournisseur" xdb:maintainDOM="false" xdb:SQLType="XML_TYPE_FOURNISSEUR">
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="totale" type="xs:string"/>
<xs:element name="tv" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<!-- Simple types -->
<xs:simpleType name="typeNumero">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{10}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>I'm using Oracle XE 2.1.0.00.39. Does this all look a bit OK, or am i way off here. I already managed to register the schema when it had a different name, and when it was in a different folder, so now i don't know what i'm doing wrong.
Also i'd like to know what the best way is to insert 10.000s of XML documents in the database, is it possible to 'upload' them to the server, or will i always have to use an INSERT query to do this?
I hope i gave enough information.
Regards,
StijnTHis looks wrong to me
XDBURIType('D:\Stage\Results\XSD_Target\www.ariase.com.xsd').
xdburitype() is used to reference an XML document that already been loaded into the XDB repository.
You can load the document using FTP or WEBDAV or BFILENAME to any folder that already exists and you have write access to. By default this will probably be '/public' unless you have loaded the xdb_utilities package which is posted in this forum and create a '/home' folder for your user. For instance if you loaded the XSD into '/public' your code would look something like this..
xdburitype('/public/www.ariase.com').getClob()
However that would typically generate an error like this
'SQL> exec DBMS_XMLSCHEMA.registerSchema('www.ariase.com.xsd', XDBURIType('D:\Stage\Results\XSD_Target\www.ariase.com.xsd').getClob(),TRUE,TR
UE,FALSE,TRUE);
BEGIN DBMS_XMLSCHEMA.registerSchema('www.ariase.com.xsd', XDBURIType('D:\Stage\Results\XSD_Target\www.ariase.com.xsd').getClob(),TRUE,TRUE,F
ALSE,TRUE); END;
ERROR at line 1:
ORA-31001: Invalid resource handle or path name
"D:\Stage\Results\XSD_Target\www.ariase.com.xsd"
ORA-06512: at "SYS.XDBURITYPE", line 4
ORA-06512: at line 1
SQL>The error message you are seeing implies that the schema you are registering contains an import or include element with a schemalocation attribute that references 'www.ariase.com.xsd'
Eg
SQL> begin
2 DBMS_XMLSCHEMA.registerSchema('www.ariase.com1.xsd',
3 '<?xml version="1.0" encoding="UTF-8"?>
4 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attri
5 <xs:include schemaLocation="www.ariase.com.xsd"/>
6 <xs:element name="root" type="xs:short">
7 <xs:annotation>
8 <xs:documentation>Comment describing your root element</xs:documentation
9 </xs:annotation>
10 </xs:element>
11 </xs:schema>',
12 TRUE,TRUE,FALSE,TRUE);
13 end;
14
15
16 /
begin
ERROR at line 1:
ORA-31000: Resource 'www.ariase.com.xsd' is not an XDB schema document
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 3
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 14
ORA-06512: at line 2
SQL> -
Ora-31000 not an XDB schema document error WHY???
I have registered a xmlschema as following
FIRSTLY
I create a procedure schemas as
create or replace procedure schemas is
begin
declare
doc varchar2(1000) := '<schema
targetNamespace="http://localhost/po.xsd"
xmlns:po="http://localhost/po.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<complexType name="PurchaseOrderType">
<sequence>
<element name="PONum" type="decimal"/>
<element name="Company">
<simpleType>
<restriction base="string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element name="Item" maxOccurs="1000">
<complexType>
<sequence>
<element name="Part">
<simpleType>
<restriction base="string">
<maxLength value="1000"/>
</restriction>
</simpleType>
</element>
<element name="Price" type="float"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
<element name="PurchaseOrder" type="po:PurchaseOrderType"/>
</schema>';
begin
dbms_xmlschema.registerSchema('http://localhost/po.xsd', doc);
end;
end schemas;
SECONDLY
I execute the schemas procedure as
"exec schemas;"
and the return value show is successful
THIRDLY
I want to create a table based on this registered schema as
"create table po_tab(
id number,
po sys.XMLType
xmltype column po
XMLSCHEMA "http://localhost/PO.xsd"
element "PurchaseOrder";
But the return value is
"ORA-31000: the 'http://localhost/PO.xsd' is not an XDB schema document "
WHY?????XML is case sensitive.. You used ''http://localhost/po.xsd' when registering the schema and "http://localhost/PO.xsd" when attempting to create the table. Which database version are you working with
-
ORA-31000: Resource 'string' is not an XDB schema document
ORA-31000: Resource '<ACCOUNT><EMPLOYEE><empid>2109</empid><sal>10000</sal></EMP
LOYEE><EMPLOYEE><empid>2109</empid><sal>10000</sal></EMPLOYEE><EMPLOYEE><empid>2
109</empid><sal>10000</sal></EMPLOYEE><EMPLOYEE><empid>2109</empid><sal>10000</s
al></EMPLOYEE><EMPLOYEE><empid>2109</empid><sal>10000</sal></EMPLOYEE><ACCOUNT>'
is not an XDB schema document
this a output that i get. i have populated this string from table and passing it as:
xmlvar := xmltype('ROOT',str_xmlstring);
the function returns the string directly but gives the above output.Hello mgralike,
Thanks for your link but for me this combination is valid with the getClobVal :
Registers the schema specified as a CLOB
DBMS_XMLSCHEMA.REGISTERSCHEMA(
schemaurl IN VARCHAR2,
schemadoc IN CLOB,
local IN BOOLEAN := TRUE,
gentypes IN BOOLEAN := TRUE,
genbean IN BOOLEAN := FALSE,
force IN BOOLEAN := FALSE,
owner IN VARCHAR2 := NULL,
options IN PLS_INTEGER := 0);
May be It is not working properly in my case.
Witch combination do you use it to register schema in a XMLTYPE column ? -
DICOM packaged application install error - XDB schema error
Hi, I have worked through the install readme for the DICOM packaged application and on installing the DICOM_demo_installer.sql supporting objects I get an error when trying to create the table dicom_archive
ORA-31000: Resource 'http://xmlns.oracle.com/ord/meta/dia_demo' is not an XDB schema document
Any pointers appreciated.9503657 (In lieu of your actual name - Please give your name in future),
Where are you trying to install this packaged application (DB Version, DB Edition (EE / SE / SE1 / XE), DB Options, localhost / hosted environment)?
There are specific requirements specified in the readme.txt file provided in the zip file.
There are very specific installation instructions also provided in the readme.txt file.
Unlike most packaged applications this one requires various scripts be run prior to installing the actual application into APEX.
So could you please specify the steps taken to get to this error.
Regards,
David -
ORA-31000: Resource '' is not an XDB schema document
I have registered HTNG_HotelRoomStatusSearchRQ.xsd with Oracle and am attempting use this schema. I have attached the original xsd, results of
SELECT * FROM user_xml_schemas where SCHEMA_URL = 'HTNG_HotelRoomStatusSearchRQ.xsd' and the block I use to test. It is all labeled in the text document attached.
Please advise.
Thank youHi Odie,
The error occurs on line 52
[Error] Execution (4: 3): ORA-31000: Resource '' is not an XDB schema document ORA-06512: at line 52
IF l_xmltype.isschemabased () = 0
THEN
RAISE non_registered_schema;
END IF;
I get the same exception regardless of the clob I use.
declare
x_RoomStatus CLOB := '<?xml version="1.0" encoding="UTF-8"?>
<HTNG_HotelRoomStatusSearchRQ
xmlns="http://htng.org/2011B"
xmlns:ota="http://www.opentravel.org/OTA/2003/05"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://htng.org/2014B HTNG_HotelRoomStatusSearchRQ.xsd"
TimeStamp="2011-08-24T09:30:47Z">
<PropertyInfo ChainCode="STARWOOD" HotelName="Westin San Diego" BrandCode="WESTIN" HotelCode="2134" HotelCodeContext="CRES"/>
<Room>
<RoomType Floor="12"/>
<HKStatus>VACANT_DIRTY</HKStatus>';
xy_roomstatus clob :='<?xml version="1.0" encoding="UTF-8"?>
<HTNG_HotelRoomStatusSearchRQ EchoToken="6c19dbf8-351b-471f-a33b-be8701eb67ae" TimeStamp="2011-08-24T09:30:47Z" Version="1.0" Target="Production" xmlns="http://htng.org/2011B" xmlns:ota="http://www.opentravel.org/OTA/2003/05">
<PropertyInfo ChainCode="STARWOOD" HotelName="Westin San Diego" BrandCode="WESTIN" HotelCode="2134" HotelCodeContext="CRES"/>
<Room>
<RoomType Floor="12"/>
<HKStatus>VACANT_DIRTY</HKStatus>
</Room>
</HTNG_HotelRoomStatusSearchRQ>';
BEGIN
l_xmltype := xmltype (xy_roomstatus);
v_schema_to_validate := l_xmltype.getrootelement () || '.xsd';
IF l_xmltype.isschemabased () = 0
THEN
RAISE non_registered_schema;
END IF;
end;
Thank you -
XDB Schema to create Database Tables
Hello
if i understood the Oracle Documentation correct, then must it be possible to create corresponding databasetables from a schema. Is it correct ?
If i create a schema oracle creates only object type's from my schema. Can anybody help me with my little problem?
Thank you very much
Bastian FiebigHi,
You can use the xdb annotation xdb:defaultTable="<tablename>" with an element, so that when a schema is registered the
table is created. Doing this on the top level element, will create a table that will only allow XML to be created in it, that complies with the
registered schema.
Regards
Pete -
ORA-31000: Resource 'example_name.xsd' is not an XDB schema document
Morning,
I'm running 11gr2 on OEL 5. I recently joined a project where a lot of work has already been done by a previous dba and xmldb is fairly new to me. I'm trying to register a new xml schema but keep getting the above error. The error is referencing a resource that I'm not even declaring in my statement. See statement below.
BEGIN
DBMS_XMLSCHEMA.registerSchema(
SCHEMAURL => 'http://localhost/xsd/test/collection_test.xsd',
SCHEMADOC => bfilename('XSD_TEST','collection_test.xsd'),
CSID => nls_charset_id('AL32UTF8'));
END;
I've used the FORCE=True option which has worked but then the error shows up again when trying to create a table. I queried the schema url and found that nothing was mapped to it so I deleted it as so:
DBMS_XMLSCHEMA.DELETESCHEMA('http://localhost/xsd/test/collection_test.xsd', DBMS_XMLSCHEMA.DELETE_CASCADE_FORCE);
This worked just fine. Problem now is, I'm still getting the same error when registering schema or creating a table. I thought maybe I could purge t he schema from the database now but I can't query the schema ID to do so. I feel I am stuck now. I've tried to look up solutions online for a day now to no avail. All help is GREATLY appreciated (and rewarded). Thanks!!I don't expect to be able to give you the answer you seek, but I'll ask a couple of questions to help others along.
1) What is your error message? That is useful
2) What does collection_test.xsd look like? Can you post it (or a portion of it, including any includes/imports and all namespaces)?
Reproducible test cases are always nice as they show others what is going on and give a starting point for reproducing/fixing the error. -
Urgent!! Oracle Portal Schema Corrupt - Help!!
Hi
We have a new installation of Oracle Portal Release 2 (version 9.0.2).
The portal schema somehow got corrupt. We tried two different recompile scripts, and still, after running it several times, we end up with 86 invalid objects, all of them either a package or type body.
Does anyone know of a script that will allow us to recompile this from source code?
Regards
HarryHi,
try running this as portal schema ,it creates a file called c1.sql ,just run c1.sql to compile all invalid objects:
set head off
set echo off
spool c1.sql
Select 'Alter '||
decode(OBJECT_TYPE,'PACKAGE BODY','PACKAGE','TYPE BODY','TYPE',OBJECT_TYPE)||
' "'||OBJECT_NAME||'" COMPILE '||
decode(OBJECT_TYPE,'PACKAGE BODY','BODY;','TYPE BODY','BODY;',';')
From user_OBJECTS
Where STATUS = 'INVALID'
spool off
set echo on
set head on
Hope this helps,
Anu -
Create a user that can only access to one schema - please help!!
Hi all,
I want to create one user in a Oracle DB that can only access to one schema. I did the following:
CREATE USER "TEST" PROFILE "DEFAULT"
IDENTIFIED BY "test" DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
ACCOUNT UNLOCK;
GRANT SELECT ON "TESTDTA"."F0007" TO "TEST"
GRANT "CONNECT" TO "TEST";
I have done a test and the user TEST can access all schemas, when I only gave explicit permissions to the schema TESTDTA.
Any suggestion/clarification???
Many thanks in advance.
Víctor.Hello Andreas and Pavan,
I have launched the query:
select * from dba_tab_privs
where grantee = 'PUBLIC'
and owner = 'PRODDTA'
and table_name= 'F0009';
And the result:
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRA HIE
PUBLIC PRODDTA F0009 PRODDTA ALTER NO NO
PUBLIC PRODDTA F0009 PRODDTA DELETE NO NO
PUBLIC PRODDTA F0009 PRODDTA INDEX NO NO
PUBLIC PRODDTA F0009 PRODDTA INSERT NO NO
PUBLIC PRODDTA F0009 PRODDTA SELECT NO NO
PUBLIC PRODDTA F0009 PRODDTA UPDATE NO NO
PUBLIC PRODDTA F0009 PRODDTA REFERENCES NO NO
PUBLIC PRODDTA F0009 PRODDTA ON COMMIT REFRESH NO NO
PUBLIC PRODDTA F0009 PRODDTA QUERY REWRITE NO NO
PUBLIC PRODDTA F0009 PRODDTA DEBUG NO NO
PUBLIC PRODDTA F0009 PRODDTA FLASHBACK NO NO
11 rows selected.
Then I supose that I have to change the value on column GARANTEE. How can I do that?
Thanks a lot for your help!!
Víctor. -
URGENT!!!!! Schema design help
Iam trying to design a schema with ActiveDirectory Application mode with the following requirements:
Profile1: CM_VIEW  view equipment, search equipment
Profile 2: CM_USR  All operations possible by CM_VIEW + create equipment objects, modify inventory, create and modify facilities attributes
Profile 3: CM_FULL  All operations possible by CM_USR + delete equipment , facilities
Profile 4: CM_ADM  All operations possible by CM_FULL + admin privilege for security management
There are a list of user groups. This level is more like a container and no privilege is controlled at this level
User Group1 : Admin
User Group2: Manager
User Group3: Operator
Now this list of User groups can have one or more subgroups. The profiles need to be assigned at this level.
Admin group: Admin1
Manager group: NW Manager , Area1 Manager, Area2 Manager etc�
Operator Group: NW Operator, Area1 Operator, Area2 Operator
There is a single network which is divided into 5 area centers. User groups are given access to the whole network or specific area center.
Whole NW access : Admin1, NW Manager with whatever profiles assigned to them
Area1 access : Area1 Manager, Area1 Operator with whatever profiles assigned to them
As Iam a novice with ADAM, I seek some help to get my schema designed. Iam very confused about
- whether the default AD schema would suffice
- do I need to create my own class
- do I need to add my own attributes to existing classes
- If so, should I consider all the operations defined in the profile as user defined attributes?
I could not get specific information for the stuff Iam searching for and Iam struggling to get the shema designed. It is quite urgent and Any help in this area would be greatly appreciatedThere would be several ways to solve this problem.
First of all, the schema. You have threee choices;
1. Extend an existing class.This is when the existing class meets your requirements (searching, differentiation) but needs a few more attributes
2. Derive a new subclass from an existing class. This is when you want to differentiate your class, but inherit features from an existing class.
3. Create a new class, when no existing class meets your requirements
For option 1, best way to do this is create an auxilliary class and add it to the existing class. (Eg. create an auxilliary class called clothing sizes, add attributes height, waist, hat size,shoe size,and then add the class to the existing user class)
For option 2, you may want a class called football player, so you create a new class called footballplayer, derived fromthe existing user class.You may add new attributes such as football team, playing position.
For option 3, you may want to create an entirely newclass to represent a football stadium, with both existing attributes such as address, city and new attributes such as seating capacity
So in your case, users & administrators would normally just be user or inetOrgPerson class objects. Equipment & facilities may require their own classes.
Next thing is to use organisationaUnits (OU's) as the boundaries for delegating administrative permissions. For each area, Area 1, Area 2, ...,Area n, create an organizational unit.
Then you have two methods to enforce role based access control.
The first is to use is to use the Windows security model to enforce the object access.
Create groups to represent CM_VIEW, CM_USR, CM_FULL, CM_ADM roles, perhaps even groups such as Area_1_CM_USR
Then grant the following permissions on the OU.
CM_VIEW - read/list eqpt class objects
CM_USR - read/write/list/create/delete eqpt class objects, read/list/write/create facilities
CM_FULL - read/write/list/create/delete eqpt class objects, read/list/write/create/delete facilities
CM_ADM - full permissions on the OU.
You can either define these ACL's on the OU's so the permissions apply to all objects in the OU, or define them on the schema definitions so that as new objects are instantiated they have the default permissions applied. As you want to differentiate access at the OU level, don't worry about the default schema permissions, just set the ACL's on each OU.
The problem you would have is using Java/JNDI to manage the ACL's (writing the security descriptors on the OU or object classes.).Far easier to use either the WIndows API's, Windows scripting interfaces (ADSI), LDIF files or Windows UI components (ADSIEdit).
You may want to do all the schema extension and ACL's with Windows tools,coz they're easier and use Java/J2EE for your application development.
The second approach is to apply the role based access controls within your application. The security risk with this approach is that it may be possible for someone to subvert the security in your application by accessing the directory directly. -
Oracle XDB no response, help
hi all,
I am doing my project on department oracle server, I can not touch the server, I can only use oracle client sqlplus work sheet. I found the oracle XDB will not response when I run any commands such as registerschema, deleteschema, create table base on schema. A wrong command will prompt error msgs, however, right command which I have run before return nothing, after execute right xml commands the sqlplus will keep no response, I have to close the connection. What should I do? The administrator never use XDB before, how can I resolve this problem? Thanks a lot!
MikeI have no idea if Oracle worksheet already supports XMLDB calls. The behaviour you are describing, supports the idea that it doesn't. iSQL*Plus will be desupported anyway, so in that light you are traveling a dead end.
In general, if you use the XDB account, this should just work (BTW you shouldn't need to use the XDB account).
For registering local XSD's etc the following should be sufficent:
grant connect, resource to XXX
grant alter session, create view to XXX
grant create any directory, drop any directory to XXXregarding public XML Schema's you need as an extra
grant XDBADMIN to XXXps... XXX is an user account ;-)
Maybe you are looking for
-
Form data - to command - for verification - exec
I'm attempting to assign entered form data into an array, to generate a list of command line commands from the form data, and pass the array to a verification page for display. After the displayed and verified information has been approved , press a
-
Calling Crystal Reports From Menu
Can I crystal Report sitting on a NT machine thru menu item which is deployed as an applet on my browser ???
-
Flipbook.h in Shake 4.1
I am trying to customize the flipbook to open RV but unlike earlier versions shake 4.1 doesnt seem to have flipbook.h I was wondering if anybody could point me to the file with the code for flipbook on shake's ui. -James Oh, running CentOS5
-
I've set up iphoto to open photos directly into elements 11 editor. After making changes, how can I save the images (orginal and modified) back into iphoto?
-
Will iPad 2 magnets and cover magnets demagnetize credit cards in carrier?
I have a purse with a padded laptop compartment. How careful must I be to protect my credit cards from the iPad magnets and cover magnets? Some say you need very strong magnets to demagnetize cards. But what of cards left in close proximity overnight