Home » Developer & Programmer » JDeveloper, Java & XML » SQL/XML Formatting
SQL/XML Formatting [message #147492] Thu, 17 November 2005 19:22 Go to next message
geoff.upham@gmail.com
Messages: 1
Registered: November 2005
Junior Member
Hi All

I'm running Oracle 9i Release 2. I have been using the built in XML procedures to generate my document into an xmlType and from there to a file.

This is all working fine except for two formatting problems which I can't seem to find any resources for on the net.

The first problem is carriage returns. Is there anyway to force a carriage return after each closing tag.

The second problem is the target parser(not under our control) accepts only the closing tag style:

<tag /> or <tag></tag> when both the opening a closing tags are on the same line.

Is there anyway to control the format of the closing tag?

Any help at all would be greatly appreciated.

Regards

Geoff Upham

Re: SQL/XML Formatting [message #149739 is a reply to message #147492] Sat, 03 December 2005 14:41 Go to previous message
mchadder
Messages: 224
Registered: May 2005
Location: UK
Senior Member
Hello there.

Both should be achievable by using so-called "pretty printing", the easiest mechanism is by using .EXTRACT('/') at the end of your SQL/XML generation, which will put each indent each tag and convert the <x></x> notation to <x/>, i.e.
SQL> SELECT XMLELEMENT("xyz", XMLELEMENT("abc", dummy), XMLELEMENT("def", NULL))
  2  FROM dual
  3  /

XMLELEMENT("XYZ",XMLELEMENT("ABC",DUMMY),XMLELEMENT("DEF",NULL))
--------------------------------------------------------------------------------
<xyz><abc>X</abc><def></def></xyz>

SQL> SELECT XMLELEMENT("xyz", XMLELEMENT("abc", dummy), XMLELEMENT("def", NULL)).EXTRACT('/')
  2  FROM dual;

XMLELEMENT("XYZ",XMLELEMENT("ABC",DUMMY),XMLELEMENT("DEF",NULL)).EXTRACT('/')
--------------------------------------------------------------------------------
<xyz>
  <abc>X</abc>
  <def/>
</xyz>

For further information, see http://www.oratechinfo.co.uk/sqlxml.html#point5.
Previous Topic: namespace prefix "xsi" is not declared
Next Topic: end-of-communication channel while executing sqlldr from java procedure
Goto Forum:
  


Current Time: Tue Apr 16 15:29:06 CDT 2024