Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> XMLQuery with schema-based XMLType data?
I've created two simple tables, one with an XMLType column (not tied to
any schema), and the other with an XMLType column constrained to a
(properly registered) schema. The same data have been successfully
loaded into each table. XPath expressions and XMLQuery queries work
fine with the unconstrained one, but not with the constrained one (no
results are returned).
Is there anything special one needs to do to make XQuery expressions work with schema-based XMLType data? The docs. and examples from Oracle say it should work. I suspect I'm missing something here; any advice appreciated!
In addition, advice welcomed about how to force Oracle to display all the returned data (it seems to be truncated after about 80 characters, and the "column" command in sqlplus didn't seem to affect this).
--Scott V.
PS Here are the relevant create, insert, and select statements (xsd and xml documents omitted):
CREATE TABLE Agents (id NUMBER, clients XMLType)
XMLType COLUMN clients
XMLSCHEMA "customerListSchema"
ELEMENT "customerList";
Table created.
INSERT INTO Agents VALUES (47,
XMLTYPE (bfilename ('HOME', 'myCustomers.xml'), nls_charset_id('AL32UTF8')));
1 row inserted.
SELECT XMLQuery ('for $i in //Address
return $i/Street' PASSING A.Clients RETURNING CONTENT) AS StreetInfoFROM Agents A;
STREETINFO
The following sequence of commands works fine:
CREATE TABLE Agents2 (id NUMBER, clients XMLType);
Table created.
INSERT INTO Agents2 VALUES (47,
XMLTYPE (bfilename ('HOME', 'myCustomers.xml'), nls_charset_id('AL32UTF8')));
1 row inserted.
SELECT XMLQuery ('for $i in //Address
return $i/Street' PASSING A.Clients RETURNING CONTENT) AS StreetInfoFROM Agents2 A;
STREETINFO