XMLTABLE with xmlnamespaces XPST0005 issue [message #556483] |
Mon, 04 June 2012 11:42 |
|
zjw2112
Messages: 2 Registered: June 2012
|
Junior Member |
|
|
Given the following XML:
<doc:document xmlns:doc="urn:su:abc:de:doc">
<titleList>
<title>
<value>Test</value>
</title>
</titleList>
</document>
and using the following query:
select X.*
from mytable,
XMLTABLE(xmlnamespaces('urn:su:abc:de:doc' as "doc"),
'$d/doc:document' passing docxml as "d"
COLUMNS
thetitle varchar2(50) PATH 'titleList/title/value') as X
I get the following error:
from mytable,
*
ERROR at line 2:
ORA-19276: XPST0005 - XPath step specifies an invalid element/attribute name: (doc:document doc='urn:su:abc:de:doc')
I don't understand why I get this error. Can anyone help? Thank you.
|
|
|
|
|
Re: XMLTABLE with xmlnamespaces XPST0005 issue [message #556491 is a reply to message #556485] |
Mon, 04 June 2012 14:15 |
|
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Your inserted XML data is invalid. The following demonstrates that, then uses some slightly different data, followed by a slightly different query. This is an example of why we ask for a copy and paste. Please review what you have very carefully and make sure you have posted exactly the right XML data and exactly the right query.
SCOTT@orcl_11gR2> CREATE TABLE mytable (docxml XMLTYPE)
2 /
Table created.
SCOTT@orcl_11gR2> INSERT INTO mytable VALUES
2 (XMLTYPE
3 ('<doc:document xmlns:doc="urn:su:abc:de:doc">
4 <titleList>
5 <title>
6 <value>Test</value>
7 </title>
8 </titleList>
9 </document>'))
10 /
(XMLTYPE
*
ERROR at line 2:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00225: end-element tag "document" does not match start-element tag
"doc:document"
Error at line 7
ORA-06512: at "SYS.XMLTYPE", line 310
ORA-06512: at line 1
SCOTT@orcl_11gR2> INSERT INTO mytable VALUES
2 (XMLTYPE
3 ('<document xmlns="urn:su:abc:de:doc">
4 <titleList>
5 <title>
6 <value>Test</value>
7 </title>
8 </titleList>
9 </document>'))
10 /
1 row created.
SCOTT@orcl_11gR2> SELECT x.*
2 FROM mytable,
3 XMLTABLE
4 (XMLNAMESPACES ('urn:su:abc:de:doc' AS "doc"),
5 '$d/doc:document' PASSING docxml AS "d"
6 COLUMNS
7 thetitle VARCHAR2(50) PATH 'doc:titleList/doc:title/doc:value') AS x
8 /
THETITLE
--------------------------------------------------
Test
1 row selected.
|
|
|