namespace prefix "xsi" is not declared [message #148564] |
Fri, 25 November 2005 01:06 |
meelis
Messages: 1 Registered: November 2005
|
Junior Member |
|
|
Hello,
I have not found a solution for my problem, so I need some help please.
I have this test procedure to illustrate my problem (Oracle 9i):
procedure MV_test1
is
xXml XMLType;
begin
xXml:=xmltype.createXML(
'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns4="http://test.ee/xsd/xt.xsd"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns4:id xsi:type="xsd:string">MPf8bN87N98fKI6OeaKhQPOhdhN67d6gede7Qgch</ns4:id>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:test10Response xmlns:m="http://producers.test.ee/producer/test-kxt">
<query>
<ees xsi:type="xsd:string">Jonh</ees>
<per xsi:type="xsd:string">Smith</per>
</query>
<body>
<docData xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="Struct[2]" SOAP-ENC:offset="[0]">
<item>
<ees xsi:type="xsd:string">Kate</ees>
<per xsi:type="xsd:string">Smith</per>
<tyyp xsi:type="xsd:string">7</tyyp>
</item>
<item>
<ees xsi:type="xsd:string">Robert</ees>
<per xsi:type="xsd:string">Smith</per>
<tyyp xsi:type="xsd:string">6</tyyp>
</item>
</docData>
</body>
</m:test10Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>');
for i1 in ( select extractvalue (value(d), 'item/ees') ees
from table (XMLSequence(xXml.extract('//body/docData/item'))) d )
loop
raise_application_error(-20013,'STOPPED: '||i1.ees);
end loop;
end;
The FOR loop gives the error:
ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00234: namespace prefix "xsi" is not declared ...
I know that functions "extract" and "extractvalue" have a second parameter for namespace but I don't know how to use it.
I have tried
Code:
for i1 in ( select extractvalue (value(d), 'item/ees','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') ees
from table (XMLSequence(xXml.extract('//body/docData/item','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'))) d )
loop
raise_application_error(-20013,'STOPPED: '||i1.ees);
end loop;
but with no success.
If I remove 'xsi:' from the xml or change the <item> tag with <item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> then the FOR loop works.
But the thing is that I cannot change the XML!
Please advise how to use the second parameter in extract and extractvalue.
Thank you
|
|
|
Re: namespace prefix "xsi" is not declared [message #149738 is a reply to message #148564] |
Sat, 03 December 2005 14:32 |
mchadder
Messages: 224 Registered: May 2005 Location: UK
|
Senior Member |
|
|
Hello.
This seems to be the known issue of namespace mis-handling when dealing with the .EXTRACT method of XMLTYPE. Unfortunately, I haven't got a 9i instance available to test this, but check out
http://www.oratechinfo.co.uk/sqlxml.html#point3 for more information on this problem.
Basically, though, it just boils down to using the EXTRACT function as opposed to the .EXTRACT method, so instead of
xXml.extract('//body/docData/item')
You would use
EXTRACT(xXml, '//body/docData/item')
Hth
|
|
|