THE XML TECHNOLOGY IMPLEMENTED IN MICROSOFT SQL SERVER Pirnau Mironela Universitatea Titu Maiorescu, Facultatea de Stiinta si Tehnologia Informatiei, Str. Horia Mecelariu nr 8-10, bl 21/1 sector 1, Bucuresti, mironelapirnau@yahoo.com, Tel : 0723210205 The scripting languages from the Server (ASP and ASP.Net then PHP or JSP) are nowadays advanced and mature technologies that offer the possibility of developing new and complex applications on the Web. Despite the existence of these technologies, basic changes took place lately regarding informational needs or equipments used by a large variety of users. Therefore, today not only the computers are connected to Internet but also hand- held devices.. Taking into account these necessities it is strongly required an universal language that can be understood by all these different devices XML proved to be the answer to this need, representing a new superior stage from all points of view. In the evolution of the information age data exchange is enabled among various equipments. Key words: HTML, XML, IP, database, query language, web services Definitions regarding XML XML (Extended Markup Language) represents the center of a great number of technologies, presently forming the most used language. XML is the simplest and most efficient way of sending data through Internet. The latest version of database administration systems of client-server type (Oracle, MS SQL Server or IBM DB2) generated a support for the XML technology. The users have the possibility, through extra parameters of SQL instructions, to realize all the operations they desire in a very simple manner. We will show some facilities offered by Microsoft SQL Server 2000 for the XML technology. The theoretical elements on this subject will be followed by practical examples. We will present the integration manner of SQL Server along with the Web Internet Information Server (IIS), explaining at the same time new options specific to the SQL language, capable of offering support for XML. XML or Extended Markup Language constitutes the base of all the elements that form the Web Services technology. Regarding the platform independence, XML represents the search engine that makes possible the data transfer through Internet, and it also constitutes the WEB services basis. XML is related to the HTML HyperText Markup Language) language. Between the two types of languages there are some similarities but also a few differences that under no circumstance may be neglected. First of all we have to mention that both of them have the same origin, represented by SGML (Standard Generalized Markup Language). This is a general language that offers the users the possibility to structure their documents and data in an electronic format, through similar mechanisms of classical grammar. HTML uses the same set of tags which help define the manner that the information will be displayed in the used Web browser. The HTML private tag set is limited and unspecialized, being generated through SGML technology. In these conditions there is no possibility to particularize your available tag sets according to your desires and needs. The mentioned lack of flexibility could represent, in some cases, an important obstacle. Thereby, in applications for database exploitation, the usage of HTML language is improper for delivering data, which does not represent a major impediment. Unlike HTML, the XML language offers the user the possibility to build up his own tag set that will be used for a certain document setup. In this manner there is a special flexibility because this element is needed to define electronic specialized documents. 1490
Chart 1 XML and Web services form a basic solid hardware equipment variety Structure of XML folders Like HTML folders, for XML structures text format for stocking the information is used. In this manner the transferability of data on any platform or device is assured. Essentially, all the elements evolved in XML technology are as follows: The proper XML folder that contains a set of tags and the proper information, delivered through it. The validation regulated and all types of data declaration, included in the document, realized by DTD (Data Type Declaration) language. Using DTD language the set of tags used to mark up the document will be defined. DTD has the function to validate the content and the structure of XML folders. In the present time there is a series of DTDs dedicated to certain domains from which we mention: HL7 element particular for human health domain or MathML particular element for mathematical equations. Using DTD elements the information can be organized on specific domains much easier. In the latest years, XML Schemas was recommended for describing data included in XML folders. This kind of technology constitutes an evolution in time from the classical DTD data descriptive language. Sheets of XSL type will be used to particularize the XML browser folder information display manner. The type sheets have a similar function to CSS (Cascading Style Sheet) formatted folders. In this manner, we may establish a table structure, containing display data, colors and formatted fonts of the information, as well as other formatted data included in the XML folder. XML and database connections XML represents the simplest and the most efficient manner to transfer the information on the Internet. In the past every time a data transfer was needed on different platforms, the text folders were used. The data were separated through commas or other specific marks. Once XML language was born, this transfer manner was forgotten. Reported to other types of data information transfer, XML has the advantage of being very simple, having efficient structures of the information, as well as information transfer on any platform or device. For operating and transfer the database information through XML language, several operations must be followed successively: The user sends a demand to the Web server, asking for example the stock exchange rates for the shares he wants to buy or sell. The Web server send the demand to the database server under a SQL interrogation, the former sending back the demanded set of registrations. The sent data to the database server are covered by specialized solutions and delivered through the Web server. On the personal computer of the user that made the request, the data are assumed and transferred in the local data base. 1491
These steps make a great example of interrelation and inter-operations of the XML technology and Internet. It is mandatory to mention that the second and third steps will form a single step; therefore most of the administration database systems have incorporated direct export facilities of data in XML format, without using additional applications or accessories. SQL Server 200 and Access 2003 include a complex support for XML. XML support used for SQL Server In order to use XML support it is mandatory to install the SQL Server 2000 version. For installing the database server it is necessary to select the IIS component of SQL XML Support. This element offers the possibility to inter-operate with the Web Internet Information Services (IIS) server database. The Web IIS server offers the possibility to realize interrogations upon the database and to obtain results through a simple Web browser. The XML support configuration for SQL Server requires the following operations: a) By applying the SQL XML Support in IIS the New Virtual Directory option is selected. After that the interaction between the database server and the Web server will be established. b) Creating a virtual named directory and a physical directory where Web pages or specific elements will be stocked. Supposing that the virtual directory was called XML, through the browser, Web pages or SQL interrogations based on XML technology may be accessed, using the following address: http://server name web/xml. Instead of the name of Web server, it may also be used the IP address, according to it. In those situations when these interrogations are locally tested, on the personal computer, it is necessary to introduce the following URL addresses: http://localhost/xml and http //127.0.0.1/XML. c) Through the Security section, it is possible to introduce a valid username and a password for accessing a SQL Server database we want to export through XML technology. Furthermore, if we established a mixed identification manner, we may access the database through a SQL Server account and also using a standard user account of the Windows operational system. d) Data Source section allows the SQL server to be accessed in the database we use. When you will access the server on the local network, it will be mandatory to mention the IP address. If you intend to test the local settings, you must mention the (local) SQL Server identification. e) Settings -sets the manner the interaction between the database server and the Web server will be realized through XML technology. Regarding these, two important options may be established: Allow ULR Queries - option realizes SQL-XML interrogations, directly through SQL interrogations as supplementary parameter at the ULR address. Allow Template Query option realizes interrogations using a series of pre-defined patterns. There are also other configuration options that allow the directory settings and the XSL folders configuration schemes to be stocked. SQL and XML interaction The interrogation allowance through old SQL instructions was realized by adding additional sets of supplementary parameters that allow establishing ways of database registrations in XML format. Therefore, at the SQL standard registration a FOR XML AUTO provision was added. Supposing that we want to interrogate the data in an Employees chart, we will realize the following interrogation: SELECT*FROM<CHART NAME>FOR XML AUTO. Instead of the AUTO parameter, there is also the possibility of using the Raw option, offering the option of using the row tag for identification each database registration exported in XML format. Additionally, the SQL Server facilitates the possibility to import registrations-available on XML folder, into the database. Therefore, in order to accomplish this operation the OpenXML function is needed, being used as a parameter of the SQL Insert command. 1492
SQL-XML interrogation manner Implementing all the options of the IIS and MS Sql server, an efficient interrogation of the SQL interrogations are available. These return the database registrations from a database format into a XML one. There are two fundamental manners of implementing these operations: a) a) Directly addressed interrogations- If the Allow URL option was activated, there is the possibility to realize the interrogation by introducing the SQL instruction, directly as a parameter of the accessing address of the Web server. Accomplishing this operation opening the Web browser and introducing the following address it is necessary: b) http://localhost/xml?sql=select+*+from+name_table>+for+xml+auto&root=roo t. c) The first part of the address identifies the Web server and the XML virtual directory. The SQL instruction it is present by using the?sql parameter and the keywords of the interrogation have been separated using +. d) At the interrogation the &root=root section has been added stressing the presence of the root element of the XML document. Therefore, the root tag root has a similar function as the HTML tag, specific for HTML language. Also, in a similar manner, the XML folder will be closed using the /root tag. e) b) The usage of interrogation patterns Interrogations realized by introducing SQL instructions as a ULR parameter address it is harder to realize because it is needed a direct SQL instruction through the browser. For eliminating this disadvantage there is the possibility to use interrogation patterns. Introducing a SQL instruction in a XML folder a predefined tag may be used sql:query. Here is an example of a XML folder where a SQL instruction from a database chart was introduced: <ROOT xmlns:sql= urn:schemas-microsoft-com:xml-sql > <sql:query> SELECT FROM <name_chart> FOR XML AUTO </sql:query> </ROOT> For using the SQL interrogation on the Web browser, we used the following URL address: http://localhost/xml/interrogation.xml. When these interrogations are changed in the browser, as a result we will have a unformatted XML folder. When we want to individualize the manner the information are presented from the XML folder into the browser, it is necessary to use the XSL style sheets. These style sheets have a similar function with the CSS (Cascading Style Sheet) folders. In this way will a chart structure of presenting the data be eastablished, the colors and the formatted fonts of the information, as well as other formatting elements included in the XML folders. Stocking procedures The stocking procedures represent a pre-collected set of SQL instructions, saved on the database server under a name and after that unitary processed. They enable the user to realize complex operations on the database through a single signal sent by the source application. The user may also use declared variables, conditioned instructions and other strong programming elements. The stocking procedures are always present in the relational database systems, based on the client/server (MS SQL Server or Oracle) technology. In the stocking procedures case, for MS Sql Server database, the Transact-SQL language it is used. This language constitutes the standard manner to communicate among the resulted applications and the database server. Transact-SQL it is a language based on Structured Query language (SQL), the ANSI standard for interrogation database languages. They enable the chart creation, establish access rights for various elements and insert, modify or delete registrations from the database. In the stocking procedures 1493
cases, Transact-SQL presents a supplementary set of instructions, reason that transform it from an interrogation database language into a genuine programming language. Conclusions By using the XML technology, one may easily change the stocking procedures on the server through a simple Web browser. For completing this procedure is mandatory the use of the Execute command, as a changing parameter to the URL address that accesses the Web server. The interrogation of XML support into SQL Server 2000, allows an efficient data transfer among the various information systems. Regarding economical applications, the XML technology offers an overflow inter-operational level, as well as many integration possibilities with different practical solutions. References 1. Floarea N stase, Pavel N stase Tehnologia aplica iilor Web (XML-DOMASP), Editura Economic 2002 2. John Gallaugher - The Critical choice of Client/Server Arhitecture White Group Press. 3. Kaufman F. Data Systems Cross Company Haward Business 2001. 1494