Oracle XSQL- P15Welcome to the exciting world of eXtended Structured Query Language (XSQL) development! What’s so exciting? Efficiency and ease of use. XSQL isn’t some razzle-dazzle technology to wow your users. It also isn’t the latest X standard du jour that no one can stop talking about until you ask, “But what does it do for me today?” The problem with all of the great stuff out there is that no one technology does it all. | HAPTER Retrieving XML Oracle can store any media type in the database XML is no exception. In the previous pages you saw how to query against XML documents stored in the database. This section examines how to return XML as opposed to strings into your XSQL. The first tool you ll examine is the xsql include-owa action which allows you to write XML into the XSQL result. Next you ll learn about the XMLGEN utility. It essentially allows you to do what XSQL does generate XML based on a SQL query. The difference is that you can generate XML from inside a PL SQL procedure. The last section covers a new feature of Oracle 9i the XMLType. This allows you to easily store and query XML documents stored in Oracle. Before beginning the lessons it s important to understand what is hard about retrieving XML with XSQL. The first section covers these difficulties. What s So Hard In the previous section on Oracle Text you saw that it is quite easy to store XML in the table. Just insert it like any other text. The size of our test documents was limited but that is easily remedied just use a CLOB type and you can store gigabytes of XML. You might be wondering Can t you just select the text 261 262 Chapter 11 Well you can but not with the xsql query action. Consider the following XSQL xml version page connection demo xmlns xsql urn oracle-xsql xsql query SELECT text FROM docs_table WHERE contains text software INPATH article body 0 xsql query page It will execute easily enough and return the result shown in Figure . It looks like XML so what s the problem Upon closer examination you ll see that the XML returned by the query isn t XML at all Notice that Internet Explorer didn t render it with the customary colored tags. When you look at the source you ll see that all of the essential XML characters have been escaped and replaced with their URL-encoded equivalents. What a shame In the context of this example it seems that you have uncovered a horrible failing of XSQL. But it isn t