[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: read records from database in XSLT
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|