Re: Future XSLT extensions. document(). Summary.

Subject: Re: Future XSLT extensions. document(). Summary.
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Wed, 22 Mar 2000 11:38:09 -0800
| > Any listbox that needs to be filled is  filled using the document() function to 
| > get that list from the database.
| 
| Are you saying that XSLT has a standard way of "getting list from the 
| database" ?

Sure.

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.

| Very interesting.  Could you please tell me what is the syntax 
| of XSLT document() you are using to access the database?

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>

_________________________________________________________
Steve Muench, Consulting Product Manager & XML Evangelist
Business Components for Java Development Team

 
| > Any listbox that needs to be filled is  filled using the document() function to 
| > get that list from the database.
| 
| Are you saying that XSLT has a standard way of "getting list from the 
| database" ?
| 
| Very interesting.  Could you please tell me what is the syntax 
| of XSLT document() you are using to access the database?
| 
| Would it work in more than one environment? If it will work 
| only in particular environment isn't it just a vendor-specific
| extension? 
| 
| > Without the document() function, XSLT is extremely limited.
| 
| Is that possible to get some examples of using document() 
| in the form other than document(URI) then ?  ( Once again, 
| nobody is saying that document(URI) should die. 
| But document() is much more than just document(URI) ).
| 
| Rgds.Paul.
| 
| 
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread