|
Home > Online Product Documentation > Table of Contents > Invoking an Adapter Programmatically Invoking an Adapter Programmatically
You can use the Stylus Studio File System Java API to invoke an adapter programmatically. This section provides background information on using adapter URLs in Stylus Studio and in your applications, and it describes
This section covers the following topics: Adapter URLs
Stylus Studio uses URLs extensively to reach a variety of data sources. For example, if you use the built-in CSV converter to open the
The instructions to the adapter engine from this instance of the adapter URL are described in Table 20.
While the basic format of the adapter URL is the same from one adapter to another, there are differences. For example:
This converter uses
Where Adapter URLs are Displayed in Stylus StudioAdapter URLs are displayed
You can use either as sources for the adapter URL strings you use in your Java applications. See Constructing Your Own Adapter URL for more information. The StylusFile Object
In Java, we write the following to retrieve the content of a file,
The content of
The
In this example, the
See Example - demo.bat for a description of the sample Java application installed with Stylus Studio, which illustrates different uses of the adapter URL. Constructing Your Own Adapter URLGenerally speaking, you should use Stylus Studio to construct adapter URLs, which you can then copy, as strings, into a Java application. Adapter URLs can be complex - properties and their values vary from one adapter to another, for example - so using Stylus Studio to construct them helps reduce errors in your applications.
Using the URL in the Select XML Converter Dialog BoxTo construct an adapter URL using the URL in the Select XML Converter dialog box:
1. Use a converter (user-defined or built-in) to open a file as an XML document in Stylus Studio. See
How to Open a File Using a Converter if you need help with this step.
2. Before clicking
OK to complete the conversion, copy the adapter URL in the URL field.
3. Click
OK to complete the conversion.
4. Paste the adapter URL into your Java program.
Using the URL in the Properties WindowTo construct an adapter URL using the URL in the Properties window:
1. Use a converter (user-defined or built-in) to open a file as an XML document in Stylus Studio. See
How to Open a File Using a Converter if you need help with this step.
2. Open a new document in any Stylus Studio text editor (for example,
File > New > Java: Text Editor).
3. Drag the document from the
Project window into your new document.
The complete URL appears in the text editor.
4. Copy the complete adapter URL.
5. Paste the adapter URL into your Java program.
6. Escape characters as required for strings in Java programs. For example,
escape=\:quotes='" becomes
escape=\\:quotes='\" (the single quote does not need to be escaped).
Example - demo.bat
The following example shows an implementation of a simple application built using the Stylus Studio File System Java API. The application,
Demonstration Files
The files required to run this demonstration are installed in the
demo.java
Here is the
Required classes
The file starts with the Java and Stylus Studio File System Java API classes and interfaces required by
Setting the installation directory
User-defined converters (
These lines are commented out in
Creating an instance of StylusFile
Next, the
The copy () method
The
The
Whether your files are saved as XML or non-XML depends on how the
Converting a file to XML
Once the new instance of
In this block of code, the adapter URL is used to specify the
Converting an XML document to another format
This exception block specifies the
Using an adapter URL with a user-defined converter
The final exception block uses a user-defined converter built using the Convert to XML module (
As with the first exception block, this block uses the adapter URL to specify the
More About the Stylus Studio File System Java APIYou can learn about other uses for the Stylus Studio File System Java API in Stylus Studio File System Java API, located in Chapter 13Extending Stylus Studio. JavadocJavadoc for the Stylus Studio File System Java API is installed with Stylus Studio. It is available in the Stylus Studio /doc/Javadoc directory. Open index.html to get started. The Javadoc is also available on the Stylus Studio Web site, www.stylusstudio.com. |
Configuring an ODBC Data Source Using DataDirect SequeLink Server
How to create and configure an ODBC system data source for use with Stylus Studio using DataDirect Sequelink Server.
DB2
IBM DB2 is a database management system for powering business applications. Learn how to build XML solutions on DB2 using Stylus Studio's DB2 tools.
Configuring the Java Runtime Engine or Java Development Kit
This page identifies the Stylus Studio modules that require Java runtime and Java compiler components, where you can download these Java components, and how to force Stylus Studio to detect new or changed Java components.
XPath Editor
Stylus Studio's intelligent code-sensing, auto-completion technology, Sense:X, is XPath-aware. You'll find Sense:X for XPath in all of Stylus Studio's editors, including the XML Editor, XSLT Editor, and XQuery Editor.