Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> XMLQuery with schema-based XMLType data?

XMLQuery with schema-based XMLType data?

From: <vandenberg_at_siena.edu>
Date: 28 Feb 2006 06:21:06 -0800
Message-ID: <1141136466.473825.226740@u72g2000cwu.googlegroups.com>


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

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) ... Received on Tue Feb 28 2006 - 08:21:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US