Overview of DB-to-XML Data Sources

SQL/XML is an extension of the Structured Query Language (SQL) that allows you to query relational data, render query results as XML, and write modified or new data back to a relational database. Stylus Studio supports the SQL/XML standard by allowing you to create a DB-to-XML data source, a file that contains

  • Connection settings used to connect to a specific relational database on a specific server. You specify connection settings in a scenario. See DB-to-XML Data Source Scenarios for more information.
  • SQL/XML statements (SELECT and UPDATE, for example) that you want to execute on that database. Query results returned by the DB-to-XML data source you define can be used in Stylus Studio anywhere you use XML.
The URL Builder

If you need only to render an entire table or view as XML, use the URL Builder. Any time you need more control - writing your own SQL/XML or updating the relational database, for example - use a DB-to-XML data source. See Using the URL Builder for more information on the URL Builder Utility.

In this section

This section covers the following topics:

Supported Databases

Stylus Studio supports several relational databases, including:

  • IBM DB2
  • Informix
  • Microsoft SQL Server
  • Oracle
  • Sybase

In addition, you can use DataDirect SequeLink Server, bundled with Stylus Studio, to connect to any ODBC data source. See Choosing a Database to learn more about specifying a database for a DB-to-XML data source.

System Requirements

In order to use DB-to-XML data sources, the Java Runtime Environment (JRE) 1.4.x or greater must be installed on your machine. This feature also requires that you install the JRE with the optional module, Support for Additional Languages. You can verify whether or not this module has been installed by checking your JRE for these files:

  • i18n.jar
  • charsets.jar

DB-to-XML Data Source Scenarios

A DB-to-XML data source scenario is a group of customizable settings associated with a DB-to-XML data source. You use a scenario to specify connection settings, such as the

  • Database type
  • Database server URI
  • Username and password required to log on to the database server

You define these settings on the Scenario Properties dialog box. See Specifying Connection Settings to learn more about DB-to-XML data source scenarios.

The DB-to-XML Data Source Editor

You use the DB-to-XML data source editor to specify database connectivity settings, and to compose the SQL/XML (queries and other actions) that you want to execute on the server.

Figure 311. DB-to-XML Data Source Editor

Tip

 

Once you connect to a server, Stylus Studio displays the databases, tables, views, and columns on the right side of the editor. When composing your SQL statements, you can drag and drop tables, views, and columns from the database schema tree into the SQL/XML editor.

SQL/XML Editor

The SQL/XML editor is on the left side of the DB-to-XML data source editor. It consists of two tabs, SELECT and UPDATE, which you use to compose SQL/XML SELECT and, optionally, UPDATE and INSERT statements. You can type directly in the editor, or you can use drag-and-drop to automatically compose SQL/XML statements.

See Composing SQL/XML in Stylus Studio to learn more about using the SQL/XML editor.

Database Schema Tree

The database schema tree is on the right side of the DB-to-XML data source editor. Once you have established a connection to the database specified in the scenario, Stylus Studio displays a tree diagram of the database schema.

Figure 312. Database Schema Tree

The database schema tree is displayed by default. You can hide it by clicking the Show/Hide Database Schema button ( ).

Note

 

Once the connection with the server has been established and the database is located, Stylus Studio drops the connection to the server. You can reconnect to the database to refresh the database schema tree by selecting DB-to-XML > Load Database Schema from the menu bar.

Information in the schema tree is displayed in a hierarchical fashion, starting with the server you specified in the scenario. Tables, views, and columns are displayed in database order; column data types are displayed in the Type column.

Working with Relational Data

Stylus Studio can automatically create valid SELECT, INSERT, and UPDATE SQL/XML statements based on the objects you select from the database schema tree. In addition, your DB-to-XML data source can contain any valid SQL/XML statement defined on the SELECT or UPDATE tabs. The actions that can be performed by the SQL/XML you define in your DB-to-XML data source are limited only by the permissions of the username you use to log in to the database. See Composing SQL/XML in Stylus Studio for more information on this topic.

Creating a DB-to-XML Data Source

The process of creating a DB-to-XML data source in Stylus Studio involves the following steps:

1. Open a new DB-to-XML data source document in Stylus Studio. See Opening a New DB-to-XML Data Source Document.

Stylus Studio displays the Scenario Properties dialog box.

2. Specify a scenario name (or accept the default) and the information needed to connect to the database server and log in to the database. This information includes
    • The database type (Oracle or Sybase, for example)
    • The server on which the database resides
    • The username, password, and any other information required to log in to the database.
    • See Specifying Connection Settings.

3. Save the scenario. Stylus Studio automatically connects to the database and logs you into the server. The database schema, table, view, and column information for the database you specified in the scenario appears in the DB-to-XML editor.
4. Compose the SQL/XML SELECT statement to query the database. (UPDATE and INSERT statements, which write modified data back to the database, are optional.) See Composing SQL/XML in Stylus Studio.
5. Execute the query and review the XML it returns.
6. Optionally (if you have written SQL/XML to write new or modified data to the database), save the XML document returned by the SQL/XML query to write data back to the database. See Working with Relational Data as XML.

The remainder of this chapter describes these steps in greater detail.

 
Free Stylus Studio XML Training: