Home > Archive > Tools for Oracle database > February 2006 > XMLQuery with schema-based XMLType data?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XMLQuery with schema-based XMLType data?
vandenberg@siena.edu

2006-02-28, 8:25 pm

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('AL32
UTF8')));

1 row inserted.

SELECT XMLQuery ('for $i in //Address
return $i/Street'
PASSING A.Clients RETURNING CONTENT) AS StreetInfo
FROM Agents A;

STREETINFO
------------------------
(nothing is printed under the header)

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('AL32
UTF8')));

1 row inserted.

SELECT XMLQuery ('for $i in //Address
return $i/Street'
PASSING A.Clients RETURNING CONTENT) AS StreetInfo
FROM Agents2 A;

STREETINFO
------------------------
<Street>... (actual data returned) ...

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com