Hi,
I'm having some trouble creating an xmlindex with structured component on a clob xmltype column without registered schema, whose data uses multiple namespaces.
The code I'm using atm:
CREATE TABLE "DECLARATIONS"
(
"ID" NUMBER(19,0),
"XML" "SYS"."XMLTYPE"
)
CREATE INDEX decl_header_ix ON "DECLARATIONS"(xml) INDEXTYPE IS XDB.XMLINDEX
PARAMETERS ('PATHS (INCLUDE (/emcs:emcsDeclaration/emcs:header//*)
NAMESPACE MAPPING (xmlns:emcs="http://www.myurl.eu/myapp/schema/emcs/nl"))');
INSERT INTO "DECLARATIONS" VALUES (1,'
<?xml version = ''1.0'' encoding = ''UTF-8'' standalone = ''yes''?>
<emcs:emcsDeclaration xsi:schemaLocation="http://www.myurl.eu/myapp/schema/emcs/nl emcs_domain.xsd"
xmlns:common="http://www.myurl.eu/myapp/schema/common"
xmlns:emcs="http://www.myurl.eu/myapp/schema/emcs/nl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<emcs:header>
<common:identifier>70</common:identifier>
<common:declarationSequenceNumber>54566</common:declarationSequenceNumber>
<common:dateCreated>2010-10-21-01:00</common:dateCreated>
<common:status>01 Draft e-AAD in preparation</common:status>
</emcs:header>
</emcs:emcsDeclaration>');
A this moment it's not desirable for us to register the schemas used in oracle. According to the documentation I should be able to add a structured component to the index as follows:
BEGIN
DBMS_XMLINDEX.registerParameter('MY_XSI_GROUP_PARAMETER'
, 'ADD_GROUP GROUP MY_XSI_GROUP
XMLTABLE decl_header
XMLNAMESPACES (''http://www.myurl.eu/myapp/schema/emcs/nl'' AS emcs,
''http://www.myurl.eu/myapp/schema/common'' AS common),
''*''
COLUMNS
status VARCHAR2(30) PATH ''/emcs:emcsDeclaration/emcs:header/common:status/text()''
');
END;
/
ALTER INDEX DECL_HEADER_IX PARAMETERS('PARAM MY_XSI_GROUP_PARAMETER');
However this results in an ORA-00904: invalid identifier. After some experimenting it seems that oracle tries to parse the namespace URLs as identifiers (even tho http://download.oracle.com/docs/cd/E14072_01/appdev.112/e10492/xdb_indexing.htm#BCGJAAGH & http://download.oracle.com/docs/cd/E14072_01/appdev.112/e10492/xdb_xquery.htm#BABJCHCC specify the former), so I swapped them around:
BEGIN
DBMS_XMLINDEX.dropParameter('MY_XSI_GROUP_PARAMETER');
DBMS_XMLINDEX.registerParameter('MY_XSI_GROUP_PARAMETER'
, 'ADD_GROUP GROUP MY_XSI_GROUP
XMLTABLE decl_header
XMLNAMESPACES (emcs ''http://www.myurl.eu/myapp/schema/emcs/nl'',
common ''http://www.myurl.eu/myapp/schema/common''),
''*''
COLUMNS
status varchar2(30) PATH ''/emcs:emcsDeclaration/emcs:header/common:status/text()''
');
END;
/
ALTER INDEX DECL_HEADER_IX PARAMETERS('PARAM MY_XSI_GROUP_PARAMETER');
Oracle seems to get a bit further with this, resulting in a ORA-19102: XQuery string literal expected. Here I pretty much hit a dead end. Removing the xmlnamespaces declaration altogether leads to a ORA-31013: Invalid XPATH expression. Going through the examples on http://www.liberidu.com/blog/?p=1805 works fine, but as soon as I try to add namespaces to it they stop working as well.
So my question is: how do I get xmlnamespaces (with non-default namespaces) to work in a structured xmlindex component?