Constructing Your Own Adapter URL

Generally speaking, you should use Stylus Studio to construct the adapter URLs you use in Java application. Adapter URLs can be complex - properties and their values vary from one adapter to another, for example - and long, so using Stylus Studio to construct them can reduce errors in your applications.

Tip

 

Adapter URLs in the Select XML Converter dialog box are already escaped and can be used as-is. Adapter URLs taken from the Project window must be escaped manually when you paste them into your application.

Using the URL in the Select XML Converter Dialog Box

To construct an adapter URL using the URL in the Select XML Converter dialog box:
1. Use the adapter to open a file as an XML document in Stylus Studio. This can be a user-defined or built-in adapter, as appropriate. See How to Open a File Using an Adapter if you need help with this step.
2. Before clicking OK to complete the conversion, copy the adapter URL in the URL field of the Select XML Converter dialog box (see Figure 508).
3. Click OK to complete the conversion. (You can click Cancel if you are peforming this procedure just to obtain the adapter URL.)
4. Paste the adapter URL into your Java program.

Using the URL in the Properties Window

To construct an adapter URL using the URL in the Properties window:
1. Use the adapter to open a file as an XML document in Stylus Studio. This can be a user-defined or built-in adapter, as appropriate. See How to Open a File Using an Adapter if you need help with this step.

Tip

 

New documents are placed in the Other Documents folder in the Project window by default.

2. Open a new document in any Stylus Studio text editor (for example, File > New > Java: Text Editor).

The purpose of this step is to provide an editor into which you can drag-and-drop the the document you created in step 1 in order to display the associated adapter URL.

3. Drag the document you created in step 1from the Project window and drop it into the text editor you opened in step 2.

The complete URL appears in the text editor.

Figure 509. Copying a URL to a 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).
 
Free Stylus Studio XML Training:
W3C Member