XML Features of Oracle 8i and 9i (4/7) - exploring XML
XML Features of Oracle 8i and 9i
XSQL servlet
XSQL servlet - as distinct from the XSU described above - is a tool that processes SQL queries and outputs the result set as XML. As a standard java servlet it should work with any java enabled web server. As input it uses an "XSQL" file: an XML file containing embedded SQL queries. XSQL pages are similar to ASPs/JSPs but give XML as output and allow for standard XML processing using XSL.
Example XSQL file:
<?xml version="1.0"?> <xsql:query connection="demo" xmlns:xsql="urn:oracle-xsql"> SELECT Carrier, FlightNumber, Origin, ExpectedTime FROM FlightSchedule WHERE Destination = '{@City}' </xsql:query>
Called via:
https://mywebserver/flights.xsql?City=LHR
Would result in this output:
<?xml version="1.0"?> <ROWSET> <ROW num="1"> <CARRIER>LH</CARRIER> <FLIGHTNUMBER>LH343</FLIGHTNUMBER> <ORIGIN>London</ORIGIN> <DUE>12:44</DUE> </ROW> <ROW num="2"> <CARRIER>BA</CARRIER> <FLIGHTNUMBER>BA272</FLIGHTNUMBER> <ORIGIN>Birmingham</ORIGIN> <DUE>02:05</DUE> </ROW> </ROWSET>
But XSQL pages can also contain references to stylesheets such as:
<?xml-stylesheet type="text/xsl" href="flight-list.xsl"?>
to convert the above into HTML or other formats.
Other features of XSQL pages:
- Insert and updates also possible
- Can contain more than one query
- Queries can be parameterised i.e WHERE Destination = '{@City}'
- Variables for pagination of a recordset available e.g
XSQL servlet can be called in different ways:
- via an http request e.g https://myserver/myquery.xsql (when enabled as a servlet)
- via a command line utility e.g xsql airport.xsql airport=LHR xml-stylesheet=none
- from a java or jsp or other XSQL file
Next is the XML class generator...
Produced by Michael Claßen
URL: https://www.webreference.com/xml/column81/4.html
Created: May 10, 2003
Revised: May 10, 2003