XSQL and XSLT, database access

XSQL

1. XSLT and XSQL
2. xsltuk-01, papers ,XSLT as a Query Language

1.

XSLT and XSQL

Steve Muench




| Are you saying that there is a  way of "getting list from the 
| database" ?


The document() function allows any XML resource reachable
via a URI to be brought into the XSLT processing. Several
technologies are available to make dynamic database
content easily "reachable via HTTP URL" as XML resources.



Here's an example that uses document() to retrieve the <Code>
and <Description> of any airports in the world matching
the value of the "code" parameter passed into the stylesheet.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes"/>
<xsl:param name="code"/>
<xsl:template match="/">
<Airports xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
  <xsl:variable name="baseUrl"
    select="'http://ws5.olab.com/xsql/demo/airport/airport.xsql?airport='"/>
  <xsl:variable name="dataServiceUrl" select="concat($baseUrl,$code)"/>
  <xsl:variable name="dynamicAirportList" select="document($dataServiceUrl)"/>
  <xsl:for-each select="$dynamicAirportList">
    <xsl:copy-of select="//Airport/Code | //Airport/Description"  </xsl:for-each>
</Airports>
</xsl:template>
</xsl:stylesheet>

$ oraxsl -p code='xml' any.xml airports.xsl

Returns:

<?xml version = '1.0' encoding = 'UTF-8'?>
<Airports>
   <Code>XML</Code>
   <Description>Minlaton, Sa, Australia</Description>
</Airports>

$ xt any.xml airports.xsl code='paul'

Returns:

<?xml version = '1.0' encoding = 'UTF-8'?>
<Airports>
   <Code>CGH</Code>
   <Description>Sao Paulo, Sp, Brazil-Congonha</Description>
   <Code>GRU</Code>
   <Description>Sao Paulo, Sp, Brazil-Guarulho</Description>
   <Code>KPH</Code>
   <Description>Pauloff Harbor, Alaska, Usa</Description>
   <Code>MSP</Code>
   <Description>Minneapolis/St. Paul-Intl</Description>
   <Code>PAV</Code>
   <Description>Paulo Afonso, Ba, Brazil</Description>
   <Code>SAO</Code>
   <Description>Sao Paulo, Sp, Brazil-Guarulho</Description>
   <Code>SNP</Code>
   <Description>St. Paul Island, Alaska, Usa</Description>
   <Code>STP</Code>
   <Description>Minneapolis/St. Paul-Dntn</Description>
   <Code>SVM</Code>
   <Description>St. Paul'S Mission, Qld, Austr</Description>
   <Code>SVV</Code>
   <Description>San Salvador De Paul, Venezuel</Description>
</Airports>

On the server side, sitting out on the Internet is an Oracle XSQL Page
at the URL: http://ws5.olab.com/xsql/demo/airport/airport.xsql
and an Oracle database with a table of all airports in the world.

Which looks like this:

<?xml version="1.0"?>
<xsql:query xmlns:xsql="urn:oracle-xsql"
     connection="demo" 
     rowset-element="Ok" 
     max-rows="1" 
     row-element="Airport" >

       SELECT tla "Code", description "Description"
  FROM AIRPORT
 WHERE tla = UPPER('{@airport}')

  <xsql:no-rows-query 
     max-rows="10" 
     rowset-element="Error" 
     row-element="Airport" >

       SELECT tla "Code", description "Description"
  FROM AIRPORT
 WHERE UPPER(description) LIKE UPPER('%{@airport}%')
        ORDER BY tla
  </xsql:no-rows-query>

</xsql:query>

2.

xsltuk-01, papers ,XSLT as a Query Language

Evan Lenz

For anyone who might be interested, I've posted my XSLT-UK slides at the following URLs:

http://www.xmlportfolio.com/xsltuk/slides
http://www.xmlportfolio.com/xsltuk/slides.zip (zipped version)

The updated/adapted paper on XQuery is available here:

http://www.xmlportfolio.com/xquery.html

Enjoy, Evan Lenz