Microsoft's XML technology preview's functionality consists of an Internet Service API (ISAPI) application, sqlxml.dll, which accepts SQL Server input in special XML formats. How does the technology preview's XML functionality work? First, the registration program, a Microsoft Management Console (MMC) snap-in, associates an entire virtual directory in Microsoft IIS with the ISAPI application. IIS then passes requests for pages in that virtual directory (even typical HTML pages) to the ISAPI application. The application accepts XML input in the supported formats and transforms the input into SQL statements, which it passes to SQL Server. The technology preview can process SQL queries and update grams (XML-based update, insert, and delete statements) as well as parameterized queries and stored procedures. In each case, the ISAPI application sends only pure SQL statements to SQL Server.
SQL Server 7.0 and earlier releases don't understand SQL Server 2000's FOR XML clause, so the ISAPI application just saves the keywords for use in processing SQL Server's response. SQL Server returns results as rows and columns, and the ISAPI application postprocesses them into XML output. Depending on the output style you've specified (FOR XML AUTO, FOR XML RAW, or FOR XML EXPLICIT), sqlxml.dll produces an XML stream from the returned rows and columns. You can also request that sqlxml.dll apply an Extensible Style Language (XSL) style sheet to the XML document or prepend the document with a Document Type Definition (DTD) or XML Data Reduced (XDR) format schema. In addition, sqlxml.dll can return an IMAGE type column of data as a single XML stream for direct display on the client browser. If the application encounters an error, it returns the correct ODBC error code. For update grams, sqlxml.dll typically doesn't return a "number of rows affected" result; to make the ISAPI application return anything other than an HTTP "200 OK" message containing a blank document, you need to follow the update query with a select statement that queries the rows you just inserted.
Because the technology preview uses ODBC to send SQL statements to the database, Microsoft will expand the technology preview to support other selected ODBC data sources besides the one for SQL Server. The technology preview is natural as a Web service because its XML functionality is available only through an ISAPI application. And besides its ability to directly produce XML and HTML output through style sheets, the preview offers an object model (osqlxml.dll) for direct access to XML through programs such as Microsoft Excel. You can access the object model through a Visual Basic (VB) program, and you can load the output into a Document Object Model (DOM) document like the one Listing A shows. The SQL Server 2000-equivalent ISAPI application doesn't have an object model, but the post-SQL Server 2000 Web release will contain an object model and all the best features of both the technology preview and SQL Server 2000's integrated XML support.