Home » Developer & Programmer » JDeveloper, Java & XML » ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 (Oracle 11g)
ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583301] Mon, 29 April 2013 04:53 Go to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Hi there

I am getting the error when trying to run this test block, this is code is to simulate the production error we are getting...The XML is attached.. Please Help

DECLARE
g_xdoc XMLTYPE;
g_trans_type CHAR (20) := NULL;
BEGIN
SELECT xmltype(c) -- column is a clob column
INTO g_xdoc
FROM test_gil
WHERE a = '1';


SELECT EXTRACT(VALUE (tt), '//transactionType').getstringval()
INTO g_trans_type
FROM TABLE (XMLSEQUENCE (EXTRACT (g_xdoc, '/'))) tt;

DBMS_OUTPUT.put_line (g_trans_type);
END;


  • Attachment: xml.txt
    (Size: 9.85KB, Downloaded 69 times)
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583302 is a reply to message #583301] Mon, 29 April 2013 05:07 Go to previous messageGo to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

What confuses me to this is that once I format the XML and run the same query it runs fine....
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583303 is a reply to message #583301] Mon, 29 April 2013 05:10 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Try:
select extractvalue(value(x),'//transactionType') v
into g_trans_type
from test_gil, 
     table(xmlsequence(extract(xmltype(c),'//transactionType'))) x
WHERE a = '1';

Regards
Michel
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583304 is a reply to message #583302] Mon, 29 April 2013 05:12 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
gmakinana@gmail.com wrote on Mon, 29 April 2013 12:07
What confuses me to this is that once I format the XML and run the same query it runs fine....


Maybe the line is too long.

For reference:
ORA-30951: Element or attribute at Xpath %s exceeds maximum length
 *Cause:   An attempt was made to insert a node of length exceeding the
           maximum length (specified by the maxLength facet) into
           an XML document.
 *Action:  Do not attempt to add a node exceeding the maximum length
           to XML documents.

Regards
Michel
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583307 is a reply to message #583303] Mon, 29 April 2013 06:14 Go to previous messageGo to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Hi Michel

Thanks for coming back to me... I did the changes but still I get the same error... I have attached the screen dump..

Please advice
  • Attachment: screen.jpg
    (Size: 297.08KB, Downloaded 76 times)
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583308 is a reply to message #583307] Mon, 29 April 2013 06:37 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Try:
select extractvalue(value(x),
                    '//transactionType',
                    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') v
into g_trans_type
from test_gil, 
     table(xmlsequence(extract(xmltype(c),
                               '//transactionType',
                               'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'))) x
WHERE a = '1';

But you may have reached a limit.

Regards
Michel

[Updated on: Mon, 29 April 2013 06:39]

Report message to a moderator

Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583310 is a reply to message #583308] Mon, 29 April 2013 06:43 Go to previous messageGo to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Hi Michel

Still getting the same error still...I have attached the screen dump
  • Attachment: dump2.jpg
    (Size: 293.91KB, Downloaded 77 times)
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583312 is a reply to message #583310] Mon, 29 April 2013 06:46 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Sorry, I modified my post when you were testing, I missed to put the "xmlns" reference in the "table" part.
Could you retry, but I'm afraid you will have to preprocess the clob to split the XML expression.

Regards
Michel
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583316 is a reply to message #583312] Mon, 29 April 2013 07:27 Go to previous messageGo to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Hi there

I still get the same error do you thing if I split the XML in the CLOB it would do a difference?
Or what is the best way to wrap the XML because when I format the XML it works fine...
  • Attachment: dump3.jpg
    (Size: 307.52KB, Downloaded 64 times)
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #583318 is a reply to message #583316] Mon, 29 April 2013 07:42 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, this is what I meant by "split", it was "wrap", sorry for this misuse of the word.
You can add a newline between each "><" in SQL:
select extractvalue(value(x),'//transactionType') v
into g_trans_type
from test_gil, 
     table(xmlsequence(extract(
                         xmltype(replace(c, '><', '>'||chr(10)||'<')),
                         '//transactionType'))) x
WHERE a = '1';

Regards
Michel
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #584544 is a reply to message #583318] Wed, 15 May 2013 04:54 Go to previous messageGo to next message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Hi guys

As for the extract part I used a Java Stored Procedure to etract the value and its working now I am getting the same error when trying to (isSchemaValid (); and schemaValidate ();0 please check code below

set serveroutput on

DECLARE
x CLOB;
v_xdoc XMLTYPE;
g_status VARCHAR2 (50);
g_msg VARCHAR2 (2000);
v_xml_ok NUMBER;
BEGIN
SELECT c --clob column from the database
INTO x
FROM test_gil
WHERE a = '1 - insert_online_xml'
AND b = 'p_message_id :FAIL201304261415231348, UNKNOWN';
v_xdoc := xmltype (x);
-- Associate an XSD to the XML
v_xdoc := v_xdoc.createSchemaBasedXML ('NXS_CLAIM_REQ.XSD');

BEGIN
-- Validate the XML received against the XSD - 0=INVALID, 1=VALID
v_xml_ok := v_xdoc.isSchemaValid ();
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'XML does not correspond to schema.' || SQLERRM);
END;

-- Find out what is invalid so as to return a more meaningful message
IF v_xml_ok = 0
THEN
BEGIN
v_xdoc.schemaValidate ();
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('XML does not conform to XSD..' || SQLERRM);
END;
END IF;

mds_web_service_pack.validate_xml (x,
'NXS_CLAIM_REQ.XSD',
v_xdoc,
g_status,
g_msg);
END;
/

SQL*Plus: Release 10.1.0.4.2 - Production on Wed May 15 10:54:36 2013

Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option

Oracle version 11.2.0.2.0 on host boa
XML does not correspond to schema.ORA-30951: Element or attribute at Xpath
exceeds maximum length
Procedure MDS_WEB_SERVICE_PACK.VALIDATE_XML.
Step 1.
XML does not correspond to schema.
Error converting input xml: XML does not correspond to schema. ORA-30951:
Element or attribute at Xpath exceeds maximum
length

PL/SQL procedure successfully completed.

pdev (assuper)>
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #584571 is a reply to message #584544] Wed, 15 May 2013 10:57 Go to previous messageGo to next message
Michel Cadot
Messages: 59993
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
As you didn't feedback nor thank after your previous question above, I don't see any reason I'll help you now.

Regards
Michel
Re: ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512: at line 11 [message #584605 is a reply to message #584571] Thu, 16 May 2013 02:40 Go to previous message
gmakinana@gmail.com
Messages: 7
Registered: April 2013
Location: Jhb
Junior Member

Sorry Michel man..... Really sorry been a very stressful week at work...
I tried all the solutions given but to no success, until on Metalink I was advised that this was an Oracle bug(See Below)...as below this apparently is happening at RegisterSchema level hence the extract part does not work as well...

So now I am trying to write the Java Stored Procs to do the same functionality... But I am struggling on some parts I have mentioned previously...

Again Sorry Michel, I truly appreciate your help

------------------METALINK----------------------------------------------------------------------------------
ORA-30951 from dbms_xmlschema.registerSchema [ID 1374471.1]

BUG:11724783 - ORA-30951 FROM DBMS_XMLSCHEMA.REGISTERSCHEMA --> 96 - Closed, Duplicate Bug3876657
BUG:5222023 - INVALID ORA-30951 WITH LARGE APPINFO ELEMENT --> Duplicate Bug11724783. To Filer
Previous Topic: Xml data to be passed
Next Topic: proceed registerSchema to a XSD, element becomes unwanted XMLTYPE
Goto Forum:
  


Current Time: Fri Dec 19 15:11:03 CST 2014

Total time taken to generate the page: 0.50490 seconds