Home » Developer & Programmer » JDeveloper, Java & XML » xmlelement inside an xmlement !
xmlelement inside an xmlement ! [message #459329] Fri, 04 June 2010 07:07 Go to next message
b_52globemaster
Messages: 51
Registered: July 2005
Member
Hi i'm having a view where i select the clob content of another view and it works , but replace the '<' and '>' by &lt; and &gt;


late's take this test case:

we create our first view:

CREATE OR REPLACE FORCE VIEW V_XML_test_data(id,xmlcontent) as
select 1,(
XMLELEMENT ("content",
 XMLELEMENT ("delta",(select 1 from dual)),
 XMLELEMENT ("omega",(select 2 from dual)),
 XMLELEMENT ("gamma",(select 3 from dual))
)
).getclobval ()
from dual



and i got the second view where i select the result from the first one:


CREATE OR REPLACE FORCE VIEW V_XML_test_call(id,xmlcontent) as
select 1,(
XMLELEMENT ("result",       
(SELECT XMLAGG (              
  XMLELEMENT ("delta",xmlcontent ) 
          )from V_XML_test_data
   )
)    
).getclobval ()
from dual



the result appear like :
select xmlcontent from V_XML_test_call


Quote:

(CLOB) <result><delta> &lt;content&gt;&lt;delta&gt;1&lt;/delta&gt;&lt;omega&gt;2&lt;/omega&gt;&lt;gamma&gt;3 &lt;/gamma&gt;&lt;/content&gt; </delta></result>


any workaround?


and thanks
Re: xmlelement inside an xmlement ! [message #459336 is a reply to message #459329] Fri, 04 June 2010 07:35 Go to previous messageGo to next message
Michel Cadot
Messages: 59498
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't understand what you want to do but you can use REPLACE to replace html codes by their characters.

Regards
Michel
Re: xmlelement inside an xmlement ! [message #459338 is a reply to message #459336] Fri, 04 June 2010 07:43 Go to previous messageGo to next message
_jum
Messages: 490
Registered: February 2008
Senior Member
You should not use .getclobval() in your first view, compare your (simplified) queries:

SELECT 
XMLELEMENT ("delta",(select 1 from dual)).getStringval() innerxml 
FROM dual;  

INNERXML
--------------------------------------------------------------
<delta>1</delta>                                                 

SELECT 
XMLELEMENT("result",XMLELEMENT ("delta",(select 1 from dual)).getStringval()).getStringval() outer_rep  
FROM dual;

OUTER_REP
--------------------------------------------------------------
<result>&lt;delta&gt;1&lt;/delta&gt;</result>   

SELECT 
XMLELEMENT("result",XMLELEMENT ("delta",(select 1 from dual))).getStringval() outer_ok 
FROM dual;

OUTER_OK
--------------------------------------------------------------
<result>delta>1</delta</result>                                  

[Updated on: Fri, 04 June 2010 08:06] by Moderator

Report message to a moderator

Re: xmlelement inside an xmlement ! [message #459352 is a reply to message #459329] Fri, 04 June 2010 08:27 Go to previous messageGo to next message
b_52globemaster
Messages: 51
Registered: July 2005
Member
_jum,Michel thanks


@_jum
yeap that did the job.



@Michel
i have a special scenario where i need to put some low level entities in the view which have some data under clob, and another view must bring some of the result of the first one depending on business rules.


thanks guys.
Re: xmlelement inside an xmlement ! [message #459362 is a reply to message #459352] Fri, 04 June 2010 09:12 Go to previous messageGo to next message
b_52globemaster
Messages: 51
Registered: July 2005
Member
is it possible to do string replacement on clob without changing his type ?
Re: xmlelement inside an xmlement ! [message #459382 is a reply to message #459362] Fri, 04 June 2010 09:58 Go to previous messageGo to next message
_jum
Messages: 490
Registered: February 2008
Senior Member
Would think so:
SET SERVEROUTPUT ON SIZE 1000000;

DECLARE
  testClob CLOB;
BEGIN  
  SELECT
    XMLELEMENT ("delta", (SELECT 1 FROM dual)).getclobval() INTO testClob
    FROM DUAL;
  DBMS_OUTPUT.put_line(testClob);    
  SELECT
    REPLACE(XMLELEMENT ("delta", (SELECT 1 FROM dual)).getclobval(),'elta','oit') INTO testClob
    FROM DUAL;
 DBMS_OUTPUT.put_line(testClob);    
END;

<delta>1</delta>

<doit>1</doit>
  
Re: xmlelement inside an xmlement ! [message #459386 is a reply to message #459362] Fri, 04 June 2010 10:14 Go to previous messageGo to next message
Michel Cadot
Messages: 59498
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, you can, REPLACE operates on CLOB (in the current supported versions).

Regards
Michel
Re: xmlelement inside an xmlement ! [message #459397 is a reply to message #459386] Fri, 04 June 2010 11:06 Go to previous message
b_52globemaster
Messages: 51
Registered: July 2005
Member
ok thanks
Previous Topic: convert clob into xmltype without a docType
Next Topic: rowconcatenate of clob
Goto Forum:
  


Current Time: Thu Oct 30 12:00:28 CDT 2014

Total time taken to generate the page: 0.07408 seconds