[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: read records from database in XSLT

Subject: RE: read records from database in XSLT
From: Mingqiang Yu <myu@xxxxxxxx>
Date: Tue, 14 May 2002 23:36:00 -0600 (MDT)
xslt reading records from database
Hi, Stuart,

I don't know if mysql can do what the Microsoft SQL does. But I'll give it 
a try. On the other hand, I'm thinking that, if the parameter for 
document() can be a URI, can I write a java servlet which takes the query 
passed through the url and return the query results? But the question is, 
in what format the output should be in? Should it be in plain text format 
or html? Is this a matter of passing the content type in the header?  

Thanks a lot for your help and your suggestions.

Ming

 On Tue, 14 May 2002, Stuart Celarier wrote:

> Ming,
> 
> I cannot speak to MySQL, but I saw a great demonstration of accessing a
> database from XSLT in Craig Andera's talk at the Web Services Developers
> Conference [1] in March. In his presentation he implemented a Web
> Service using XSLT, Microsoft SQL Server and IIS (Microsoft's web
> server). Very cool. Perhaps these notes will guide you in working with
> your own tools.
> 
> The key concept is that the document() function is called with a string
> parameter, that string is treated as a URI. That URI may be the URL for
> a file or any other resource the server can serve up. Using MS SQL
> Server, the database is exposed as an HTTP endpoint using the IIS
> Virtual Directory Management for SQL Server utility. That makes it
> possible to query the database via a URL, something of the form
> 
>   http://localhost/myDatabase?sql=SELECT * ... FOR XML AUTO
> 
> with all the space characters properly escaped for a URL (I've left them
> out for clarity). The "localhost" term is the local name for the web
> server, replace that with the real server name if the database is being
> served up from another machine. This sort of URL can then be passed into
> XSLT's document() function to perform a query against the database and
> return it as an XML document.
> 
> So the problem you need to solve isn't really with XSLT, it is with
> exposing your database through a web server so that you can access it
> with a URL. Can you do that with MySQL? Good luck and let me know if you
> have success.
> 
> Cheers,
> Stuart
> 
> [1] http://www.sellsbrothers.com/conference
> 
> 
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ming
> Sent: Tuesday, May 14, 2002 16:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  read records from database in XSLT
> 
> Hi,
> 
> I have a question regarding reading records from a database in XSLT.
> 
> I have the following xml file:
> 
> <files>
> <file db="db1" name="/record/2233/21/1/12_mmish"  />
> <file db="db2" name="/record/2233/21/2/34_ytrrm"  />
> </files>
> 
> And the name attribute is a key in a mysql table. What I want is the
> value of the key. So, I can use "select recordvalue from Record where
> keyvalue = '/record/2233/21/1/12_mmish'" to get the record value from
> the table.
> 
> The record value is actually in xml format like this:
> <xml>
>   <db1>
>    <title> title1 </title>
>   </db1/>
> </xml>
> 
> What I need is to read the whole value in my stylesheet using something
> like <xsl:variable name='record' select="document(@name)/xml"/>. But
> since the name attribute is not the path to a xml file, I cannot use
> this method.
> 
> Can anyone give me some suggestions on how to approach this or some
> information I can know more about using queries in my stylesheet?
> 
> Thanks a lot.
> 
> Ming
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.