Extra whitespace in XML file read from Oracle database - why? -
i experimenting python , oracle xml db. have table xmltype column , id column in oracle 11g database. storage model xml column object relational. need whole xml file, , longer 4000 characters, use query clob:
select t.representation.getclobval() myxmldocs t id=:documentid
when run query output includes whitespace, newlines , tabs between xml elements not there in xml docs inserted. effect of kind of formatting, output looks this:
<a>\n \t<b></b>\n \t\t<c>some text</c>\n \t\t<c>some more text</c>\n \t<b></b>\n ...
and on. quite pretty , readable, why getting it? messes other libraries using choke on whitespaces.
if remove getclobval() python client not clob object , don't know it.
this appears consistent; problem using sqlplus command line client, , creating other tables using different xml schemas, , querying them. in previous version of prototype had xmltype column use clob storage model , didn't have problem.
how should rewrite query clob xml file without formatting?
update: requested in comments, output running query select dump(t.representation) myxmldocs t id=:documentid
command line client (replacing of course :documentid actual, existing id database):
dump(t.representation) -------------------------------------------------------------------------------- typ=58 len=218: 32,156,148,1,0,0,0,0,80,193,223,20,0,0,0,0,216,15,47,21,0,0,0,0, 80,44,55,21,0,0,0,0,0,202,154,59,160,15,0,0,160,15,0,0,1,0,4,0,220,190,195,71,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,33,65,0,15,0,72,0,1,0,0,0,0,0,0,0,49,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0
in 11g can use xmlserialize
(in fact should not use getclobval
anymore. it's not recommended performance reasons)
sql> select t.test.getclobval() testxml t id = 1; t.test.getclobval() -------------------------------------------------------------------------------- <a> <b> <c>foo</c> <c>foo2</c> </b> </a> sql> select xmlserialize(document t.test clob no indent) testxml t id = 1; xmlserialize(documentt.testasclobnoindent) -------------------------------------------------------------------------------- <a><b><c>foo</c><c>foo2</c></b></a>
Comments
Post a Comment